Commit 4865a27c authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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()
parents b6394d6f 5671dca2
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -3725,6 +3725,20 @@ F: tools/include/vdso/bits.h
F:	tools/lib/bitmap.c
F:	tools/lib/find_bit.c
BITOPS API
M:	Yury Norov <yury.norov@gmail.com>
R:	Rasmus Villemoes <linux@rasmusvillemoes.dk>
S:	Maintained
F:	arch/*/include/asm/bitops.h
F:	arch/*/include/asm/bitops_32.h
F:	arch/*/include/asm/bitops_64.h
F:	arch/*/lib/bitops.c
F:	include/asm-generic/bitops
F:	include/asm-generic/bitops.h
F:	include/linux/bitops.h
F:	lib/test_bitops.c
F:	tools/*/bitops*
BLINKM RGB LED DRIVER
M:	Jan-Simon Moeller <jansimon.moeller@gmx.de>
S:	Maintained
+3 −16
Original line number Diff line number Diff line
@@ -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;
}

/**
+13 −0
Original line number Diff line number Diff line
@@ -361,6 +361,19 @@
 */
#define __used                          __attribute__((__used__))

/*
 * The __used attribute guarantees that the attributed variable will be
 * always emitted by a compiler. It doesn't prevent the compiler from
 * throwing 'unused' warnings when it can't detect how the variable is
 * actually used. It's a compiler implementation details either emit
 * the warning in that case or not.
 *
 * The combination of both 'used' and 'unused' attributes ensures that
 * the variable would be emitted, and will not trigger 'unused' warnings.
 * The attribute is applicable for functions, static and global variables.
 */
#define __always_used			__used __maybe_unused

/*
 *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-warn_005funused_005fresult-function-attribute
 * clang: https://clang.llvm.org/docs/AttributeReference.html#nodiscard-warn-unused-result
+10 −0
Original line number Diff line number Diff line
@@ -385,6 +385,16 @@ unsigned int __pure cpumask_next_wrap(int n, const struct cpumask *mask, int sta
#define for_each_cpu_or(cpu, mask1, mask2)				\
	for_each_or_bit(cpu, cpumask_bits(mask1), cpumask_bits(mask2), small_cpumask_bits)

/**
 * for_each_cpu_from - iterate over CPUs present in @mask, from @cpu to the end of @mask.
 * @cpu: the (optionally unsigned) integer iterator
 * @mask: the cpumask pointer
 *
 * After the loop, cpu is >= nr_cpu_ids.
 */
#define for_each_cpu_from(cpu, mask)				\
	for_each_set_bit_from(cpu, cpumask_bits(mask), small_cpumask_bits)

/**
 * cpumask_any_but - return a "random" in a cpumask, but not this one.
 * @mask: the cpumask to search
+1 −1
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
 *	 idx = find_first_bit(addr, size);
 *
 * Returns the bit number of the N'th set bit.
 * If no such, returns @size.
 * If no such, returns >= @size.
 */
static inline
unsigned long find_nth_bit(const unsigned long *addr, unsigned long size, unsigned long n)
Loading