* [PATCH] sched/isolation: Have housekeeping_any_cpu() use raw_smp_processor_id()
@ 2026-11-27 22:10 Steven Rostedt
2026-11-27 22:16 ` sashiko-bot
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2026-11-27 22:10 UTC (permalink / raw)
To: LKML, Linux Trace Kernel
Cc: Frederic Weisbecker, Peter Zijlstra, Ingo Molnar, Thomas Gleixner
From: Steven Rostedt <rostedt@goodmis.org>
When isolation is not enabled, houeskeeping_any_cpu() returns the current
CPU via smp_processor_id(). If this is called from a preemptable context,
it triggers a WARN_ON():
BUG: using smp_processor_id() in preemptible [00000000] code: ftracetest/21785
As the function is to return any CPU that is for house keeping, it
doesn't make sense to require it to be called from a non preemptable
context as the result is not guaranteed to return the current CPU anyway.
Use raw_smp_processor_id() to suppress the warning.
Fixes: 7863406143d8b ("sched/isolation: Move housekeeping related code to its own file")
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/linux/sched/isolation.h | 2 +-
kernel/sched/isolation.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
index cf0fd03dd7a2..81617d5c8e69 100644
--- a/include/linux/sched/isolation.h
+++ b/include/linux/sched/isolation.h
@@ -50,7 +50,7 @@ extern void __init housekeeping_init(void);
static inline int housekeeping_any_cpu(enum hk_type type)
{
- return smp_processor_id();
+ return raw_smp_processor_id();
}
static inline const struct cpumask *housekeeping_cpumask(enum hk_type type)
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 156025ef81b7..c1c84d72c7c5 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -99,7 +99,7 @@ int housekeeping_any_cpu(enum hk_type type)
type != HK_TYPE_TIMER);
}
}
- return smp_processor_id();
+ return raw_smp_processor_id();
}
EXPORT_SYMBOL_GPL(housekeeping_any_cpu);
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sched/isolation: Have housekeeping_any_cpu() use raw_smp_processor_id()
2026-11-27 22:10 [PATCH] sched/isolation: Have housekeeping_any_cpu() use raw_smp_processor_id() Steven Rostedt
@ 2026-11-27 22:16 ` sashiko-bot
2026-11-27 22:23 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: sashiko-bot @ 2026-11-27 22:16 UTC (permalink / raw)
To: Steven Rostedt, Linux Trace Kernel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/isolation: housekeeping_any_cpu() still warns in
preemptible context
--
commit c1392718dea3b288dab2eb1637739fbba4e0fc9a
Author: Steven Rostedt <rostedt@goodmis.org>
sched/isolation: Have housekeeping_any_cpu() use raw_smp_processor_id()
This commit replaces smp_processor_id() with raw_smp_processor_id() in
the housekeeping_any_cpu() fallback returns so that callers in preemptible
context do not trigger preemption warnings when isolation is not enabled.
> diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
> index 156025ef81b75..c1c84d72c7c5b 100644
> --- a/kernel/sched/isolation.c
> +++ b/kernel/sched/isolation.c
> @@ -99,7 +99,7 @@ int housekeeping_any_cpu(enum hk_type type)
> type != HK_TYPE_TIMER);
> }
> }
> - return smp_processor_id();
> + return raw_smp_processor_id();
> }
> EXPORT_SYMBOL_GPL(housekeeping_any_cpu);
[Severity: Medium]
Can housekeeping_any_cpu() still trigger CONFIG_DEBUG_PREEMPT warnings when
called from a preemptible context with CPU isolation enabled?
When housekeeping_overridden is active and housekeeping.flags has the
requested type set, housekeeping_any_cpu() takes the branch above this
fallback:
kernel/sched/isolation.c:housekeeping_any_cpu() {
if (static_branch_unlikely(&housekeeping_overridden)) {
if (housekeeping.flags & BIT(type)) {
cpu = sched_numa_find_closest(housekeeping_cpumask(type), smp_processor_id());
if (cpu < nr_cpu_ids)
return cpu;
cpu = cpumask_any_and_distribute(housekeeping_cpumask(type), cpu_online_mask);
}
That path still passes smp_processor_id() to sched_numa_find_closest(), and
both sched_numa_find_closest() (under rcu_read_lock(), which remains
preemptible on CONFIG_PREEMPT_RCU kernels) and the fallback call
cpumask_any_and_distribute(), which uses __this_cpu_read() and
__this_cpu_write() on distribute_cpu_mask_prev. A preemptible caller such
as ring_buffer_poll_remote() -> rb_wakeups() -> rb_irq_work_queue() on a
system booted with nohz_full= will therefore still hit smp_processor_id()
and __this_cpu_read() preemption splats.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127171034.60e9de0c@gandalf.local.home?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sched/isolation: Have housekeeping_any_cpu() use raw_smp_processor_id()
2026-11-27 22:16 ` sashiko-bot
@ 2026-11-27 22:23 ` Steven Rostedt
0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2026-11-27 22:23 UTC (permalink / raw)
To: sashiko-bot
Cc: sashiko-reviews, Linux Trace Kernel, Frederic Weisbecker,
Peter Zijlstra, Ingo Molnar, Thomas Gleixner
On Fri, 27 Nov 2026 22:16:58 +0000
sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] sched/isolation: housekeeping_any_cpu() still warns in
> preemptible context
> --
>
> commit c1392718dea3b288dab2eb1637739fbba4e0fc9a
> Author: Steven Rostedt <rostedt@goodmis.org>
>
> sched/isolation: Have housekeeping_any_cpu() use raw_smp_processor_id()
>
> This commit replaces smp_processor_id() with raw_smp_processor_id() in
> the housekeeping_any_cpu() fallback returns so that callers in preemptible
> context do not trigger preemption warnings when isolation is not enabled.
>
> > diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
> > index 156025ef81b75..c1c84d72c7c5b 100644
> > --- a/kernel/sched/isolation.c
> > +++ b/kernel/sched/isolation.c
> > @@ -99,7 +99,7 @@ int housekeeping_any_cpu(enum hk_type type)
> > type != HK_TYPE_TIMER);
> > }
> > }
> > - return smp_processor_id();
> > + return raw_smp_processor_id();
> > }
> > EXPORT_SYMBOL_GPL(housekeeping_any_cpu);
>
> [Severity: Medium]
> Can housekeeping_any_cpu() still trigger CONFIG_DEBUG_PREEMPT warnings when
> called from a preemptible context with CPU isolation enabled?
>
> When housekeeping_overridden is active and housekeeping.flags has the
> requested type set, housekeeping_any_cpu() takes the branch above this
> fallback:
>
> kernel/sched/isolation.c:housekeeping_any_cpu() {
> if (static_branch_unlikely(&housekeeping_overridden)) {
> if (housekeeping.flags & BIT(type)) {
> cpu = sched_numa_find_closest(housekeeping_cpumask(type), smp_processor_id());
> if (cpu < nr_cpu_ids)
> return cpu;
>
> cpu = cpumask_any_and_distribute(housekeeping_cpumask(type), cpu_online_mask);
> }
>
> That path still passes smp_processor_id() to sched_numa_find_closest(), and
> both sched_numa_find_closest() (under rcu_read_lock(), which remains
> preemptible on CONFIG_PREEMPT_RCU kernels) and the fallback call
> cpumask_any_and_distribute(), which uses __this_cpu_read() and
> __this_cpu_write() on distribute_cpu_mask_prev. A preemptible caller such
> as ring_buffer_poll_remote() -> rb_wakeups() -> rb_irq_work_queue() on a
> system booted with nohz_full= will therefore still hit smp_processor_id()
> and __this_cpu_read() preemption splats.
>
Hmm, I wonder if we should add a preempt_disable() to the above in case
that needs to keep on the same CPU for that logic.
I still do not see the point of having this function in general have to be
called with preemption disabled.
-- Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-27 22:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 22:10 [PATCH] sched/isolation: Have housekeeping_any_cpu() use raw_smp_processor_id() Steven Rostedt
2026-11-27 22:16 ` sashiko-bot
2026-11-27 22:23 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox