[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221025135850.51044-12-anna-maria@linutronix.de>
Date: Tue, 25 Oct 2022 15:58:44 +0200
From: Anna-Maria Behnsen <anna-maria@...utronix.de>
To: linux-kernel@...r.kernel.org
Cc: Peter Zijlstra <peterz@...radead.org>,
John Stultz <john.stultz@...aro.org>,
Eric Dumazet <edumazet@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
linux-pm@...r.kernel.org, Arjan van de Ven <arjan@...radead.org>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Rik van Riel <riel@...hat.com>,
"Richard Cochran (linutronix GmbH)" <richardcochran@...il.com>,
Anna-Maria Behnsen <anna-maria@...utronix.de>
Subject: [PATCH v3 11/17] timer: Restructure internal locking
From: "Richard Cochran (linutronix GmbH)" <richardcochran@...il.com>
Move the locking out from __run_timers() to the call sites, so the
protected section can be extended at the call site. Preparatory patch for
changing the NOHZ timer placement to a pull at expiry time model.
No functional change.
Signed-off-by: Richard Cochran (linutronix GmbH) <richardcochran@...il.com>
Signed-off-by: Anna-Maria Behnsen <anna-maria@...utronix.de>
---
kernel/time/timer.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 54631e86763f..bce2f87d5e70 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1911,11 +1911,7 @@ static inline void __run_timers(struct timer_base *base)
struct hlist_head heads[LVL_DEPTH];
int levels;
- if (time_before(jiffies, base->next_expiry))
- return;
-
- timer_base_lock_expiry(base);
- raw_spin_lock_irq(&base->lock);
+ lockdep_assert_held(&base->lock);
while (time_after_eq(jiffies, base->clk) &&
time_after_eq(jiffies, base->next_expiry)) {
@@ -1935,21 +1931,36 @@ static inline void __run_timers(struct timer_base *base)
while (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);
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.
*/
static __latent_entropy void run_timer_softirq(struct softirq_action *h)
{
- struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_LOCAL]);
-
- __run_timers(base);
+ run_timer_base(BASE_LOCAL);
if (IS_ENABLED(CONFIG_NO_HZ_COMMON)) {
- __run_timers(this_cpu_ptr(&timer_bases[BASE_GLOBAL]));
- __run_timers(this_cpu_ptr(&timer_bases[BASE_DEF]));
+ run_timer_base(BASE_GLOBAL);
+ run_timer_base(BASE_DEF);
}
}
--
2.30.2
Powered by blists - more mailing lists