diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2022-04-04 16:47:55 +0200 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2022-04-09 22:19:39 +0200 |
commit | a2026e44eff5d74a83d7ffee6325a007bef85385 (patch) | |
tree | bce89de4ce23346ff21fa3f837dcd2cc29d6763b /kernel/time | |
parent | 2731aa7d65dbb31c6dad14347c37d522bb3bc7c6 (diff) |
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
Diffstat (limited to 'kernel/time')
-rw-r--r-- | kernel/time/timer.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 204d6cd83d0e..60aebf2b7f0a 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -502,7 +502,7 @@ static inline unsigned calc_index(unsigned long expires, unsigned lvl, * * Round up with level granularity to prevent this. */ - expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl); + expires = (expires >> LVL_SHIFT(lvl)) + 1; *bucket_expiry = expires << LVL_SHIFT(lvl); return LVL_OFFS(lvl) + (expires & LVL_MASK); } |