History

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.

Frederic Weisbecker committed 6 years ago

Commit e2a71bd1 parent 30c66fc1 file · +2 −2Browse files

Unified · Split

kernel/time/timer.c+2−2
@@ -521,8 +521,8 @@ static int calc_wheel_index(unsigned long expires, unsigned long clk) · 520 unmodified lines
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 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t