Skip to contentSkip to conversation

all: remove GENERIC_FIND_FIRST_BIT

PATCH In review Yury Norov 5 participants 6 messages May 10, 2021 – Jun 9, 2021

Subsystems (9)
x86 Library code MIPS arm64 +5 more subsystems
lore
Share & tools
lore

Yury Norov

author maintainer
#0 lore raw

PATCH 1/1 all: remove GENERIC_FIND_FIRST_BIT

In the 5.12 cycle we enabled the GENERIC_FIND_FIRST_BIT config option for ARM64 and MIPS. It increased performance and shrunk .text size; and so far I didn't receive any negative feedback on the change.

https://lore.kernel.org/linux-arch/[email protected]/

I think it's time to make all architectures use find_{first,last}_bit() unconditionally and remove the corresponding config option.

This patch doesn't introduce functional changes for arc, arm64, mips, s390 and x86 because they already enable GENERIC_FIND_FIRST_BIT. There will be no changes for arm because it implements find_{first,last}_bit in arch code. For other architectures I expect improvement both in performance and .text size.

It would be great if people with an access to real hardware would share the output of bloat-o-meter and lib/find_bit_benchmark.

---
 arch/arc/Kconfig                  |  1 -
 arch/arm64/Kconfig                |  1 -
 arch/mips/Kconfig                 |  1 -
 arch/s390/Kconfig                 |  1 -
 arch/x86/Kconfig                  |  1 -
 arch/x86/um/Kconfig               |  1 -
 include/asm-generic/bitops/find.h | 12 ------------
 lib/Kconfig                       |  3 ---
 8 files changed, 21 deletions(-)
arch/arc/Kconfig +0 -1
index bc8d6aecfbbd..9c991ba50db3 100644
@@ -19,7 +19,6 @@ config ARC
 	select COMMON_CLK
 	select DMA_DIRECT_REMAP
 	select GENERIC_ATOMIC64 if !ISA_ARCV2 || !(ARC_HAS_LL64 && ARC_HAS_LLSC)
-	select GENERIC_FIND_FIRST_BIT
 	# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
arch/arm64/Kconfig +0 -1
index e09a9591af45..9d5b36f7d981 100644
@@ -108,7 +108,6 @@ config ARM64
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_EARLY_IOREMAP
-	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_IDLE_POLL_SETUP
 	select GENERIC_IRQ_IPI
 	select GENERIC_IRQ_PROBE
arch/mips/Kconfig +0 -1
index b72458215d20..3ddae7918386 100644
@@ -27,7 +27,6 @@ config MIPS
 	select GENERIC_ATOMIC64 if !64BIT
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CPU_AUTOPROBE
-	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_PROBE
arch/s390/Kconfig +0 -1
index c1ff874e6c2e..3a10ceb8a097 100644
@@ -125,7 +125,6 @@ config S390
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_ENTRY
-	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_PTDUMP
 	select GENERIC_SMP_IDLE_THREAD
arch/x86/Kconfig +0 -1
index b83364a15d34..6a7d8305365e 100644
@@ -123,7 +123,6 @@ config X86
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_EARLY_IOREMAP
 	select GENERIC_ENTRY
-	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_EFFECTIVE_AFF_MASK	if SMP
 	select GENERIC_IRQ_MATRIX_ALLOCATOR	if X86_LOCAL_APIC
arch/x86/um/Kconfig +0 -1
index 95d26a69088b..40d6a06e41c8 100644
@@ -8,7 +8,6 @@ endmenu
 
 config UML_X86
 	def_bool y
-	select GENERIC_FIND_FIRST_BIT
 
 config 64BIT
 	bool "64-bit kernel" if "$(SUBARCH)" = "x86"
include/asm-generic/bitops/find.h +0 -12
index 0d132ee2a291..8a7b70c79e15 100644
@@ -95,8 +95,6 @@ unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
 }
 #endif
 
