Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'bitmap-for-6.14' of https://github.com:/norov/linux

Pull bitmap updates from Yury Norov:
"This includes const_true() series from Vincent Mailhol, another
__always_inline rework from Nathan Chancellor for RISCV, and a couple
of random fixes from Dr. David Alan Gilbert and I Hsin Cheng"

* tag 'bitmap-for-6.14' of https://github.com:/norov/linux:
cpumask: Rephrase comments for cpumask_any*() APIs
cpu: Remove unused init_cpu_online
riscv: Always inline bitops
linux/bits.h: simplify GENMASK_INPUT_CHECK()
compiler.h: add const_true()

+38 -23
+10 -10
arch/riscv/include/asm/bitops.h
··· 228 228 * 229 229 * This operation may be reordered on other architectures than x86. 230 230 */ 231 - static inline int arch_test_and_set_bit(int nr, volatile unsigned long *addr) 231 + static __always_inline int arch_test_and_set_bit(int nr, volatile unsigned long *addr) 232 232 { 233 233 return __test_and_op_bit(or, __NOP, nr, addr); 234 234 } ··· 240 240 * 241 241 * This operation can be reordered on other architectures other than x86. 242 242 */ 243 - static inline int arch_test_and_clear_bit(int nr, volatile unsigned long *addr) 243 + static __always_inline int arch_test_and_clear_bit(int nr, volatile unsigned long *addr) 244 244 { 245 245 return __test_and_op_bit(and, __NOT, nr, addr); 246 246 } ··· 253 253 * This operation is atomic and cannot be reordered. 254 254 * It also implies a memory barrier. 255 255 */ 256 - static inline int arch_test_and_change_bit(int nr, volatile unsigned long *addr) 256 + static __always_inline int arch_test_and_change_bit(int nr, volatile unsigned long *addr) 257 257 { 258 258 return __test_and_op_bit(xor, __NOP, nr, addr); 259 259 } ··· 270 270 * Note that @nr may be almost arbitrarily large; this function is not 271 271 * restricted to acting on a single-word quantity. 272 272 */ 273 - static inline void arch_set_bit(int nr, volatile unsigned long *addr) 273 + static __always_inline void arch_set_bit(int nr, volatile unsigned long *addr) 274 274 { 275 275 __op_bit(or, __NOP, nr, addr); 276 276 } ··· 284 284 * on non x86 architectures, so if you are writing portable code, 285 285 * make sure not to rely on its reordering guarantees. 286 286 */ 287 - static inline void arch_clear_bit(int nr, volatile unsigned long *addr) 287 + static __always_inline void arch_clear_bit(int nr, volatile unsigned long *addr) 288 288 { 289 289 __op_bit(and, __NOT, nr, addr); 290 290 } ··· 298 298 * Note that @nr may be almost arbitrarily large; this function is not 299 299 * restricted to acting on a single-word quantity. 300 300 */ 301 - static inline void arch_change_bit(int nr, volatile unsigned long *addr) 301 + static __always_inline void arch_change_bit(int nr, volatile unsigned long *addr) 302 302 { 303 303 __op_bit(xor, __NOP, nr, addr); 304 304 } ··· 311 311 * This operation is atomic and provides acquire barrier semantics. 312 312 * It can be used to implement bit locks. 313 313 */ 314 - static inline int arch_test_and_set_bit_lock( 314 + static __always_inline int arch_test_and_set_bit_lock( 315 315 unsigned long nr, volatile unsigned long *addr) 316 316 { 317 317 return __test_and_op_bit_ord(or, __NOP, nr, addr, .aq); ··· 324 324 * 325 325 * This operation is atomic and provides release barrier semantics. 326 326 */ 327 - static inline void arch_clear_bit_unlock( 327 + static __always_inline void arch_clear_bit_unlock( 328 328 unsigned long nr, volatile unsigned long *addr) 329 329 { 330 330 __op_bit_ord(and, __NOT, nr, addr, .rl); ··· 345 345 * non-atomic property here: it's a lot more instructions and we still have to 346 346 * provide release semantics anyway. 347 347 */ 348 - static inline void arch___clear_bit_unlock( 348 + static __always_inline void arch___clear_bit_unlock( 349 349 unsigned long nr, volatile unsigned long *addr) 350 350 { 351 351 arch_clear_bit_unlock(nr, addr); 352 352 } 353 353 354 - static inline bool arch_xor_unlock_is_negative_byte(unsigned long mask, 354 + static __always_inline bool arch_xor_unlock_is_negative_byte(unsigned long mask, 355 355 volatile unsigned long *addr) 356 356 { 357 357 unsigned long res;
+2 -3
include/linux/bits.h
··· 20 20 */ 21 21 #if !defined(__ASSEMBLY__) 22 22 #include <linux/build_bug.h> 23 - #define GENMASK_INPUT_CHECK(h, l) \ 24 - (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \ 25 - __is_constexpr((l) > (h)), (l) > (h), 0))) 23 + #include <linux/compiler.h> 24 + #define GENMASK_INPUT_CHECK(h, l) BUILD_BUG_ON_ZERO(const_true((l) > (h))) 26 25 #else 27 26 /* 28 27 * BUILD_BUG_ON_ZERO is not available in h files included from asm files,
+22
include/linux/compiler.h
··· 308 308 #define statically_true(x) (__builtin_constant_p(x) && (x)) 309 309 310 310 /* 311 + * Similar to statically_true() but produces a constant expression 312 + * 313 + * To be used in conjunction with macros, such as BUILD_BUG_ON_ZERO(), 314 + * which require their input to be a constant expression and for which 315 + * statically_true() would otherwise fail. 316 + * 317 + * This is a trade-off: const_true() requires all its operands to be 318 + * compile time constants. Else, it would always returns false even on 319 + * the most trivial cases like: 320 + * 321 + * true || non_const_var 322 + * 323 + * On the opposite, statically_true() is able to fold more complex 324 + * tautologies and will return true on expressions such as: 325 + * 326 + * !(non_const_var * 8 % 4) 327 + * 328 + * For the general case, statically_true() is better. 329 + */ 330 + #define const_true(x) __builtin_choose_expr(__is_constexpr(x), x, false) 331 + 332 + /* 311 333 * This is needed in functions which generate the stack canary, see 312 334 * arch/x86/kernel/smpboot.c::start_secondary() for an example. 313 335 */
+4 -5
include/linux/cpumask.h
··· 391 391 for_each_set_bit_from(cpu, cpumask_bits(mask), small_cpumask_bits) 392 392 393 393 /** 394 - * cpumask_any_but - return a "random" in a cpumask, but not this one. 394 + * cpumask_any_but - return an arbitrary cpu in a cpumask, but not this one. 395 395 * @mask: the cpumask to search 396 396 * @cpu: the cpu to ignore. 397 397 * ··· 411 411 } 412 412 413 413 /** 414 - * cpumask_any_and_but - pick a "random" cpu from *mask1 & *mask2, but not this one. 414 + * cpumask_any_and_but - pick an arbitrary cpu from *mask1 & *mask2, but not this one. 415 415 * @mask1: the first input cpumask 416 416 * @mask2: the second input cpumask 417 417 * @cpu: the cpu to ignore ··· 840 840 } 841 841 842 842 /** 843 - * cpumask_any - pick a "random" cpu from *srcp 843 + * cpumask_any - pick an arbitrary cpu from *srcp 844 844 * @srcp: the input cpumask 845 845 * 846 846 * Return: >= nr_cpu_ids if no cpus set. ··· 848 848 #define cpumask_any(srcp) cpumask_first(srcp) 849 849 850 850 /** 851 - * cpumask_any_and - pick a "random" cpu from *mask1 & *mask2 851 + * cpumask_any_and - pick an arbitrary cpu from *mask1 & *mask2 852 852 * @mask1: the first input cpumask 853 853 * @mask2: the second input cpumask 854 854 * ··· 1043 1043 /* Wrappers for arch boot code to manipulate normally-constant masks */ 1044 1044 void init_cpu_present(const struct cpumask *src); 1045 1045 void init_cpu_possible(const struct cpumask *src); 1046 - void init_cpu_online(const struct cpumask *src); 1047 1046 1048 1047 #define assign_cpu(cpu, mask, val) \ 1049 1048 assign_bit(cpumask_check(cpu), cpumask_bits(mask), (val))
-5
kernel/cpu.c
··· 3128 3128 cpumask_copy(&__cpu_possible_mask, src); 3129 3129 } 3130 3130 3131 - void init_cpu_online(const struct cpumask *src) 3132 - { 3133 - cpumask_copy(&__cpu_online_mask, src); 3134 - } 3135 - 3136 3131 void set_cpu_online(unsigned int cpu, bool online) 3137 3132 { 3138 3133 /*