Skip to contentSkip to conversation

little-endian bitops bugfixes

PATCH New Akinobu Mita 1 participant 3 messages Nov 26, 2010

Subsystems (10)
PowerPC Library code MIPS SuperH +6 more subsystems
lore
Share & tools
lore
#0 lore raw

cover little-endian bitops bugfixes

The little-endian bitops patch series has been added to the -mm tree recently. I found two problems so far.

Akinobu Mita (2):
bitops: use find_first_zero_bit() instead of find_next_zero_bit(addr,

    size, 0)

bitops: introduce CONFIG_GENERIC_FIND_LE_BIT

 arch/frv/Kconfig                |    4 ++++
 arch/h8300/Kconfig              |    4 ++++
 arch/m32r/Kconfig               |    4 ++++
 arch/microblaze/Kconfig         |    3 +++
 arch/mips/Kconfig               |    4 ++++
 arch/parisc/Kconfig             |    4 ++++
 arch/powerpc/Kconfig            |    4 ++++
 arch/sh/Kconfig                 |    3 +++
 arch/sparc/Kconfig              |    4 ++++
 arch/xtensa/Kconfig             |    3 +++
 include/asm-generic/bitops/le.h |    8 +++++---
 lib/Kconfig                     |    3 +++
 lib/Makefile                    |    1 +
 lib/find_next_bit.c             |    3 +++
 14 files changed, 49 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.3.2
#1 lore raw

PATCH 1/2 bitops: use find_first_zero_bit() instead of find_next_zero_bit(addr, size, 0)

The little-endian bitops patch series introduced inefficiency to some little-endian architectures.

include/asm-generic/bitops/le.h defines find_first_zero_le_bit() like this:

	#define find_first_zero_le_bit(addr, size) \
		find_next_zero_le_bit((addr), (size), 0)

All little-endian architectures include le.h and little-endian bitops are just aliases for their native endian bitops. So above macro definision is converted to:

	#define find_first_zero_le_bit(addr, size) \
		find_next_zero_bit(addr, size, 0)

This is inefficient for some architectures which have faster find_first_zero_bit() than find_next_zero_bit(addr, size, 0).

Fix it by aliasing find_first_zero_bit() to find_first_zero_le_bit() on little-endian architectures.

---
 include/asm-generic/bitops/le.h |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
include/asm-generic/bitops/le.h +5 -3
index 6ad46ce..17a7119 100644
@@ -12,6 +12,8 @@
 	find_next_zero_bit(addr, size, offset)
 #define find_next_le_bit(addr, size, offset) \
 	find_next_bit(addr, size, offset)
+#define find_first_zero_le_bit(addr, size) \
+	find_first_zero_bit(addr, size)
 
 #elif defined(__BIG_ENDIAN)
 