-#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
-
 /**
  * find_first_bit - find the first set bit in a memory region
  * @addr: The address to start the search at
@@ -136,16 +134,6 @@ unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
 
 	return _find_first_zero_bit(addr, size);
 }
-#else /* CONFIG_GENERIC_FIND_FIRST_BIT */
-
-#ifndef find_first_bit
-#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
-#endif
-#ifndef find_first_zero_bit
-#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
-#endif
-
-#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
 
 #ifndef find_last_bit
 /**
lib/Kconfig +0 -3
index a38cc61256f1..8346b3181214 100644
@@ -59,9 +59,6 @@ config GENERIC_STRNLEN_USER
 config GENERIC_NET_UTILS
 	bool
 
-config GENERIC_FIND_FIRST_BIT
-	bool
-
 source "lib/math/Kconfig"
 
 config NO_GENERIC_PCI_IOPORT_MAP
Signature · 1 line
2.25.1
#1 lore raw
I love your patch! Yet something to improve:

Hi Yury,

I love your patch! Yet something to improve:

[auto build test ERROR on linux/master]
[also build test ERROR on s390/features linus/master v5.13-rc1 next-20210510] [cannot apply to arm64/for-next/core tip/x86/core uml/linux-next arc/for-next asm-generic/master] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Yury-Norov/all-remove-GENERIC_FIND_FIRST_BIT/20210511-073448
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git dd860052c99b1e088352bdd4fb7aef46f8d2ef47
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/843a54481be51456235f7c2cd87e1b20f60ba6a2
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yury-Norov/all-remove-GENERIC_FIND_FIRST_BIT/20210511-073448 git checkout 843a54481be51456235f7c2cd87e1b20f60ba6a2
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=m68k

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from include/linux/bitops.h:32,

                    from include/linux/kernel.h:12,
                    from include/asm-generic/bug.h:20,
                    from arch/m68k/include/asm/bug.h:32,
                    from include/linux/bug.h:5,
                    from include/linux/page-flags.h:10,
                    from kernel/bounds.c:10:
>> arch/m68k/include/asm/bitops.h:396:24: error: conflicting types for 'find_first_bit'
     396 | #define find_first_bit find_first_bit
         |                        ^~~~~~~~~~~~~~
   include/asm-generic/bitops/find.h:107:15: note: in expansion of macro 'find_first_bit'
     107 | unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
         |               ^~~~~~~~~~~~~~
   arch/m68k/include/asm/bitops.h:373:19: note: previous definition of 'find_first_bit' was here
     373 | static inline int find_first_bit(const unsigned long *vaddr, unsigned size)
         |                   ^~~~~~~~~~~~~~
>> arch/m68k/include/asm/bitops.h:341:29: error: conflicting types for 'find_first_zero_bit'

341 | #define find_first_zero_bit find_first_zero_bit
| ^~~~~~~~~~~~~~~~~~~
include/asm-generic/bitops/find.h:127:15: note: in expansion of macro 'find_first_zero_bit'
127 | unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
| ^~~~~~~~~~~~~~~~~~~
arch/m68k/include/asm/bitops.h:317:19: note: previous definition of 'find_first_zero_bit' was here
317 | static inline int find_first_zero_bit(const unsigned long *vaddr,
| ^~~~~~~~~~~~~~~~~~~
--
In file included from include/linux/bitops.h:32,
from include/linux/kernel.h:12,
from kernel//locking/locktorture.c:14:

>> arch/m68k/include/asm/bitops.h:396:24: error: conflicting types for 'find_first_bit'
     396 | #define find_first_bit find_first_bit
         |                        ^~~~~~~~~~~~~~
   include/asm-generic/bitops/find.h:107:15: note: in expansion of macro 'find_first_bit'
     107 | unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
         |               ^~~~~~~~~~~~~~
   arch/m68k/include/asm/bitops.h:373:19: note: previous definition of 'find_first_bit' was here
     373 | static inline int find_first_bit(const unsigned long *vaddr, unsigned size)
         |                   ^~~~~~~~~~~~~~
>> arch/m68k/include/asm/bitops.h:341:29: error: conflicting types for 'find_first_zero_bit'

341 | #define find_first_zero_bit find_first_zero_bit
| ^~~~~~~~~~~~~~~~~~~
include/asm-generic/bitops/find.h:127:15: note: in expansion of macro 'find_first_zero_bit'
127 | unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
| ^~~~~~~~~~~~~~~~~~~
arch/m68k/include/asm/bitops.h:317:19: note: previous definition of 'find_first_zero_bit' was here
317 | static inline int find_first_zero_bit(const unsigned long *vaddr,
| ^~~~~~~~~~~~~~~~~~~
In file included from include/linux/mmzone.h:19,
from include/linux/gfp.h:6,
from include/linux/umh.h:4,
from include/linux/kmod.h:9,
from include/linux/module.h:16,
from kernel//locking/locktorture.c:15:
include/linux/page-flags-layout.h:6:10: fatal error: generated/bounds.h: No such file or directory
6 | #include <generated/bounds.h>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
--
In file included from include/linux/bitops.h:32,

                    from include/linux/kernel.h:12,
                    from include/linux/list.h:9,
                    from include/linux/wait.h:7,
                    from include/linux/wait_bit.h:8,
                    from include/linux/fs.h:6,
                    from include/linux/debugfs.h:15,
                    from kernel//time/test_udelay.c:13:
>> arch/m68k/include/asm/bitops.h:396:24: error: conflicting types for 'find_first_bit'
     396 | #define find_first_bit find_first_bit
         |                        ^~~~~~~~~~~~~~
   include/asm-generic/bitops/find.h:107:15: note: in expansion of macro 'find_first_bit'
     107 | unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
         |               ^~~~~~~~~~~~~~
   arch/m68k/include/asm/bitops.h:373:19: note: previous definition of 'find_first_bit' was here
     373 | static inline int find_first_bit(const unsigned long *vaddr, unsigned size)
         |                   ^~~~~~~~~~~~~~
>> arch/m68k/include/asm/bitops.h:341:29: error: conflicting types for 'find_first_zero_bit'
     341 | #define find_first_zero_bit find_first_zero_bit
         |                             ^~~~~~~~~~~~~~~~~~~
   include/asm-generic/bitops/find.h:127:15: note: in expansion of macro 'find_first_zero_bit'
     127 | unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
         |               ^~~~~~~~~~~~~~~~~~~
   arch/m68k/include/asm/bitops.h:317:19: note: previous definition of 'find_first_zero_bit' was here
     317 | static inline int find_first_zero_bit(const unsigned long *vaddr,
         |                   ^~~~~~~~~~~~~~~~~~~
   In file included from include/linux/dcache.h:14,
                    from include/linux/fs.h:8,
                    from include/linux/debugfs.h:15,
                    from kernel//time/test_udelay.c:13:

include/linux/lockref.h:19:10: fatal error: generated/bounds.h: No such file or directory
19 | #include <generated/bounds.h>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
--
In file included from include/linux/bitops.h:32,

                    from include/linux/kernel.h:12,
                    from include/asm-generic/bug.h:20,
                    from arch/m68k/include/asm/bug.h:32,
                    from include/linux/bug.h:5,
                    from include/linux/page-flags.h:10,
                    from kernel/bounds.c:10:
>> arch/m68k/include/asm/bitops.h:396:24: error: conflicting types for 'find_first_bit'
     396 | #define find_first_bit find_first_bit
         |                        ^~~~~~~~~~~~~~
   include/asm-generic/bitops/find.h:107:15: note: in expansion of macro 'find_first_bit'
     107 | unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
         |               ^~~~~~~~~~~~~~
   arch/m68k/include/asm/bitops.h:373:19: note: previous definition of 'find_first_bit' was here
     373 | static inline int find_first_bit(const unsigned long *vaddr, unsigned size)
         |                   ^~~~~~~~~~~~~~
>> arch/m68k/include/asm/bitops.h:341:29: error: conflicting types for 'find_first_zero_bit'

341 | #define find_first_zero_bit find_first_zero_bit
| ^~~~~~~~~~~~~~~~~~~
include/asm-generic/bitops/find.h:127:15: note: in expansion of macro 'find_first_zero_bit'
127 | unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
| ^~~~~~~~~~~~~~~~~~~
arch/m68k/include/asm/bitops.h:317:19: note: previous definition of 'find_first_zero_bit' was here
317 | static inline int find_first_zero_bit(const unsigned long *vaddr,
| ^~~~~~~~~~~~~~~~~~~
make[2]: *** [scripts/Makefile.build:117: kernel/bounds.s] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1232: prepare0] Error 2
make[1]: Target 'modules_prepare' not remade because of errors.
make: *** [Makefile:215: __sub-make] Error 2
make: Target 'modules_prepare' not remade because of errors.
--
scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr] scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr]
In file included from include/linux/bitops.h:32,

                    from include/linux/kernel.h:12,
                    from include/asm-generic/bug.h:20,
                    from arch/m68k/include/asm/bug.h:32,
                    from include/linux/bug.h:5,
                    from include/linux/page-flags.h:10,
                    from kernel/bounds.c:10:
>> arch/m68k/include/asm/bitops.h:396:24: error: conflicting types for 'find_first_bit'
     396 | #define find_first_bit find_first_bit
         |                        ^~~~~~~~~~~~~~
   include/asm-generic/bitops/find.h:107:15: note: in expansion of macro 'find_first_bit'
     107 | unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
         |               ^~~~~~~~~~~~~~
   arch/m68k/include/asm/bitops.h:373:19: note: previous definition of 'find_first_bit' was here
     373 | static inline int find_first_bit(const unsigned long *vaddr, unsigned size)
         |                   ^~~~~~~~~~~~~~
>> arch/m68k/include/asm/bitops.h:341:29: error: conflicting types for 'find_first_zero_bit'

341 | #define find_first_zero_bit find_first_zero_bit
| ^~~~~~~~~~~~~~~~~~~
include/asm-generic/bitops/find.h:127:15: note: in expansion of macro 'find_first_zero_bit'
127 | unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
| ^~~~~~~~~~~~~~~~~~~
arch/m68k/include/asm/bitops.h:317:19: note: previous definition of 'find_first_zero_bit' was here
317 | static inline int find_first_zero_bit(const unsigned long *vaddr,
| ^~~~~~~~~~~~~~~~~~~
make[2]: *** [scripts/Makefile.build:117: kernel/bounds.s] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1232: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:215: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.

vim +/find_first_bit +396 arch/m68k/include/asm/bitops.h

171d809df1896c Greg Ungerer 2011-05-17  316  
171d809df1896c Greg Ungerer 2011-05-17  317  static inline int find_first_zero_bit(const unsigned long *vaddr,
171d809df1896c Greg Ungerer 2011-05-17  318  				      unsigned size)
171d809df1896c Greg Ungerer 2011-05-17  319  {
171d809df1896c Greg Ungerer 2011-05-17  320  	const unsigned long *p = vaddr;
171d809df1896c Greg Ungerer 2011-05-17  321  	int res = 32;
171d809df1896c Greg Ungerer 2011-05-17  322  	unsigned int words;
171d809df1896c Greg Ungerer 2011-05-17  323  	unsigned long num;
171d809df1896c Greg Ungerer 2011-05-17  324  
171d809df1896c Greg Ungerer 2011-05-17  325  	if (!size)
171d809df1896c Greg Ungerer 2011-05-17  326  		return 0;
171d809df1896c Greg Ungerer 2011-05-17  327  
171d809df1896c Greg Ungerer 2011-05-17  328  	words = (size + 31) >> 5;
171d809df1896c Greg Ungerer 2011-05-17  329  	while (!(num = ~*p++)) {
171d809df1896c Greg Ungerer 2011-05-17  330  		if (!--words)
171d809df1896c Greg Ungerer 2011-05-17  331  			goto out;
171d809df1896c Greg Ungerer 2011-05-17  332  	}
171d809df1896c Greg Ungerer 2011-05-17  333  
171d809df1896c Greg Ungerer 2011-05-17  334  	__asm__ __volatile__ ("bfffo %1{#0,#0},%0"
171d809df1896c Greg Ungerer 2011-05-17  335  			      : "=d" (res) : "d" (num & -num));
171d809df1896c Greg Ungerer 2011-05-17  336  	res ^= 31;
171d809df1896c Greg Ungerer 2011-05-17  337  out:
171d809df1896c Greg Ungerer 2011-05-17  338  	res += ((long)p - (long)vaddr - 4) * 8;
171d809df1896c Greg Ungerer 2011-05-17  339  	return res < size ? res : size;
171d809df1896c Greg Ungerer 2011-05-17  340  }
171d809df1896c Greg Ungerer 2011-05-17 @341  #define find_first_zero_bit find_first_zero_bit
171d809df1896c Greg Ungerer 2011-05-17  342  
171d809df1896c Greg Ungerer 2011-05-17  343  static inline int find_next_zero_bit(const unsigned long *vaddr, int size,
171d809df1896c Greg Ungerer 2011-05-17  344  				     int offset)
171d809df1896c Greg Ungerer 2011-05-17  345  {
171d809df1896c Greg Ungerer 2011-05-17  346  	const unsigned long *p = vaddr + (offset >> 5);
171d809df1896c Greg Ungerer 2011-05-17  347  	int bit = offset & 31UL, res;
171d809df1896c Greg Ungerer 2011-05-17  348  
171d809df1896c Greg Ungerer 2011-05-17  349  	if (offset >= size)
171d809df1896c Greg Ungerer 2011-05-17  350  		return size;
171d809df1896c Greg Ungerer 2011-05-17  351  
171d809df1896c Greg Ungerer 2011-05-17  352  	if (bit) {
171d809df1896c Greg Ungerer 2011-05-17  353  		unsigned long num = ~*p++ & (~0UL << bit);
171d809df1896c Greg Ungerer 2011-05-17  354  		offset -= bit;
171d809df1896c Greg Ungerer 2011-05-17  355  
171d809df1896c Greg Ungerer 2011-05-17  356  		/* Look for zero in first longword */
171d809df1896c Greg Ungerer 2011-05-17  357  		__asm__ __volatile__ ("bfffo %1{#0,#0},%0"
171d809df1896c Greg Ungerer 2011-05-17  358  				      : "=d" (res) : "d" (num & -num));
171d809df1896c Greg Ungerer 2011-05-17  359  		if (res < 32) {
171d809df1896c Greg Ungerer 2011-05-17  360  			offset += res ^ 31;
171d809df1896c Greg Ungerer 2011-05-17  361  			return offset < size ? offset : size;
171d809df1896c Greg Ungerer 2011-05-17  362  		}
171d809df1896c Greg Ungerer 2011-05-17  363  		offset += 32;
171d809df1896c Greg Ungerer 2011-05-17  364  
171d809df1896c Greg Ungerer 2011-05-17  365  		if (offset >= size)
171d809df1896c Greg Ungerer 2011-05-17  366  			return size;
171d809df1896c Greg Ungerer 2011-05-17  367  	}
171d809df1896c Greg Ungerer 2011-05-17  368  	/* No zero yet, search remaining full bytes for a zero */
171d809df1896c Greg Ungerer 2011-05-17  369  	return offset + find_first_zero_bit(p, size - offset);
171d809df1896c Greg Ungerer 2011-05-17  370  }
171d809df1896c Greg Ungerer 2011-05-17  371  #define find_next_zero_bit find_next_zero_bit
171d809df1896c Greg Ungerer 2011-05-17  372  
171d809df1896c Greg Ungerer 2011-05-17  373  static inline int find_first_bit(const unsigned long *vaddr, unsigned size)
171d809df1896c Greg Ungerer 2011-05-17  374  {
171d809df1896c Greg Ungerer 2011-05-17  375  	const unsigned long *p = vaddr;
171d809df1896c Greg Ungerer 2011-05-17  376  	int res = 32;
171d809df1896c Greg Ungerer 2011-05-17  377  	unsigned int words;
171d809df1896c Greg Ungerer 2011-05-17  378  	unsigned long num;
171d809df1896c Greg Ungerer 2011-05-17  379  
171d809df1896c Greg Ungerer 2011-05-17  380  	if (!size)
171d809df1896c Greg Ungerer 2011-05-17  381  		return 0;
171d809df1896c Greg Ungerer 2011-05-17  382  
171d809df1896c Greg Ungerer 2011-05-17  383  	words = (size + 31) >> 5;
171d809df1896c Greg Ungerer 2011-05-17  384  	while (!(num = *p++)) {
171d809df1896c Greg Ungerer 2011-05-17  385  		if (!--words)
171d809df1896c Greg Ungerer 2011-05-17  386  			goto out;
171d809df1896c Greg Ungerer 2011-05-17  387  	}
171d809df1896c Greg Ungerer 2011-05-17  388  
171d809df1896c Greg Ungerer 2011-05-17  389  	__asm__ __volatile__ ("bfffo %1{#0,#0},%0"
171d809df1896c Greg Ungerer 2011-05-17  390  			      : "=d" (res) : "d" (num & -num));
171d809df1896c Greg Ungerer 2011-05-17  391  	res ^= 31;
171d809df1896c Greg Ungerer 2011-05-17  392  out:
171d809df1896c Greg Ungerer 2011-05-17  393  	res += ((long)p - (long)vaddr - 4) * 8;
171d809df1896c Greg Ungerer 2011-05-17  394  	return res < size ? res : size;
171d809df1896c Greg Ungerer 2011-05-17  395  }

