|
|
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@xxxxxxxxxxxxx>: > From: Maciej Żenczykowski <zenczykowski@xxxxxxxxx> > Date: Mon, 12 Mar 2012 22:12:21 -0700 > >> From: Maciej Żenczykowski <maze@xxxxxxxxxx> >> >> 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@xxxxxxxxxx> > > 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@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
[Linux Kernel Discussion] [Ethernet Bridging] [Linux Wireless Networking] [Linux Bluetooth Networking] [Linux Networking Users] [VLAN] [Git] [IETF Annouce] [Linux Assembly] [Security] [Bugtraq] [Photo] [Singles Social Networking] [Yosemite Information] [MIPS Linux] [ARM Linux Kernel] [ARM Linux] [Linux Virtualization] [Linux Security] [Linux IDE] [Linux RAID] [Linux SCSI] [Free Dating]
![]() |
![]() |