linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bitops: Move test_bit() into bitops/atomic.h
@ 2020-05-21 14:31 Will Deacon
  2020-05-22 11:10 ` kbuild test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Will Deacon @ 2020-05-21 14:31 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-team, Will Deacon, Peter Zijlstra

test_bit() is an atomic operation as documented by atomic_bitops.txt.
Move the function from bitops/non-atomic.h to bitops/atomic.h and adjust
its implementation to align with the other atomic bitops.

Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Will Deacon <will@kernel.org>
---
 include/asm-generic/bitops/atomic.h     |  6 ++++++
 include/asm-generic/bitops/non-atomic.h | 10 ----------
 2 files changed, 6 insertions(+), 10 deletions(-)

Just found this kicking around on a branch from last year!

diff --git a/include/asm-generic/bitops/atomic.h b/include/asm-generic/bitops/atomic.h
index dd90c9792909..5fc4399d8fb4 100644
--- a/include/asm-generic/bitops/atomic.h
+++ b/include/asm-generic/bitops/atomic.h
@@ -17,6 +17,12 @@ static inline void set_bit(unsigned int nr, volatile unsigned long *p)
 	atomic_long_or(BIT_MASK(nr), (atomic_long_t *)p);
 }
 
+static inline int test_bit(unsigned int nr, const volatile unsigned long *p)
+{
+	p += BIT_WORD(nr);
+	return !!(READ_ONCE(*p) & BIT_MASK(nr));
+}
+
 static inline void clear_bit(unsigned int nr, volatile unsigned long *p)
 {
 	p += BIT_WORD(nr);
diff --git a/include/asm-generic/bitops/non-atomic.h b/include/asm-generic/bitops/non-atomic.h
index 7e10c4b50c5d..8b44da59a9d0 100644
--- a/include/asm-generic/bitops/non-atomic.h
+++ b/include/asm-generic/bitops/non-atomic.h
@@ -96,14 +96,4 @@ static inline int __test_and_change_bit(int nr,
 	return (old & mask) != 0;
 }
 
-/**
- * test_bit - Determine whether a bit is set
- * @nr: bit number to test
- * @addr: Address to start counting from
- */
-static inline int test_bit(int nr, const volatile unsigned long *addr)
-{
-	return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
-}
-
 #endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */
-- 
2.26.2.761.g0e0b3e54be-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bitops: Move test_bit() into bitops/atomic.h
  2020-05-21 14:31 [PATCH] bitops: Move test_bit() into bitops/atomic.h Will Deacon
@ 2020-05-22 11:10 ` kbuild test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2020-05-22 11:10 UTC (permalink / raw)
  To: Will Deacon, linux-kernel
  Cc: kbuild-all, clang-built-linux, kernel-team, Will Deacon, Peter Zijlstra

[-- Attachment #1: Type: text/plain, Size: 3085 bytes --]

Hi Will,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on asm-generic/master linux/master v5.7-rc6 next-20200521]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Will-Deacon/bitops-Move-test_bit-into-bitops-atomic-h/20200521-224744
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b85051e755b0e9d6dd8f17ef1da083851b83287d
config: arm-randconfig-r021-20200522 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 3393cc4cebf9969db94dc424b7a2b6195589c33b)
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

In file included from kernel/bounds.c:10:
In file included from include/linux/page-flags.h:10:
In file included from include/linux/bug.h:5:
In file included from arch/arm/include/asm/bug.h:60:
In file included from include/asm-generic/bug.h:19:
In file included from include/linux/kernel.h:12:
In file included from include/linux/bitops.h:29:
In file included from arch/arm/include/asm/bitops.h:268:
>> include/asm-generic/bitops/le.h:55:9: error: implicit declaration of function 'test_bit' [-Werror,-Wimplicit-function-declaration]
return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
^
1 error generated.
make[2]: *** [scripts/Makefile.build:100: kernel/bounds.s] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1148: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:180: sub-make] Error 2

vim +/test_bit +55 include/asm-generic/bitops/le.h

63ab595fb6b342 Akinobu Mita 2011-03-23  52  
a56560b3b23323 Akinobu Mita 2011-03-23  53  static inline int test_bit_le(int nr, const void *addr)
a56560b3b23323 Akinobu Mita 2011-03-23  54  {
a56560b3b23323 Akinobu Mita 2011-03-23 @55  	return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
a56560b3b23323 Akinobu Mita 2011-03-23  56  }
a56560b3b23323 Akinobu Mita 2011-03-23  57  

:::::: The code at line 55 was first introduced by commit
:::::: a56560b3b233238e85205d4e8d7bded904ac2306 asm-generic: change little-endian bitops to take any pointer types

:::::: TO: Akinobu Mita <akinobu.mita@gmail.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33750 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-22 11:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21 14:31 [PATCH] bitops: Move test_bit() into bitops/atomic.h Will Deacon
2020-05-22 11:10 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).