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

sched: simplify sched_find_first_bit()

simplify sched_rt.c's sched_find_first_bit() function: there are
only 100 RT priority levels left.

Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

Mike Galbraith and committed by
Ingo Molnar
ff80a77f 5e7eaade

+8 -13
+8 -13
include/asm-generic/bitops/sched.h
··· 6 6 7 7 /* 8 8 * Every architecture must define this function. It's the fastest 9 - * way of searching a 140-bit bitmap where the first 100 bits are 10 - * unlikely to be set. It's guaranteed that at least one of the 140 11 - * bits is cleared. 9 + * way of searching a 100-bit bitmap. It's guaranteed that at least 10 + * one of the 100 bits is cleared. 12 11 */ 13 12 static inline int sched_find_first_bit(const unsigned long *b) 14 13 { 15 14 #if BITS_PER_LONG == 64 16 - if (unlikely(b[0])) 15 + if (b[0]) 17 16 return __ffs(b[0]); 18 - if (likely(b[1])) 19 - return __ffs(b[1]) + 64; 20 - return __ffs(b[2]) + 128; 17 + return __ffs(b[1]) + 64; 21 18 #elif BITS_PER_LONG == 32 22 - if (unlikely(b[0])) 19 + if (b[0]) 23 20 return __ffs(b[0]); 24 - if (unlikely(b[1])) 21 + if (b[1]) 25 22 return __ffs(b[1]) + 32; 26 - if (unlikely(b[2])) 23 + if (b[2]) 27 24 return __ffs(b[2]) + 64; 28 - if (b[3]) 29 - return __ffs(b[3]) + 96; 30 - return __ffs(b[4]) + 128; 25 + return __ffs(b[3]) + 96; 31 26 #else 32 27 #error BITS_PER_LONG not defined 33 28 #endif