[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251024070714.4047816-1-namcao@linutronix.de>
Date: Fri, 24 Oct 2025 09:07:14 +0200
From: Nam Cao <namcao@...utronix.de>
To: Ingo Molnar <mingo@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Mel Gorman <mgorman@...e.de>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Shrikanth Hegde <sshegde@...ux.ibm.com>,
Steven Rostedt <rostedt@...dmis.org>,
Valentin Schneider <vschneid@...hat.com>,
linux-kernel@...r.kernel.org,
Nam Cao <namcao@...utronix.de>
Subject: [PATCH] smp: Suppress false DEBUG_PREEMPT warning in smp_call_on_cpu()
While booting UP (uniprocessor) kernel with CONFIG_DEBUG_PREEMPT=y, the
following warning is observed:
BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
caller is debug_smp_processor_id+0x1c/0x28
CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.18.0-rc2-00012-g002733e953a7 #111 PREEMPT_RT
Hardware name: MangoPi MQ Pro (DT)
Call Trace:
dump_backtrace
show_stack
dump_stack_lvl
dump_stack
check_preemption_disabled.isra.0
debug_smp_processor_id
check_unaligned_access
smp_call_on_cpu
check_unaligned_access_all_cpus
do_one_initcall
kernel_init_freeable
kernel_init
ret_from_fork_kernel
ret_from_fork_kernel_asm
This is a false warning. The UP-variant of smp_call_on_cpu() simply calls
the callback, and thus debug_smp_processor_id() thinks the context is
unsafe for smp_processor_id(), which is obviously false because this is UP
kernel.
This appears after commit 06ddd17521bf ("sched/smp: Always define
is_percpu_thread() and scheduler_ipi()"). Before this commit,
is_percpu_thread() always returns true on UP kernel and thus
debug_smp_processor_id() always sees a per-cpu thread and never warns. But
now is_percpu_thread() returns false for this case.
Suppress this warning with a migrate_disable()+migrate_enable() pair.
Fixes: 06ddd17521bf ("sched/smp: Always define is_percpu_thread() and scheduler_ipi()")
Signed-off-by: Nam Cao <namcao@...utronix.de>
---
grep shows me that the followings also have the same false warning:
arch/arm64/kernel/watchdog_hld.c
drivers/hwmon/dell-smm-hwmon.c
drivers/platform/x86/dell/dcdbas.c
kernel/watchdog.c
---
kernel/up.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/up.c b/kernel/up.c
index df50828cc2f0..37c9f0d39b36 100644
--- a/kernel/up.c
+++ b/kernel/up.c
@@ -64,7 +64,14 @@ int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys)
if (phys)
hypervisor_pin_vcpu(0);
+
+ /* suppress warnings from debug_smp_processor_id() */
+ migrate_disable();
+
ret = func(par);
+
+ migrate_enable();
+
if (phys)
hypervisor_pin_vcpu(-1);
--
2.39.5
Powered by blists - more mailing lists