171d809df1896c Greg Ungerer 2011-05-17 @396 #define find_first_bit find_first_bit 171d809df1896c Greg Ungerer 2011-05-17 397

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Yury Norov

From: Yury Norov <[email protected]>
Date: Mon, 10 May 2021 16:34:21 -0700

Quoted 15 lines

In the 5.12 cycle we enabled the GENERIC_FIND_FIRST_BIT config option for ARM64 and MIPS. It increased performance and shrunk .text size; and so far I didn't receive any negative feedback on the change.

https://lore.kernel.org/linux-arch/[email protected]/

I think it's time to make all architectures use find_{first,last}_bit() unconditionally and remove the corresponding config option.

This patch doesn't introduce functional changes for arc, arm64, mips, s390 and x86 because they already enable GENERIC_FIND_FIRST_BIT. There will be no changes for arm because it implements find_{first,last}_bit in arch code. For other architectures I expect improvement both in performance and .text size.

Quoted 8 lines

It would be great if people with an access to real hardware would share the output of bloat-o-meter and lib/find_bit_benchmark.

---
 arch/arc/Kconfig                  |  1 -
 arch/arm64/Kconfig                |  1 -
 arch/mips/Kconfig                 |  1 -

MIPS bit:

Quoted 6 lines
 arch/s390/Kconfig                 |  1 -
 arch/x86/Kconfig                  |  1 -
 arch/x86/um/Kconfig               |  1 -
 include/asm-generic/bitops/find.h | 12 ------------
 lib/Kconfig                       |  3 ---
 8 files changed, 21 deletions(-)

