netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jun Zhao <mypopydev@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH] ipv4 : igmp : optimize timer modify logic in igmp_mod_timer()
Date: Wed, 23 Nov 2011 23:44:36 +0800	[thread overview]
Message-ID: <1322063076.6253.1.camel@barry.pixelworks.com> (raw)
In-Reply-To: <1322062966.17693.44.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC>

On Wed, 2011-11-23 at 16:42 +0100, Eric Dumazet wrote:
> Le mercredi 23 novembre 2011 à 23:26 +0800, Jun Zhao a écrit :
> > 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@gmail.com>
> > ---
> >  net/ipv4/igmp.c |   12 ++++++------
> >  1 files changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
> > index c7472ef..50d06c5 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;
> > -			spin_unlock_bh(&im->lock);
> > +	if (timer_pending(&im->timer)) {
> > +		if (time_before_eq(im->timer.expires, (jiffies + max_delay))) {
> > +			spin_lock_bh(&im->lock);
> 
> And you actually tested this patch ?

Sorry for this mistake. :(.  spin_lock_bh -> spin_unlock_bh

> 
> >  			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);
> 
> 
> Not sure why you want to optimize this very rare function call, risking
> adding bugs in it.
> 
> 
> 

      reply	other threads:[~2011-11-23 15:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-23 15:26 [PATCH] ipv4 : igmp : optimize timer modify logic in igmp_mod_timer() Jun Zhao
2011-11-23 15:42 ` Eric Dumazet
2011-11-23 15:44   ` Jun Zhao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1322063076.6253.1.camel@barry.pixelworks.com \
    --to=mypopydev@gmail.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).