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:	Tue, 20 Dec 2011 21:50:32 -0800
From:	Joe Perches <joe@...ches.com>
To:	Michael Wang <wangyun@...ux.vnet.ibm.com>
Cc:	Stephen Hemminger <shemminger@...tta.com>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH] Avoid extra calculation in ip_route_input_common

On Wed, 2011-12-21 at 13:39 +0800, Michael Wang wrote:
> On 12/21/2011 01:23 PM, Joe Perches wrote:
> > On Wed, 2011-12-21 at 13:12 +0800, Michael Wang wrote:
> >> From: Michael Wang <wangyun@...ux.vnet.ibm.com>
> >>
> >> If previous condition doesn't meet, the later check will be cancelled.
> >> So we don't need to do all the calculation.
[]
> > commit c0b8c32b1c96afc9b32b717927330025cc1c501e
> > Author: Stephen Hemminger <shemminger@...tta.com>
> > Date:   Thu Apr 10 04:00:28 2008 -0700
> > 
> >     IPV4: use xor rather than multiple ands for route compare
> >     
> >     The comparison in ip_route_input is a hot path, by recoding the C
> >     "and" as bit operations, fewer conditional branches get generated
> >     so the code should be faster. Maybe someday Gcc will be smart
> >     enough to do this?
> This is what confused me, why "fewer conditional branches get generated"
> will make code faster?
> In this example, I think the best condition when daddr is different, we
> only need to go to one branch do compare then quit, won't this be faster?

	if (a && b)
		...
pseudo-codes to:
	if (!a)
		goto fail;
	if (!b)
		goto fail;
	...
fail:

Each of those conditional branches has a cost.
Combining tests of variables in the same cache lines
has relatively little cost compared to the conditional
branches.

That's the theory anyway.

If you have tests that demonstrate otherwise, please
provide them.

cheers, Joe

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