Thanks,
Al

maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Yury Norov
Quoted 19 lines · Yury Norov

In the 5.12 cycle we enabled the GENERIC_FIND_FIRST_BIT config option for ARM64 and MIPS. It increased performance and shrunk .text size; and so far I didn't receive any negative feedback on the change.

https://lore.kernel.org/linux-arch/[email protected]/

I think it's time to make all architectures use find_{first,last}_bit() unconditionally and remove the corresponding config option.

This patch doesn't introduce functional changes for arc, arm64, mips, s390 and x86 because they already enable GENERIC_FIND_FIRST_BIT. There will be no changes for arm because it implements find_{first,last}_bit in arch code. For other architectures I expect improvement both in performance and .text size.

It would be great if people with an access to real hardware would share the output of bloat-o-meter and lib/find_bit_benchmark.

Quoted 10 lines
---
 arch/arc/Kconfig                  |  1 -
 arch/arm64/Kconfig                |  1 -
 arch/mips/Kconfig                 |  1 -
 arch/s390/Kconfig                 |  1 -
 arch/x86/Kconfig                  |  1 -
 arch/x86/um/Kconfig               |  1 -
 include/asm-generic/bitops/find.h | 12 ------------
 lib/Kconfig                       |  3 ---
 8 files changed, 21 deletions(-)

