lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 01 Jan 2016 18:07:15 -0500
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Mike Danese <mikedanese@...gle.com>
Cc:	netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
	Alexey Kuznetsov <kuznet@....inr.ac.ru>,
	James Morris <jmorris@...ei.org>,
	Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
	Patrick McHardy <kaber@...sh.net>,
	open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] net: refactor icmp_global_allow to improve readability
 and performance.

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@...gle.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 ;)



--
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