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  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 30 Jun 2009 06:18:01 -0400 (EDT)
From:	"Robert P. J. Day" <rpjday@...shcourse.ca>
To:	Petr Tesarik <ptesarik@...e.cz>
cc:	Andrew Morton <akpm@...ux-foundation.org>,
	David Daney <ddaney@...iumnetworks.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] Introduce a boolean "single_bit_set" function.

On Tue, 30 Jun 2009, Petr Tesarik wrote:

> Robert P. J. Day píše v Po 29. 06. 2009 v 14:50 -0400:

> >   since i originally muttered about this, the rationale behind it
> > was not for performance (obviously), but for semantic
> > clarification, so that when you saw the expression "n & (n-1)", it
> > was more obvious which test you were doing semantically:
> >
> > 1) is n a power of 2?
> > 2) does n represent a single set bit?
> >
> > nothing ever came of that, but that was the thinking behind it.
>
> Yes, I can remember and I would still appreciate it. It's always
> better to show _what_ the code does rather than _how_ it does it.
>
> IIRC Andrew rejected your patch on the grounds that it is possible
> to replace the expression "n & (n-1)" with "hweight(n) == 1" if one
> wants to show that it really tests for a single bit set. But I don't
> like his proposal quite as much as yours, because of the big
> overhead.
>
> In short, if you re-post your patch, I'll gladly join you in the
> battle of getting it in. ;-)

  i never meant for this to turn into a pitched battle of
philosophies -- it just seemed like a simple way to make the code
clearer, particularly since some of the patches i've submitted allowed
for the removal of comments like "test that blocksize is a power of
2" given that what you're testing is now painfully obvious. :-)

  if someone has a quick, simple and performance non-crippling
suggestion for this, i'm all ears.  but there's no point thinking
about it if it's actually going to cause performance issues.

rday

p.s.  a simple grep to find potential cleanup of the form n&(n-1):

grep -Ern "([^\(\)]+) ?\& ?\(\1 ?- ?1\)" * | less

--

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

        Linux Consulting, Training and Annoying Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Linked In:                             http://www.linkedin.com/in/rpjday
Twitter:                                       http://twitter.com/rpjday
========================================================================

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