Will

Reviewed-by on v1 1/1
#4 lore raw
In reply to Yury Norov
Quoted 6 lines · Yury Norov

In the 5.12 cycle we enabled the GENERIC_FIND_FIRST_BIT config option for ARM64 and MIPS. It increased performance and shrunk .text size; and so far I didn't receive any negative feedback on the change.

https://lore.kernel.org/linux-arch/[email protected]/

Quoted 8 lines

I think it's time to make all architectures use find_{first,last}_bit() unconditionally and remove the corresponding config option.

This patch doesn't introduce functional changes for arc, arm64, mips, s390 and x86 because they already enable GENERIC_FIND_FIRST_BIT. There will be no changes for arm because it implements find_{first,last}_bit in arch code. For other architectures I expect improvement both in performance and .text size.

Subject like s/all:/arch:/.

Quoted 2 lines

It would be great if people with an access to real hardware would share the output of bloat-o-meter and lib/find_bit_benchmark.

This is rather comment (should be below cutter '---' line).

Anyway, seems good to my by the code:

Quoted 131 lines
---
 arch/arc/Kconfig                  |  1 -
 arch/arm64/Kconfig                |  1 -
 arch/mips/Kconfig                 |  1 -
 arch/s390/Kconfig                 |  1 -
 arch/x86/Kconfig                  |  1 -
 arch/x86/um/Kconfig               |  1 -
 include/asm-generic/bitops/find.h | 12 ------------
 lib/Kconfig                       |  3 ---
 8 files changed, 21 deletions(-)
