Skip to content

Commit 1f8a421

Browse files
Frederic WeisbeckerKAGA-KOKO
authored andcommitted
timers: Expand clk forward logic beyond nohz
As for next_expiry, the base->clk catch up logic will be expanded beyond NOHZ in order to avoid triggering useless softirqs. If softirqs should only fire to expire pending timers, periodic base->clk increments must be skippable for random amounts of time. Therefore prepare to catch-up with missing updates whenever an up-to-date base clock is needed. Signed-off-by: Frederic Weisbecker <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Juri Lelli <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 90d52f6 commit 1f8a421

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

kernel/time/timer.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -888,19 +888,12 @@ get_target_base(struct timer_base *base, unsigned tflags)
888888

889889
static inline void forward_timer_base(struct timer_base *base)
890890
{
891-
#ifdef CONFIG_NO_HZ_COMMON
892891
unsigned long jnow;
893892

894-
/*
895-
* We only forward the base when we are idle or have just come out of
896-
* idle (must_forward_clk logic), and have a delta between base clock
897-
* and jiffies. In the common case, run_timers will take care of it.
898-
*/
899-
if (likely(!base->must_forward_clk))
893+
if (!base->must_forward_clk)
900894
return;
901895

902896
jnow = READ_ONCE(jiffies);
903-
base->must_forward_clk = base->is_idle;
904897
if ((long)(jnow - base->clk) < 2)
905898
return;
906899

@@ -915,7 +908,6 @@ static inline void forward_timer_base(struct timer_base *base)
915908
return;
916909
base->clk = base->next_expiry;
917910
}
918-
#endif
919911
}
920912

921913

@@ -1667,10 +1659,8 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
16671659
* logic is only maintained for the BASE_STD base, deferrable
16681660
* timers may still see large granularity skew (by design).
16691661
*/
1670-
if ((expires - basem) > TICK_NSEC) {
1671-
base->must_forward_clk = true;
1662+
if ((expires - basem) > TICK_NSEC)
16721663
base->is_idle = true;
1673-
}
16741664
}
16751665
raw_spin_unlock(&base->lock);
16761666

@@ -1769,16 +1759,7 @@ static inline void __run_timers(struct timer_base *base)
17691759
/*
17701760
* timer_base::must_forward_clk must be cleared before running
17711761
* timers so that any timer functions that call mod_timer() will
1772-
* not try to forward the base. Idle tracking / clock forwarding
1773-
* logic is only used with BASE_STD timers.
1774-
*
1775-
* The must_forward_clk flag is cleared unconditionally also for
1776-
* the deferrable base. The deferrable base is not affected by idle
1777-
* tracking and never forwarded, so clearing the flag is a NOOP.
1778-
*
1779-
* The fact that the deferrable base is never forwarded can cause
1780-
* large variations in granularity for deferrable timers, but they
1781-
* can be deferred for long periods due to idle anyway.
1762+
* not try to forward the base.
17821763
*/
17831764
base->must_forward_clk = false;
17841765

@@ -1791,6 +1772,7 @@ static inline void __run_timers(struct timer_base *base)
17911772
while (levels--)
17921773
expire_timers(base, heads + levels);
17931774
}
1775+
base->must_forward_clk = true;
17941776
raw_spin_unlock_irq(&base->lock);
17951777
timer_base_unlock_expiry(base);
17961778
}

0 commit comments

Comments
 (0)