From: David Miller <davem@davemloft.net>
To: shemminger@vyatta.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] tcp_probe: avoid modulus operation and wrap fix
Date: Mon, 25 Jan 2010 15:48:14 -0800 (PST) [thread overview]
Message-ID: <20100125.154814.56026460.davem@davemloft.net> (raw)
In-Reply-To: <20100125083006.47fd2f7e@nehalam>
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 25 Jan 2010 08:30:06 -0800
> 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.
Ok, that makes sense, thanks for explaining.
Applied, thanks Stephen.
prev parent reply other threads:[~2010-01-25 23:48 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
2010-01-25 23:48 ` David Miller [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=20100125.154814.56026460.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/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).