Re: [PATCH] bitops: simplify generic bit finding functions

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Thomas Gleixner
Date: Monday, April 28, 2008 - 7:04 am

On Sun, 27 Apr 2008, Linus Torvalds wrote:

The delta between the inlined version including the constant
optimizations and the original non inlined version is exactly 1400
bytes on a sparc64 defconfig build.


Which makes the whole constant optimization moot.

How about making the optimization controlled by a config switch so
arch maintainers can decide whether they want to enable the constant
optimization or unconditionally call the lib function ?

See patch below. It gives back the 1400 bytes on SPARC64 and other
platforms that have no instruction for find bit.

Thanks,
	tglx

---------->

Subject: bitops: optional bitops mapsize optimization on config switch
From: Thomas Gleixner <tglx@linutronix.de>
Date: Mon, 28 Apr 2008 00:22:06 +0200

The mapsize optimizations which were moved from x86 to the generic
code in commit 64970b68d2b3ed32b964b0b30b1b98518fde388e increased the
binary size on non x86 architectures.

Make the optimization depend on a config switch so architecture
maintainers can decide.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ingo Molnar <mingo@elte.hu>

---
 arch/x86/Kconfig.cpu   |    1 +
 include/linux/bitops.h |    6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

Index: linux-2.6/arch/x86/Kconfig.cpu
===================================================================
--- linux-2.6.orig/arch/x86/Kconfig.cpu
+++ linux-2.6/arch/x86/Kconfig.cpu
@@ -282,6 +282,7 @@ config X86_CPU
 	def_bool y
 	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_FIND_NEXT_BIT
+	select GENERIC_FIND_BIT_MAPSIZE_OPTIMIZE
 
 config X86_GENERIC
 	bool "Generic x86 support"
Index: linux-2.6/include/linux/bitops.h
===================================================================
--- linux-2.6.orig/include/linux/bitops.h
+++ linux-2.6/include/linux/bitops.h
@@ -190,6 +190,7 @@ static __always_inline unsigned long
 find_next_bit(const unsigned long *addr, unsigned long size,
 		unsigned long offset)
 {
+#ifdef CONFIG_GENERIC_FIND_BIT_MAPSIZE_OPTIMIZE
 	unsigned long value;
 
 	/* Avoid a function call if the bitmap size is a constant */
@@ -209,7 +210,7 @@ find_next_bit(const unsigned long *addr,
 		value = (*addr) & ((~0ul) << offset);
 		return (value == 0) ? BITS_PER_LONG : __ffs(value);
 	}
-
+#endif
 	/* size is not constant or too big */
 	return __find_next_bit(addr, size, offset);
 }
@@ -227,6 +228,7 @@ static __always_inline unsigned long
 find_next_zero_bit(const unsigned long *addr, unsigned long size,
 		unsigned long offset)
 {
+#ifdef CONFIG_GENERIC_FIND_BIT_MAPSIZE_OPTIMIZE
 	unsigned long value;
 
 	/* Avoid a function call if the bitmap size is a constant */
@@ -246,7 +248,7 @@ find_next_zero_bit(const unsigned long *
 		value = (~(*addr)) & ((~0ul) << offset);
 		return (value == 0) ? BITS_PER_LONG : __ffs(value);
 	}
-
+#endif
 	/* size is not constant or too big */
 	return __find_next_zero_bit(addr, size, offset);
 }
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] bitops: simplify generic bit finding functions, Harvey Harrison, (Sun Apr 27, 1:19 pm)
Re: [PATCH] bitops: simplify generic bit finding functions, Linus Torvalds, (Sun Apr 27, 1:26 pm)
Re: [PATCH] bitops: simplify generic bit finding functions, Harvey Harrison, (Sun Apr 27, 1:29 pm)
Re: [PATCH] bitops: simplify generic bit finding functions, Harvey Harrison, (Sun Apr 27, 1:38 pm)
Re: [PATCH] bitops: simplify generic bit finding functions, Linus Torvalds, (Sun Apr 27, 1:38 pm)
Re: [PATCH] bitops: simplify generic bit finding functions, Thomas Gleixner, (Mon Apr 28, 7:04 am)
Re: [PATCH] bitops: simplify generic bit finding functions, Alexander van Heukelum, (Mon Apr 28, 7:32 am)
Re: [PATCH] bitops: simplify generic bit finding functions, Alexander van Heukelum, (Mon Apr 28, 7:58 am)
Re: [PATCH] bitops: simplify generic bit finding functions, Alexander van Heukelum, (Mon Apr 28, 8:10 am)
Re: [PATCH] bitops: simplify generic bit finding functions, Thomas Gleixner, (Mon Apr 28, 8:58 am)
Re: [PATCH] bitops: simplify generic bit finding functions, Linus Torvalds, (Mon Apr 28, 9:25 am)
Re: [PATCH] bitops: simplify generic bit finding functions, Thomas Gleixner, (Mon Apr 28, 9:47 am)
Re: [PATCH] bitops: simplify generic bit finding functions, Linus Torvalds, (Mon Apr 28, 9:54 am)
Re: [PATCH] bitops: simplify generic bit finding functions, Thomas Gleixner, (Mon Apr 28, 12:26 pm)
Re: [PATCH] bitops: simplify generic bit finding functions, Linus Torvalds, (Mon Apr 28, 12:37 pm)
[PATCH] bitops: remove &quot;optimizations&quot;, Thomas Gleixner, (Tue Apr 29, 3:01 am)
Re: [PATCH] bitops: remove &quot;optimizations&quot;, David Miller, (Tue Apr 29, 3:03 am)
Re: [PATCH] bitops: remove &quot;optimizations&quot;, David Miller, (Tue Apr 29, 5:34 am)
Re: [PATCH] bitops: remove &quot;optimizations&quot;, Ingo Molnar, (Tue Apr 29, 7:20 am)
Re: [PATCH] bitops: remove &quot;optimizations&quot;, Thomas Gleixner, (Tue Apr 29, 9:51 am)
Re: [PATCH] bitops: remove &quot;optimizations&quot;, David Miller, (Tue Apr 29, 3:31 pm)
Re: [PATCH] bitops: remove &quot;optimizations&quot;, David Miller, (Tue Apr 29, 3:58 pm)
Re: [PATCH] bitops: remove &quot;optimizations&quot;, David Miller, (Tue Apr 29, 4:30 pm)