Commit 1f8a4212 authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Thomas Gleixner

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: default avatarFrederic Weisbecker <frederic@kernel.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Tested-by: default avatarJuri Lelli <juri.lelli@redhat.com>
Link: https://lkml.kernel.org/r/20200717140551.29076-10-frederic@kernel.org
parent 90d52f65
...@@ -888,19 +888,12 @@ get_target_base(struct timer_base *base, unsigned tflags) ...@@ -888,19 +888,12 @@ get_target_base(struct timer_base *base, unsigned tflags)
static inline void forward_timer_base(struct timer_base *base) static inline void forward_timer_base(struct timer_base *base)
{ {
#ifdef CONFIG_NO_HZ_COMMON
unsigned long jnow; unsigned long jnow;
/* if (!base->must_forward_clk)
* We only forward the base when we are idle or have just come out of
* idle (must_forward_clk logic), and have a delta between base clock
* and jiffies. In the common case, run_timers will take care of it.
*/
if (likely(!base->must_forward_clk))
return; return;
jnow = READ_ONCE(jiffies); jnow = READ_ONCE(jiffies);
base->must_forward_clk = base->is_idle;
if ((long)(jnow - base->clk) < 2) if ((long)(jnow - base->clk) < 2)
return; return;
...@@ -915,7 +908,6 @@ static inline void forward_timer_base(struct timer_base *base) ...@@ -915,7 +908,6 @@ static inline void forward_timer_base(struct timer_base *base)
return; return;
base->clk = base->next_expiry; base->clk = base->next_expiry;
} }
#endif
} }
...@@ -1667,10 +1659,8 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem) ...@@ -1667,10 +1659,8 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
* logic is only maintained for the BASE_STD base, deferrable * logic is only maintained for the BASE_STD base, deferrable
* timers may still see large granularity skew (by design). * timers may still see large granularity skew (by design).
*/ */
if ((expires - basem) > TICK_NSEC) { if ((expires - basem) > TICK_NSEC)
base->must_forward_clk = true;
base->is_idle = true; base->is_idle = true;
}
} }
raw_spin_unlock(&base->lock); raw_spin_unlock(&base->lock);
...@@ -1769,16 +1759,7 @@ static inline void __run_timers(struct timer_base *base) ...@@ -1769,16 +1759,7 @@ static inline void __run_timers(struct timer_base *base)
/* /*
* timer_base::must_forward_clk must be cleared before running * timer_base::must_forward_clk must be cleared before running
* timers so that any timer functions that call mod_timer() will * timers so that any timer functions that call mod_timer() will
* not try to forward the base. Idle tracking / clock forwarding * not try to forward the base.
* logic is only used with BASE_STD timers.
*
* The must_forward_clk flag is cleared unconditionally also for
* the deferrable base. The deferrable base is not affected by idle
* tracking and never forwarded, so clearing the flag is a NOOP.
*
* The fact that the deferrable base is never forwarded can cause
* large variations in granularity for deferrable timers, but they
* can be deferred for long periods due to idle anyway.
*/ */
base->must_forward_clk = false; base->must_forward_clk = false;
...@@ -1791,6 +1772,7 @@ static inline void __run_timers(struct timer_base *base) ...@@ -1791,6 +1772,7 @@ static inline void __run_timers(struct timer_base *base)
while (levels--) while (levels--)
expire_timers(base, heads + levels); expire_timers(base, heads + levels);
} }
base->must_forward_clk = true;
raw_spin_unlock_irq(&base->lock); raw_spin_unlock_irq(&base->lock);
timer_base_unlock_expiry(base); timer_base_unlock_expiry(base);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment