[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250115134111.2703089-2-imran.f.khan@oracle.com>
Date: Thu, 16 Jan 2025 00:41:10 +1100
From: Imran Khan <imran.f.khan@...cle.com>
To: anna-maria@...utronix.de, frederic@...nel.org, tglx@...utronix.de
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH 1/2] timers: WARN if add_timer_on is used with offlined cpu.
timer started on an offlined cpu will not fire after
its expiry time and may never fire if that cpu remains
offline.
So add a WARN_ON_ONCE in add_timer_on, to indicate
if any of its users are (wrongly) starting a timer
on an offlined cpu.
Suggested-by: Thomas Gleixner <tglx@...utronix.de>
Signed-off-by: Imran Khan <imran.f.khan@...cle.com>
---
kernel/time/timer.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index a5860bf6d16f9..ec9eb58e45241 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1370,6 +1370,12 @@ void add_timer_on(struct timer_list *timer, int cpu)
if (!timer->function)
goto out_unlock;
+ /*
+ * WARN if specified cpu is offline, because on offlined cpu
+ * timer will not fire even after its expiry.
+ */
+ WARN_ON_ONCE(!cpu_online(cpu));
+
if (base != new_base) {
timer->flags |= TIMER_MIGRATING;
--
2.34.1
Powered by blists - more mailing lists