@@ -22,6 +24,9 @@ extern unsigned long find_next_zero_le_bit(const unsigned long *addr,
 extern unsigned long find_next_le_bit(const unsigned long *addr,
 		unsigned long size, unsigned long offset);
 
+#define find_first_zero_le_bit(addr, size) \
+	find_next_zero_le_bit((addr), (size), 0)
+
 #else
 #error "Please fix <asm/byteorder.h>"
 #endif
@@ -43,7 +48,4 @@ extern unsigned long find_next_le_bit(const unsigned long *addr,
 #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)
-
 #endif /* _ASM_GENERIC_BITOPS_LE_H_ */
Signature · 1 line
1.7.3.2
#2 lore raw

PATCH 2/2 bitops: introduce CONFIG_GENERIC_FIND_LE_BIT

In reply to Akinobu Mita

The little-endian bitops patch series broke the build on m68knommu.

lib/find_next_bit.c:190: error: conflicting types for 'find_next_zero_le_bit' /home/mita/scm/linux-2.6/arch/m68k/include/asm/bitops_no.h:286: error: previous definition of 'find_next_zero_le_bit' was here

Because m68knommu selects CONFIG_GENERIC_FIND_NEXT_BIT, it redefines find_next_zero_le_bit() in lib/find_next_bit.c.

This introduces CONFIG_GENERIC_FIND_NEXT_BIT to tell whether to use generic implementation of find_*_le_bit() in lib/find_next_bit.c or not. It will not be selected by m68knommu to fix build failure.

Cc Greg Ungerer <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
 arch/frv/Kconfig        |    4 ++++
 arch/h8300/Kconfig      |    4 ++++
 arch/m32r/Kconfig       |    4 ++++
 arch/microblaze/Kconfig |    3 +++
 arch/mips/Kconfig       |    4 ++++
 arch/parisc/Kconfig     |    4 ++++
 arch/powerpc/Kconfig    |    4 ++++
 arch/sh/Kconfig         |    3 +++
 arch/sparc/Kconfig      |    4 ++++
 arch/xtensa/Kconfig     |    3 +++
 lib/Kconfig             |    3 +++
 lib/Makefile            |    1 +
 lib/find_next_bit.c     |    3 +++
 13 files changed, 44 insertions(+), 0 deletions(-)
arch/frv/Kconfig +4 -0
index f6bcb03..77deacd 100644
@@ -21,6 +21,10 @@ config GENERIC_FIND_NEXT_BIT
 	bool
 	default y
 
+config GENERIC_FIND_LE_BIT
+	bool
+	default y
+
 config GENERIC_HWEIGHT
 	bool
 	default y
arch/h8300/Kconfig +4 -0
index 65f897d8..02de073 100644
@@ -43,6 +43,10 @@ config GENERIC_FIND_NEXT_BIT
 	bool
 	default y
 
+config GENERIC_FIND_LE_BIT
+	bool
+	default y
+
 config GENERIC_HWEIGHT
 	bool
 	default y
arch/m32r/Kconfig +4 -0
index 5c291d6..df2e01a 100644
@@ -265,6 +265,10 @@ config GENERIC_FIND_NEXT_BIT
 	bool
 	default y
 
+config GENERIC_FIND_LE_BIT
+	bool
+	default y
+
 config GENERIC_HWEIGHT
 	bool
 	default y
arch/microblaze/Kconfig +3 -0
index 387d5ff..5f29d63 100644
@@ -34,6 +34,9 @@ config ARCH_HAS_ILOG2_U64
 config GENERIC_FIND_NEXT_BIT
 	def_bool y
 
+config GENERIC_FIND_LE_BIT
+	def_bool y
+
 config GENERIC_HWEIGHT
 	def_bool y
 
arch/mips/Kconfig +4 -0
index 67a2fa2..0ca01a2 100644
@@ -753,6 +753,10 @@ config GENERIC_FIND_NEXT_BIT
 	bool
 	default y
 
+config GENERIC_FIND_LE_BIT
+	bool
+	default y
+
 config GENERIC_HWEIGHT
 	bool
 	default y
arch/parisc/Kconfig +4 -0
index 0888675..ca59250 100644
@@ -48,6 +48,10 @@ config GENERIC_FIND_NEXT_BIT
 	bool
 	default y
 
+config GENERIC_FIND_LE_BIT
+	bool
+	default y
+
 config GENERIC_BUG
 	bool
 	default y
arch/powerpc/Kconfig +4 -0
index e625e9e..ac44ad9 100644
@@ -104,6 +104,10 @@ config GENERIC_FIND_NEXT_BIT
 	bool
 	default y
 
+config GENERIC_FIND_LE_BIT
+	bool
+	default y
+
 config GENERIC_GPIO
 	bool
 	help
arch/sh/Kconfig +3 -0
index 7f217b3..0438776 100644
@@ -72,6 +72,9 @@ config GENERIC_CSUM
 config GENERIC_FIND_NEXT_BIT
 	def_bool y
 
+config GENERIC_FIND_LE_BIT
+	def_bool y
+
 config GENERIC_HWEIGHT
 	def_bool y
 
arch/sparc/Kconfig +4 -0
index 45d9c87..af40adf 100644
@@ -194,6 +194,10 @@ config GENERIC_FIND_NEXT_BIT
 	bool
 	default y
 
+config GENERIC_FIND_LE_BIT
+	bool
+	default y
+
 config GENERIC_HWEIGHT
 	bool
 	default y if !ULTRA_HAS_POPULATION_COUNT
arch/xtensa/Kconfig +3 -0
index d373d15..d20d434 100644
@@ -21,6 +21,9 @@ config RWSEM_XCHGADD_ALGORITHM
 config GENERIC_FIND_NEXT_BIT
 	def_bool y
 
+config GENERIC_FIND_LE_BIT
+	def_bool y
+
 config GENERIC_HWEIGHT
 	def_bool y
 
lib/Kconfig +3 -0
index fa9bf2c..2e5df8e 100644
@@ -22,6 +22,9 @@ config GENERIC_FIND_FIRST_BIT
 config GENERIC_FIND_NEXT_BIT
 	bool
 
+config GENERIC_FIND_LE_BIT
+	bool
+
 config GENERIC_FIND_LAST_BIT
 	bool
 	default y
lib/Makefile +1 -0
index e6a3763..a3265d6 100644
@@ -38,6 +38,7 @@ lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
 lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
 lib-$(CONFIG_GENERIC_FIND_FIRST_BIT) += find_next_bit.o
 lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o
+lib-$(CONFIG_GENERIC_FIND_LE_BIT) += find_next_bit.o
 obj-$(CONFIG_GENERIC_FIND_LAST_BIT) += find_last_bit.o
 
 CFLAGS_hweight.o = $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
lib/find_next_bit.c +3 -0
index eb8934b..b7047d1 100644
@@ -160,6 +160,7 @@ EXPORT_SYMBOL(find_first_zero_bit);
 #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
 
 #ifdef __BIG_ENDIAN
+#ifdef CONFIG_GENERIC_FIND_LE_BIT
 
 /* include/linux/byteorder does not support "unsigned long" type */
 static inline unsigned long ext2_swabp(const unsigned long * x)
@@ -271,4 +272,6 @@ found_middle_swap:
 	return result + __ffs(ext2_swab(tmp));
 }
 EXPORT_SYMBOL(find_next_le_bit);
+
+#endif /* CONFIG_GENERIC_FIND_LE_BIT */
 #endif /* __BIG_ENDIAN */
Signature · 1 line
1.7.3.2