Commit 90f5df66 authored by Richard Cochran (linutronix GmbH)'s avatar Richard Cochran (linutronix GmbH) Committed by Thomas Gleixner

timers: Restructure internal locking

Move the locking out from __run_timers() to the call sites, so the
protected section can be extended at the call site. Preparatory work for
changing the NOHZ timer placement to a pull at expiry time model.

No functional change.
Signed-off-by: default avatarRichard Cochran (linutronix GmbH) <richardcochran@gmail.com>
Signed-off-by: default avatarAnna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarFrederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20240221090548.36600-15-anna-maria@linutronix.de
parent f73d9257
...@@ -2283,11 +2283,7 @@ static inline void __run_timers(struct timer_base *base) ...@@ -2283,11 +2283,7 @@ static inline void __run_timers(struct timer_base *base)
struct hlist_head heads[LVL_DEPTH]; struct hlist_head heads[LVL_DEPTH];
int levels; int levels;
if (time_before(jiffies, base->next_expiry)) lockdep_assert_held(&base->lock);
return;
timer_base_lock_expiry(base);
raw_spin_lock_irq(&base->lock);
while (time_after_eq(jiffies, base->clk) && while (time_after_eq(jiffies, base->clk) &&
time_after_eq(jiffies, base->next_expiry)) { time_after_eq(jiffies, base->next_expiry)) {
...@@ -2311,21 +2307,36 @@ static inline void __run_timers(struct timer_base *base) ...@@ -2311,21 +2307,36 @@ static inline void __run_timers(struct timer_base *base)
while (levels--) while (levels--)
expire_timers(base, heads + levels); expire_timers(base, heads + levels);
} }
}
static void __run_timer_base(struct timer_base *base)
{
if (time_before(jiffies, base->next_expiry))
return;
timer_base_lock_expiry(base);
raw_spin_lock_irq(&base->lock);
__run_timers(base);
raw_spin_unlock_irq(&base->lock); raw_spin_unlock_irq(&base->lock);
timer_base_unlock_expiry(base); timer_base_unlock_expiry(base);
} }
static void run_timer_base(int index)
{
struct timer_base *base = this_cpu_ptr(&timer_bases[index]);
__run_timer_base(base);
}
/* /*
* This function runs timers and the timer-tq in bottom half context. * This function runs timers and the timer-tq in bottom half context.
*/ */
static __latent_entropy void run_timer_softirq(struct softirq_action *h) static __latent_entropy void run_timer_softirq(struct softirq_action *h)
{ {
struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_LOCAL]); run_timer_base(BASE_LOCAL);
__run_timers(base);
if (IS_ENABLED(CONFIG_NO_HZ_COMMON)) { if (IS_ENABLED(CONFIG_NO_HZ_COMMON)) {
__run_timers(this_cpu_ptr(&timer_bases[BASE_GLOBAL])); run_timer_base(BASE_GLOBAL);
__run_timers(this_cpu_ptr(&timer_bases[BASE_DEF])); run_timer_base(BASE_DEF);
} }
} }
......
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