remove powerpc bitops infavor of existing generic bitops
Subsystems (2)
PATCH 1/1 remove powerpc bitops infavor of existing generic bitops
There already exists a big endian safe bitops implementation in lib/find_next_bit.c. The code in it is 90%+ common with the powerpc specific version, so the powerpc version is redundant. This patch makes the necessary changes to use the generic bitops in powerpc, and removes the powerpc specific version.
Thanks,
Jon
arch/powerpc/Kconfig +4 -0
@@ -42,6 +42,10 @@ config GENERIC_HWEIGHT default y config GENERIC_CALIBRATE_DELAY + bool + default y + +config GENERIC_FIND_NEXT_BIT bool default y
arch/powerpc/lib/Makefile +0 -1
@@ -7,7 +7,6 @@ obj-$(CONFIG_PPC32) += div64.o copy_32.o obj-$(CONFIG_PPC32) += div64.o copy_32.o checksum_32.o endif -obj-y += bitops.o obj-$(CONFIG_PPC64) += checksum_64.o copypage_64.o copyuser_64.o \ memcpy_64.o usercopy_64.o mem_64.o string.o \ strcase.o
include/asm-powerpc/bitops.h +3 -3
@@ -288,8 +288,8 @@ static __inline__ int test_le_bit(unsign#define __test_and_clear_le_bit (nr, addr) \ __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) -#define find_first_zero_le_bit (addr, size) find_next_zero_le_bit((addr), (size), 0) -unsigned long find_next_zero_le_bit (const unsigned long *addr, +#define find_first_zero_le_bit (addr, size) generic_find_next_zero_le_bit((addr), (size), 0) +unsigned long generic_find_next_zero_le_bit (const unsigned long *addr,unsigned long size,unsigned long offset);/* Bitmap functions for the ext2 filesystem */
@@ -309,7 +309,7 @@ unsigned long find_next_zero_le_bit(cons#define ext2_find_first_zero_bit (addr, size) \ find_first_zero_le_bit((unsigned long*)addr, size)#define ext2_find_next_zero_bit (addr, size, off) \ - find_next_zero_le_bit((unsigned long*)addr, size, off) + generic_find_next_zero_le_bit((unsigned long*)addr, size, off)/* Bitmap functions for the minix filesystem. */
arch/powerpc/lib/bitops.c deleted +0 -150
150 lines not on this page · raw message
Quoted 5 lines
There already exists a big endian safe bitops implementation in
lib/find_next_bit.c. The code in it is 90%+ common with the powerpc specific version, so the powerpc version is redundant. This patch makes the necessary changes to use the generic bitops in powerpc, and removes the powerpc specific version.
I like generic as much as the next guy, but I'm also a big fan of fast bitops. And the function below is fast. You'll have to explain to me how the generic code is going to find the first zero as fast without explicit calls to ppc assembly.
Quoted 7 lines
arch/powerpc/lib/bitops.c deleted +0
-7-static inline unsigned int ext2_ilog2 (unsigned int x) -{ -int lz; - - asm("cntlzw %0,%1" :"=r" (lz):"r" (x)); -return 31 - lz; -}
Quoted 11 lines · jschopp
Quoted 5 lines
There already exists a big endian safe bitops implementation in
lib/find_next_bit.c. The code in it is 90%+ common with the powerpc specific version, so the powerpc version is redundant. This patch makes the necessary changes to use the generic bitops in powerpc, and removes the powerpc specific version.I like generic as much as the next guy, but I'm also a big fan of fast bitops. And the function below is fast. You'll have to explain to me how the generic code is going to find the first zero as fast without explicit calls to ppc assembly.
Quoted 7 lines
arch/powerpc/lib/bitops.c line 102
Quoted 7 lines
arch/powerpc/lib/bitops.c deleted +0
-7-static inline unsigned int ext2_ilog2 (unsigned int x) -{ -int lz; - - asm("cntlzw %0,%1" :"=r" (lz):"r" (x)); -return 31 - lz; -}
Ah but here's the trick, there is the same explicit call to ppc assembly. The only function in the file removed is this one you pointed out, and the only caller of this function is ext2_ffz. And the only user of ext2_ffz is find_next_zero_le_bit.
Now the generic code is very similar to the file removed (diff -Narup arch/powerpc/lib/bitops.c lib/find_next_bit.c to see for yourself). In the same place where ext2_ffz is called, ffz is called in the generic code. Now if we look at the definition of ffz in include/asm-powerpc/bitops.h, we see it calls __ilog2 of that same file. __ilog2 is defined as:
static __inline__ int __ilog2(unsigned long x)
{
int lz;
asm (PPC_CNTLZL "%0,%1" : "=r" (lz) : "r" (x));
return BITS_PER_LONG - 1 - lz;
}So, its really the same code :)
Thanks,
Jon
jschopp
Acked-byQuoted 13 lines
Ah but here's the trick, there is the same explicit call to ppc assembly. The only function in the file removed is this one you pointed out, and the only caller of this function is
ext2_ffz. And the only user ofext2_ffzisfind_next_zero_le_bit.Now the generic code is very similar to the file removed (
diff -Narup arch/powerpc/lib/bitops.c lib/find_next_bit.cto see for yourself). In the same place whereext2_ffzis called, ffz is called in the generic code. Now if we look at the definition of ffz ininclude/asm-powerpc/bitops.h, we see it calls__ilog2of that same file.__ilog2is defined as:static
__inline__int__ilog2(unsigned long x)
Quoted 8 lines
{ int lz; asm (PPC_CNTLZL "%0,%1" : "=r" (lz) : "r" (x)); return BITS_PER_LONG - 1 - lz; }So, its really the same code :)
Good explination. I'm convinced, so for what it's worth:
Quoted 5 lines · Jon Mason
There already exists a big endian safe bitops implementation in
lib/find_next_bit.c. The code in it is 90%+ common with the powerpc specific version, so the powerpc version is redundant. This patch makes the necessary changes to use the generic bitops in powerpc, and removes the powerpc specific version.
This patch breaks ARCH=ppc builds. Please resubmit with the necessary changes to arch/ppc/Kconfig as well.
Paul.
Quoted 8 lines · Paul Mackerras
Quoted 5 lines · Jon Mason
There already exists a big endian safe bitops implementation in
lib/find_next_bit.c. The code in it is 90%+ common with the powerpc specific version, so the powerpc version is redundant. This patch makes the necessary changes to use the generic bitops in powerpc, and removes the powerpc specific version.
Quoted 4 lines
This patch breaks ARCH=ppc builds. Please resubmit with the necessary changes to
arch/ppc/Kconfigas well.Paul.
Sorry. Here is the patch with the necessary correction.
Thanks,
Jon
arch/powerpc/Kconfig +4 -0
@@ -42,6 +42,10 @@ config GENERIC_HWEIGHT default y config GENERIC_CALIBRATE_DELAY + bool + default y + +config GENERIC_FIND_NEXT_BIT bool default y
arch/powerpc/lib/Makefile +0 -1
@@ -7,7 +7,6 @@ obj-$(CONFIG_PPC32) += div64.o copy_32.o obj-$(CONFIG_PPC32) += div64.o copy_32.o checksum_32.o endif -obj-y += bitops.o obj-$(CONFIG_PPC64) += checksum_64.o copypage_64.o copyuser_64.o \ memcpy_64.o usercopy_64.o mem_64.o string.o \ strcase.o
arch/ppc/Kconfig +4 -0
@@ -37,6 +37,10 @@ config PPC32 # All PPCs use generic nvram driver through ppc_md config GENERIC_NVRAM + bool + default y + +config GENERIC_FIND_NEXT_BIT bool default y
include/asm-powerpc/bitops.h +3 -3
@@ -288,8 +288,8 @@ static __inline__ int test_le_bit(unsign#define __test_and_clear_le_bit (nr, addr) \ __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) -#define find_first_zero_le_bit (addr, size) find_next_zero_le_bit((addr), (size), 0) -unsigned long find_next_zero_le_bit (const unsigned long *addr, +#define find_first_zero_le_bit (addr, size) generic_find_next_zero_le_bit((addr), (size), 0) +unsigned long generic_find_next_zero_le_bit (const unsigned long *addr,unsigned long size,unsigned long offset);/* Bitmap functions for the ext2 filesystem */
@@ -309,7 +309,7 @@ unsigned long find_next_zero_le_bit(cons#define ext2_find_first_zero_bit (addr, size) \ find_first_zero_le_bit((unsigned long*)addr, size)#define ext2_find_next_zero_bit (addr, size, off) \ - find_next_zero_le_bit((unsigned long*)addr, size, off) + generic_find_next_zero_le_bit((unsigned long*)addr, size, off)/* Bitmap functions for the minix filesystem. */
arch/powerpc/lib/bitops.c deleted +0 -150
150 lines not on this page · raw message