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:	Mon, 12 Mar 2012 22:54:35 -0700 (PDT)
From:	David Miller <davem@...emloft.net>
To:	zenczykowski@...il.com
Cc:	maze@...gle.com, netdev@...r.kernel.org
Subject: Re: [PATCH] net: pfifo_fast - use ffs(x)-1 instead of array lookup

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