From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Nam Cao <namcao@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Mel Gorman <mgorman@suse.de>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Valentin Schneider <vschneid@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] smp: Suppress false DEBUG_PREEMPT warning in smp_call_on_cpu()
Date: Fri, 24 Oct 2025 16:08:32 +0200 [thread overview]
Message-ID: <20251024140832.46JNLRvL@linutronix.de> (raw)
In-Reply-To: <20251024070714.4047816-1-namcao@linutronix.de>
On 2025-10-24 09:07:14 [+0200], Nam Cao wrote:
> 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
Can be compressed to:
Using smp_processor_id() in a smp_call_on_cpu() callback triggers a
"using ... in preemptible" warning in UP builds.
> 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.
"Only the UP implementation is affected by this"
> 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.
Right. This is one of the possibilities. The other one would be to also
workqueue on UP and preserve the same semantic.
I don't mind this.
> Fixes: 06ddd17521bf ("sched/smp: Always define is_percpu_thread() and scheduler_ipi()")
> Signed-off-by: Nam Cao <namcao@linutronix.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() */
If you want to add a comment, what about something like
/* Preserve not being migratable such as SMP variant does */
> + migrate_disable();
> +
> ret = func(par);
> +
> + migrate_enable();
> +
> if (phys)
> hypervisor_pin_vcpu(-1);
>
Sebastian
next prev parent reply other threads:[~2025-10-24 14:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-24 7:07 [PATCH] smp: Suppress false DEBUG_PREEMPT warning in smp_call_on_cpu() Nam Cao
2025-10-24 14:08 ` Sebastian Andrzej Siewior [this message]
2025-11-05 8:42 ` Nam Cao
2025-11-05 8:48 ` Sebastian Andrzej Siewior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251024140832.46JNLRvL@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=namcao@linutronix.de \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sshegde@linux.ibm.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.