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, 13 Mar 2012 00:21:55 -0700
From:	Maciej Żenczykowski <zenczykowski@...il.com>
To:	David Miller <davem@...emloft.net>
Cc:	netdev@...r.kernel.org
Subject: Re: [PATCH] net: pfifo_fast - use ffs(x)-1 instead of array lookup

If I understand correctly, you're suggesting to go with

return ((26468 >> (i+i)) & 3) - 1;

correct?

2012/3/12 David Miller <davem@...emloft.net>:
> From: Maciej Żenczykowski <zenczykowski@...il.com>
> Date: Mon, 12 Mar 2012 22:12:21 -0700
>
>> From: Maciej Żenczykowski <maze@...gle.com>
>>
>> See ffs(x) definition in arch/x86/include/asm/bitops.h
>>
>>   ffs - find first set bit in word
>>
>>   ffs(value) returns 0 if value is 0 or the position of the first
>>   set bit if value is nonzero. The first (least significant) bit
>>   is at position 1.
>>
>> On x86_64 ffs(x) is effectively:
>>   Z := -1
>>   BSFL X, Z
>>   return Z + 1
>>
>> Since we subtract one, we effectively end up with:
>>   Z := -1
>>   BSFL X, Z
>>   return Z
>>
>> This is certainly more readable than the open coded array that
>> was there before, supports an easier change in the number of bands,
>> and is probably faster to boot (no memory lookup).
>>
>> However, on other architectures ffs() might not be so pretty,
>> hence use a clever arithmetic hack on other archs.
>> Unfortunately it only support 3 bands.
>>
>> Signed-off-by: Maciej Żenczykowski <maze@...gle.com>
>
> It's about the same cost, the non-ffs() version, so I would just
> use that for now.  Conditionalized code is such a pain in the butt.
>
--
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