Skip to content

Commit e2a71bd

Browse files
Frederic WeisbeckerKAGA-KOKO
authored andcommitted
timer: Fix wheel index calculation on last level
When an expiration delta falls into the last level of the wheel, that delta has be compared against the maximum possible delay and reduced to fit in if necessary. However instead of comparing the delta against the maximum, the code compares the actual expiry against the maximum. Then instead of fixing the delta to fit in, it sets the maximum delta as the expiry value. This can result in various undesired outcomes, the worst possible one being a timer expiring 15 days ahead to fire immediately. Fixes: 500462a ("timers: Switch to a non-cascading wheel") Signed-off-by: Frederic Weisbecker <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent 30c66fc commit e2a71bd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/time/timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,8 @@ static int calc_wheel_index(unsigned long expires, unsigned long clk)
521521
* Force expire obscene large timeouts to expire at the
522522
* capacity limit of the wheel.
523523
*/
524-
if (expires >= WHEEL_TIMEOUT_CUTOFF)
525-
expires = WHEEL_TIMEOUT_MAX;
524+
if (delta >= WHEEL_TIMEOUT_CUTOFF)
525+
expires = clk + WHEEL_TIMEOUT_MAX;
526526

527527
idx = calc_index(expires, LVL_DEPTH - 1);
528528
}

0 commit comments

Comments
 (0)