All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] tcp_probe: avoid modulus operation and wrap fix
Date: Mon, 25 Jan 2010 08:30:06 -0800	[thread overview]
Message-ID: <20100125083006.47fd2f7e@nehalam> (raw)
In-Reply-To: <20100124.224122.13742906.davem@davemloft.net>

On Sun, 24 Jan 2010 22:41:22 -0800 (PST)
David Miller <davem@davemloft.net> wrote:

> From: Stephen Hemminger <shemminger@vyatta.com>
> Date: Sun, 24 Jan 2010 21:50:01 -0800
> 
> > @@ -75,12 +75,12 @@ static struct {
> >  
> >  static inline int tcp_probe_used(void)
> >  {
> > -	return (tcp_probe.head - tcp_probe.tail) % bufsize;
> > +	return (tcp_probe.head - tcp_probe.tail) & (bufsize - 1);
> >  }
> >  
> >  static inline int tcp_probe_avail(void)
> >  {
> > -	return bufsize - tcp_probe_used();
> > +	return bufsize - tcp_probe_used() - 1;
> >  }
> >  
> >  /*
> 
> Hmmm...  When the ring is full head==tail, which means
> tcp_probe_used() returns 0.  Which would now make tcp_probe_avail()
> return "bufsize - 0 - 1".
> 
> Is that right?

Yes. in this ring; empty is head == tail, and full needs to
be tail == head - 1.

-- 

  reply	other threads:[~2010-01-25 16:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-25  5:50 [PATCH] tcp_probe: avoid modulus operation and wrap fix Stephen Hemminger
2010-01-25  6:41 ` David Miller
2010-01-25 16:30   ` Stephen Hemminger [this message]
2010-01-25 23:48     ` David Miller

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=20100125083006.47fd2f7e@nehalam \
    --to=shemminger@vyatta.com \
    --cc=davem@davemloft.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.