From: Eric Dumazet <eric.dumazet@gmail.com>
To: Mike Danese <mikedanese@google.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
James Morris <jmorris@namei.org>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
Patrick McHardy <kaber@trash.net>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net: refactor icmp_global_allow to improve readability and performance.
Date: Fri, 01 Jan 2016 18:07:15 -0500 [thread overview]
Message-ID: <1451689635.8255.71.camel@edumazet-glaptop2.roam.corp.google.com> (raw)
In-Reply-To: <1451635091-109673-1-git-send-email-mikedanese@google.com>
On Thu, 2015-12-31 at 23:58 -0800, Mike Danese wrote:
> We can reduce the number of operations performed by icmp_global_allow
> and make the routine more readable by refactoring it in two ways:
>
> First, this patch refactors the meaning of the "delta" variable. Before
> this change, it meant min("time since last refill of token bucket", HZ).
> After this change, it means "time since last refill". The original
> definition is required only once but was being calculated twice. The new
> meaning is also more intuitive for a variable named "delta".
>
> Second, by calculating "delta" (time since last refill of token bucket)
> and "cbr" (token bucket can be refilled) at the beginning of the
> routine, we reduce the number of repeated calculations of these two
> variables.
>
> There should be no functional difference.
>
> Signed-off-by: Mike Danese <mikedanese@google.com>
> ---
> net/ipv4/icmp.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
Hi Mike
Sorry, this is a very broken patch.
There is a comment you apparently missed completely :
/* Check if token bucket is empty and cannot be refilled
* without taking the spinlock.
*/
There is a reason we compute 'delta' two times.
One without the spinlock held, and a second time with the spinlock held.
This is an opportunistic way to exit early without false sharing in the
stress case where many cpus might enter this code.
Really I do not think current code needs any 'refactoring', especially
around December 31th at midnight ;)
next prev parent reply other threads:[~2016-01-01 23:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-01 7:58 Mike Danese
2016-01-01 23:07 ` Eric Dumazet [this message]
2016-01-02 3:20 ` Mike Danese
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=1451689635.8255.71.camel@edumazet-glaptop2.roam.corp.google.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=mikedanese@google.com \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.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
all inboxes | Powered by JetHome®