arch/arc/Kconfig +0 -1
index bc8d6aecfbbd..9c991ba50db3 100644
@@ -19,7 +19,6 @@ config ARC
 	select COMMON_CLK
 	select DMA_DIRECT_REMAP
 	select GENERIC_ATOMIC64 if !ISA_ARCV2 || !(ARC_HAS_LL64 && ARC_HAS_LLSC)
-	select GENERIC_FIND_FIRST_BIT
 	# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
arch/arm64/Kconfig +0 -1
index e09a9591af45..9d5b36f7d981 100644
@@ -108,7 +108,6 @@ config ARM64
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_EARLY_IOREMAP
-	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_IDLE_POLL_SETUP
 	select GENERIC_IRQ_IPI
 	select GENERIC_IRQ_PROBE
arch/mips/Kconfig +0 -1
index b72458215d20..3ddae7918386 100644
@@ -27,7 +27,6 @@ config MIPS
 	select GENERIC_ATOMIC64 if !64BIT
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CPU_AUTOPROBE
-	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_PROBE
arch/s390/Kconfig +0 -1
index c1ff874e6c2e..3a10ceb8a097 100644
@@ -125,7 +125,6 @@ config S390
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_ENTRY
-	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_PTDUMP
 	select GENERIC_SMP_IDLE_THREAD
