summaryrefslogtreecommitdiff
path: root/include/linux/bitops.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2024-05-22 01:29:01 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2024-05-22 01:29:01 +0300
commit4865a27c66fda6a32511ec5492f4bbec437f512d (patch)
treedae4d82641bb45bc97735799dd7f0aac88b34778 /include/linux/bitops.h
parentb6394d6f715919c053c1450ef0d7c5e517b53764 (diff)
parent5671dca241b9a2f4ecf88d8e992041cfb580e0a5 (diff)
downloadlinux-4865a27c66fda6a32511ec5492f4bbec437f512d.tar.xz
Merge tag 'bitmap-for-6.10v2' of https://github.com/norov/linux
Pull bitmap updates from Yury Norov: - topology_span_sane() optimization from Kyle Meyer - fns() rework from Kuan-Wei Chiu (used in cpumask_local_spread() and other places) - headers cleanup from Andy - add a MAINTAINERS record for bitops API * tag 'bitmap-for-6.10v2' of https://github.com/norov/linux: usercopy: Don't use "proxy" headers bitops: Move aligned_byte_mask() to wordpart.h MAINTAINERS: add BITOPS API record bitmap: relax find_nth_bit() limitation on return value lib: make test_bitops compilable into the kernel image bitops: Optimize fns() for improved performance lib/test_bitops: Add benchmark test for fns() Compiler Attributes: Add __always_used macro sched/topology: Optimize topology_span_sane() cpumask: Add for_each_cpu_from()
Diffstat (limited to 'include/linux/bitops.h')
-rw-r--r--include/linux/bitops.h19
1 files changed, 3 insertions, 16 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 3112ae7d6524..46d4bdc634c0 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -8,13 +8,6 @@
#include <uapi/linux/kernel.h>
-/* Set bits in the first 'n' bytes when loaded from memory */
-#ifdef __LITTLE_ENDIAN
-# define aligned_byte_mask(n) ((1UL << 8*(n))-1)
-#else
-# define aligned_byte_mask(n) (~0xffUL << (BITS_PER_LONG - 8 - 8*(n)))
-#endif
-
#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
#define BITS_TO_LONGS(nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(long))
#define BITS_TO_U64(nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u64))
@@ -257,16 +250,10 @@ static inline unsigned int __ffs64(u64 word)
*/
static inline unsigned int fns(unsigned long word, unsigned int n)
{
- unsigned int bit;
-
- while (word) {
- bit = __ffs(word);
- if (n-- == 0)
- return bit;
- __clear_bit(bit, &word);
- }
+ while (word && n--)
+ word &= word - 1;
- return BITS_PER_LONG;
+ return word ? __ffs(word) : BITS_PER_LONG;
}
/**