Skip to content

Commit da05b5e

Browse files
committed
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fix from Ingo Molnar: "Fix a timer expiry bug that would cause spurious delay of timers" * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: timer: Read jiffies once when forwarding base clk
2 parents a7b7b77 + e430d80 commit da05b5e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

kernel/time/timer.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,24 +1678,26 @@ void timer_clear_idle(void)
16781678
static int collect_expired_timers(struct timer_base *base,
16791679
struct hlist_head *heads)
16801680
{
1681+
unsigned long now = READ_ONCE(jiffies);
1682+
16811683
/*
16821684
* NOHZ optimization. After a long idle sleep we need to forward the
16831685
* base to current jiffies. Avoid a loop by searching the bitfield for
16841686
* the next expiring timer.
16851687
*/
1686-
if ((long)(jiffies - base->clk) > 2) {
1688+
if ((long)(now - base->clk) > 2) {
16871689
unsigned long next = __next_timer_interrupt(base);
16881690

16891691
/*
16901692
* If the next timer is ahead of time forward to current
16911693
* jiffies, otherwise forward to the next expiry time:
16921694
*/
1693-
if (time_after(next, jiffies)) {
1695+
if (time_after(next, now)) {
16941696
/*
16951697
* The call site will increment base->clk and then
16961698
* terminate the expiry loop immediately.
16971699
*/
1698-
base->clk = jiffies;
1700+
base->clk = now;
16991701
return 0;
17001702
}
17011703
base->clk = next;

0 commit comments

Comments
 (0)