arch/x86/Kconfig +0 -1
index b83364a15d34..6a7d8305365e 100644
@@ -123,7 +123,6 @@ config X86
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_EARLY_IOREMAP
 	select GENERIC_ENTRY
-	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_EFFECTIVE_AFF_MASK	if SMP
 	select GENERIC_IRQ_MATRIX_ALLOCATOR	if X86_LOCAL_APIC
arch/x86/um/Kconfig +0 -1
index 95d26a69088b..40d6a06e41c8 100644
@@ -8,7 +8,6 @@ endmenu
 
 config UML_X86
 	def_bool y
-	select GENERIC_FIND_FIRST_BIT
 
 config 64BIT
 	bool "64-bit kernel" if "$(SUBARCH)" = "x86"
include/asm-generic/bitops/find.h +0 -12
index 0d132ee2a291..8a7b70c79e15 100644
@@ -95,8 +95,6 @@ unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
 }
 #endif
 
-#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
-
 /**
  * find_first_bit - find the first set bit in a memory region
  * @addr: The address to start the search at
@@ -136,16 +134,6 @@ unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
 
 	return _find_first_zero_bit(addr, size);
 }
-#else /* CONFIG_GENERIC_FIND_FIRST_BIT */
-
-#ifndef find_first_bit
-#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
-#endif
-#ifndef find_first_zero_bit
-#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
-#endif
-
-#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
 
 #ifndef find_last_bit
 /**
lib/Kconfig +0 -3
index a38cc61256f1..8346b3181214 100644
@@ -59,9 +59,6 @@ config GENERIC_STRNLEN_USER
 config GENERIC_NET_UTILS
 	bool
 
-config GENERIC_FIND_FIRST_BIT
-	bool
-
 source "lib/math/Kconfig"
 
 config NO_GENERIC_PCI_IOPORT_MAP
Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#5 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Yury Norov

In the 5.12 cycle we enabled the GENERIC_FIND_FIRST_BIT config option for ARM64 and MIPS. It increased performance and shrunk .text size; and so far I didn't receive any negative feedback on the change.

https://lore.kernel.org/linux-arch/[email protected]/

I think it's time to make all architectures use find_{first,last}_bit() unconditionally and remove the corresponding config option.

Quoted 7 lines
Quoted 5 lines

This patch doesn't introduce functional changes for arc, arm64, mips, s390 and x86 because they already enable GENERIC_FIND_FIRST_BIT. There will be no changes for arm because it implements find_{first,last}_bit in arch code. For other architectures I expect improvement both in performance and .text size.

Subject like s/all:/arch:/.

Ok, thanks. I will resend shortly as part of series, to fix m68k issue.

Quoted 144 lines
Quoted 2 lines

It would be great if people with an access to real hardware would share the output of bloat-o-meter and lib/find_bit_benchmark.

This is rather comment (should be below cutter '---' line).

Anyway, seems good to my by the code:

Quoted 131 lines
---
 arch/arc/Kconfig                  |  1 -
 arch/arm64/Kconfig                |  1 -
 arch/mips/Kconfig                 |  1 -
 arch/s390/Kconfig                 |  1 -
 arch/x86/Kconfig                  |  1 -
 arch/x86/um/Kconfig               |  1 -
 include/asm-generic/bitops/find.h | 12 ------------
 lib/Kconfig                       |  3 ---
 8 files changed, 21 deletions(-)
arch/arc/Kconfig +0 -1
index bc8d6aecfbbd..9c991ba50db3 100644
@@ -19,7 +19,6 @@ config ARC
 	select COMMON_CLK
 	select DMA_DIRECT_REMAP
 	select GENERIC_ATOMIC64 if !ISA_ARCV2 || !(ARC_HAS_LL64 && ARC_HAS_LLSC)
-	select GENERIC_FIND_FIRST_BIT
 	# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
arch/arm64/Kconfig +0 -1
index e09a9591af45..9d5b36f7d981 100644
@@ -108,7 +108,6 @@ config ARM64
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_EARLY_IOREMAP
-	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_IDLE_POLL_SETUP
 	select GENERIC_IRQ_IPI
 	select GENERIC_IRQ_PROBE
arch/mips/Kconfig +0 -1
index b72458215d20..3ddae7918386 100644
@@ -27,7 +27,6 @@ config MIPS
 	select GENERIC_ATOMIC64 if !64BIT
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CPU_AUTOPROBE
-	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_PROBE
arch/s390/Kconfig +0 -1
index c1ff874e6c2e..3a10ceb8a097 100644
@@ -125,7 +125,6 @@ config S390
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_ENTRY
-	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_PTDUMP
 	select GENERIC_SMP_IDLE_THREAD
arch/x86/Kconfig +0 -1
index b83364a15d34..6a7d8305365e 100644
@@ -123,7 +123,6 @@ config X86
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_EARLY_IOREMAP
 	select GENERIC_ENTRY
-	select GENERIC_FIND_FIRST_BIT
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_EFFECTIVE_AFF_MASK	if SMP
 	select GENERIC_IRQ_MATRIX_ALLOCATOR	if X86_LOCAL_APIC
arch/x86/um/Kconfig +0 -1
index 95d26a69088b..40d6a06e41c8 100644
@@ -8,7 +8,6 @@ endmenu
 
 config UML_X86
 	def_bool y
-	select GENERIC_FIND_FIRST_BIT
 
 config 64BIT
 	bool "64-bit kernel" if "$(SUBARCH)" = "x86"
include/asm-generic/bitops/find.h +0 -12
index 0d132ee2a291..8a7b70c79e15 100644
@@ -95,8 +95,6 @@ unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
 }
 #endif
 
-#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
-
 /**
  * find_first_bit - find the first set bit in a memory region
  * @addr: The address to start the search at
@@ -136,16 +134,6 @@ unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
 
 	return _find_first_zero_bit(addr, size);
 }
-#else /* CONFIG_GENERIC_FIND_FIRST_BIT */
-
-#ifndef find_first_bit
-#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
-#endif
-#ifndef find_first_zero_bit
-#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
-#endif
-
-#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
 
 #ifndef find_last_bit
 /**
lib/Kconfig +0 -3
index a38cc61256f1..8346b3181214 100644
@@ -59,9 +59,6 @@ config GENERIC_STRNLEN_USER
 config GENERIC_NET_UTILS
 	bool
 
-config GENERIC_FIND_FIRST_BIT
-	bool
-
 source "lib/math/Kconfig"
 
 config NO_GENERIC_PCI_IOPORT_MAP
Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards,
Andy Shevchenko