[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1322066322-4782-1-git-send-email-mypopydev@gmail.com>
Date: Thu, 24 Nov 2011 00:38:42 +0800
From: Jun Zhao <mypopydev@...il.com>
To: davem@...emloft.net
Cc: eric.dumazet@...il.com, netdev@...r.kernel.org,
Jun Zhao <mypopydev@...il.com>
Subject: [PATCH v2] ipv4 : igmp : optimize timer modify logic in igmp_mod_timer()
When timer is pending and expires less-than-or-equal-to new delay,
we need not used del_timer()/add_timer().
Signed-off-by: Jun Zhao <mypopydev@...il.com>
---
net/ipv4/igmp.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index c7472ef..5f2aedf 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -215,14 +215,14 @@ static void igmp_mod_timer(struct ip_mc_list *im, int max_delay)
{
spin_lock_bh(&im->lock);
im->unsolicit_count = 0;
- if (del_timer(&im->timer)) {
- if ((long)(im->timer.expires-jiffies) < max_delay) {
- add_timer(&im->timer);
- im->tm_running = 1;
+ if (timer_pending(&im->timer)) {
+ if (time_before_eq(im->timer.expires, (jiffies + max_delay))) {
spin_unlock_bh(&im->lock);
return;
+ } else {
+ del_timer(&im->timer);
+ atomic_dec(&im->refcnt);
}
- atomic_dec(&im->refcnt);
}
igmp_start_timer(im, max_delay);
spin_unlock_bh(&im->lock);
--
1.7.2.5
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists