LVL_START() makes the first index of a level to start with what would be the value of all bits set of the previous level.
For example level 1 starts at 63 instead of 64. To cope with that, calc_index() always adds one offset for the level granularity to the expiry passed in parameter. Yet there is no apparent reason for such fixups so simplify the whole thing. Signed-off-by: Frederic Weisbecker <frede...@kernel.org> Cc: Peter Zijlstra <pet...@infradead.org> Cc: Anna-Maria Gleixner <anna-ma...@linutronix.de> Cc: Juri Lelli <juri.le...@redhat.com> --- kernel/time/timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 4c977df3610b..b4838d63a016 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -158,7 +158,7 @@ EXPORT_SYMBOL(jiffies_64); * The time start value for each level to select the bucket at enqueue * time. */ -#define LVL_START(n) ((LVL_SIZE - 1) << (((n) - 1) * LVL_CLK_SHIFT)) +#define LVL_START(n) (LVL_SIZE << (((n) - 1) * LVL_CLK_SHIFT)) /* Size of each clock level */ #define LVL_BITS 6 @@ -489,7 +489,7 @@ static inline void timer_set_idx(struct timer_list *timer, unsigned int idx) */ static inline unsigned calc_index(unsigned expires, unsigned lvl) { - expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl); + expires >>= LVL_SHIFT(lvl); return LVL_OFFS(lvl) + (expires & LVL_MASK); } -- 2.26.2