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.

timers: Simplify calc_index()

The level granularity round up of calc_index() does:

(x + (1 << n)) >> n

which is obviously equivalent to

(x >> n) + 1

but compilers can't figure that out despite the fact that the input range
is known to not cause an overflow. It's neither intuitive to read.

Just write out the obvious.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/87h778j46c.ffs@tglx

+1 -1
+1 -1
kernel/time/timer.c
··· 502 502 * 503 503 * Round up with level granularity to prevent this. 504 504 */ 505 - expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl); 505 + expires = (expires >> LVL_SHIFT(lvl)) + 1; 506 506 *bucket_expiry = expires << LVL_SHIFT(lvl); 507 507 return LVL_OFFS(lvl) + (expires & LVL_MASK); 508 508 }