* [PATCH v2] sched/topology: Add a cpus_read_lock to rebuild_sched_domains()
@ 2026-08-13 7:38 Sebastian Andrzej Siewior
2026-08-13 7:48 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-08-13 7:38 UTC (permalink / raw)
To: linux-kernel
Cc: Ben Segall, Dietmar Eggemann, Ingo Molnar, Juri Lelli,
K Prateek Nayak, Mel Gorman, Peter Zijlstra, Steven Rostedt,
Tim Chen, Valentin Schneider, Vincent Guittot, chen.yu@linux.dev,
Chen, Yu C
A read from /proc/sys/kernel/sched_rt_runtime_us leads to backtrace due
to missing cpu_hotplug_lock with CONFIG_CPUSETS=n. The callchain is
sched_rt_handler() -> partition_sched_domains() -> sched_cache_set() ->
static_key_enable_cpuslocked(&sched_cache_present).
sched_cache_set() itself is also invoked from sched_init_domains() which
is early during the boot, holding just the sched_domains_mutex_lock().
Here is no warning because it happens before user space is running (and
hotplug operations are not possible).
There is also sched_cache_active_set() which acquires the hotplug lock
before invoking any of the _cpuslocked() functions.
This is only a problem with CONFIG_CPUSETS=n because in the =y case the
other implementation of rebuild_sched_domains acquires the CPU-hotplug
lock.
Acquire CPU hotplug lock before in rebuild_sched_domains(), before
partition_sched_domains() is invoked for the CONFIG_CPUSETS=n case.
Fixes: a7660ce1590fc ("sched/cache: Fix has_multi_llcs iff at least one partition has multiple LLCs")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
v1…v2: https://lore.kernel.org/all/20260812095800.gl06ANul@linutronix.de/
- Move the lock from partition_sched_domains() to
rebuild_sched_domains() in the CONFIG_CPUSETS=n since this is the
only affected case. Noticed by Yu C Chen and Tim Chen.
include/linux/cpuset.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 65d76a38974ba..bf3999daa080a 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -273,6 +273,7 @@ static inline void dl_rebuild_rd_accounting(void)
static inline void rebuild_sched_domains(void)
{
+ guard(cpus_read_lock)();
partition_sched_domains(1, NULL, NULL);
}
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] sched/topology: Add a cpus_read_lock to rebuild_sched_domains()
2026-08-13 7:38 [PATCH v2] sched/topology: Add a cpus_read_lock to rebuild_sched_domains() Sebastian Andrzej Siewior
@ 2026-08-13 7:48 ` Sebastian Andrzej Siewior
2026-08-13 9:20 ` Chen Yu
2026-08-13 9:43 ` Ridong Chen
0 siblings, 2 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-08-13 7:48 UTC (permalink / raw)
To: linux-kernel, cgroups
Cc: Ben Segall, Dietmar Eggemann, Ingo Molnar, Juri Lelli,
K Prateek Nayak, Mel Gorman, Peter Zijlstra, Steven Rostedt,
Tim Chen, Valentin Schneider, Vincent Guittot, chen.yu@linux.dev,
Chen, Yu C, Waiman Long, Ridong Chen
+ CPUSET maintainer which I missed because re-used the CCs from v1.
On 2026-08-13 09:38:56 [+0200], To linux-kernel@vger.kernel.org wrote:
> A read from /proc/sys/kernel/sched_rt_runtime_us leads to backtrace due
> to missing cpu_hotplug_lock with CONFIG_CPUSETS=n. The callchain is
> sched_rt_handler() -> partition_sched_domains() -> sched_cache_set() ->
> static_key_enable_cpuslocked(&sched_cache_present).
>
> sched_cache_set() itself is also invoked from sched_init_domains() which
> is early during the boot, holding just the sched_domains_mutex_lock().
> Here is no warning because it happens before user space is running (and
> hotplug operations are not possible).
>
> There is also sched_cache_active_set() which acquires the hotplug lock
> before invoking any of the _cpuslocked() functions.
>
> This is only a problem with CONFIG_CPUSETS=n because in the =y case the
> other implementation of rebuild_sched_domains acquires the CPU-hotplug
> lock.
>
> Acquire CPU hotplug lock before in rebuild_sched_domains(), before
> partition_sched_domains() is invoked for the CONFIG_CPUSETS=n case.
>
> Fixes: a7660ce1590fc ("sched/cache: Fix has_multi_llcs iff at least one partition has multiple LLCs")
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> v1…v2: https://lore.kernel.org/all/20260812095800.gl06ANul@linutronix.de/
> - Move the lock from partition_sched_domains() to
> rebuild_sched_domains() in the CONFIG_CPUSETS=n since this is the
> only affected case. Noticed by Yu C Chen and Tim Chen.
>
> include/linux/cpuset.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
> index 65d76a38974ba..bf3999daa080a 100644
> --- a/include/linux/cpuset.h
> +++ b/include/linux/cpuset.h
> @@ -273,6 +273,7 @@ static inline void dl_rebuild_rd_accounting(void)
>
> static inline void rebuild_sched_domains(void)
> {
> + guard(cpus_read_lock)();
> partition_sched_domains(1, NULL, NULL);
> }
>
> --
> 2.55.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] sched/topology: Add a cpus_read_lock to rebuild_sched_domains()
2026-08-13 7:48 ` Sebastian Andrzej Siewior
@ 2026-08-13 9:20 ` Chen Yu
2026-08-13 9:43 ` Ridong Chen
1 sibling, 0 replies; 4+ messages in thread
From: Chen Yu @ 2026-08-13 9:20 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, cgroups, Ben Segall, Dietmar Eggemann, Ingo Molnar,
Juri Lelli, K Prateek Nayak, Mel Gorman, Peter Zijlstra,
Steven Rostedt, Tim Chen, Valentin Schneider, Vincent Guittot,
Chen, Yu C, Waiman Long, Ridong Chen
On Thu, Aug 13, 2026 at 09:48:17AM +0200, Sebastian Andrzej Siewior wrote:
>
> + CPUSET maintainer which I missed because re-used the CCs from v1.
>
> On 2026-08-13 09:38:56 [+0200], To linux-kernel@vger.kernel.org wrote:
> > A read from /proc/sys/kernel/sched_rt_runtime_us leads to backtrace due
> > to missing cpu_hotplug_lock with CONFIG_CPUSETS=n. The callchain is
> > sched_rt_handler() -> partition_sched_domains() -> sched_cache_set() ->
> > static_key_enable_cpuslocked(&sched_cache_present).
> >
> > sched_cache_set() itself is also invoked from sched_init_domains() which
> > is early during the boot, holding just the sched_domains_mutex_lock().
> > Here is no warning because it happens before user space is running (and
> > hotplug operations are not possible).
> >
> > There is also sched_cache_active_set() which acquires the hotplug lock
> > before invoking any of the _cpuslocked() functions.
> >
> > This is only a problem with CONFIG_CPUSETS=n because in the =y case the
> > other implementation of rebuild_sched_domains acquires the CPU-hotplug
> > lock.
> >
> > Acquire CPU hotplug lock before in rebuild_sched_domains(), before
> > partition_sched_domains() is invoked for the CONFIG_CPUSETS=n case.
> >
> > Fixes: a7660ce1590fc ("sched/cache: Fix has_multi_llcs iff at least one partition has multiple LLCs")
> > Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Chen Yu <yu.c.chen@intel.com>
thanks,
Chenyu
> > ---
> > v1…v2: https://lore.kernel.org/all/20260812095800.gl06ANul@linutronix.de/
> > - Move the lock from partition_sched_domains() to
> > rebuild_sched_domains() in the CONFIG_CPUSETS=n since this is the
> > only affected case. Noticed by Yu C Chen and Tim Chen.
> >
> > include/linux/cpuset.h | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
> > index 65d76a38974ba..bf3999daa080a 100644
> > --- a/include/linux/cpuset.h
> > +++ b/include/linux/cpuset.h
> > @@ -273,6 +273,7 @@ static inline void dl_rebuild_rd_accounting(void)
> >
> > static inline void rebuild_sched_domains(void)
> > {
> > + guard(cpus_read_lock)();
> > partition_sched_domains(1, NULL, NULL);
> > }
> >
> > --
> > 2.55.0
> >
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] sched/topology: Add a cpus_read_lock to rebuild_sched_domains()
2026-08-13 7:48 ` Sebastian Andrzej Siewior
2026-08-13 9:20 ` Chen Yu
@ 2026-08-13 9:43 ` Ridong Chen
1 sibling, 0 replies; 4+ messages in thread
From: Ridong Chen @ 2026-08-13 9:43 UTC (permalink / raw)
To: Sebastian Andrzej Siewior, linux-kernel, cgroups
Cc: Ben Segall, Dietmar Eggemann, Ingo Molnar, Juri Lelli,
K Prateek Nayak, Mel Gorman, Peter Zijlstra, Steven Rostedt,
Tim Chen, Valentin Schneider, Vincent Guittot, chen.yu@linux.dev,
Chen, Yu C, Waiman Long
On 8/13/2026 3:48 PM, Sebastian Andrzej Siewior wrote:
> + CPUSET maintainer which I missed because re-used the CCs from v1.
>
> On 2026-08-13 09:38:56 [+0200], To linux-kernel@vger.kernel.org wrote:
>> A read from /proc/sys/kernel/sched_rt_runtime_us leads to backtrace due
>> to missing cpu_hotplug_lock with CONFIG_CPUSETS=n. The callchain is
>> sched_rt_handler() -> partition_sched_domains() -> sched_cache_set() ->
>> static_key_enable_cpuslocked(&sched_cache_present).
>>
>> sched_cache_set() itself is also invoked from sched_init_domains() which
>> is early during the boot, holding just the sched_domains_mutex_lock().
>> Here is no warning because it happens before user space is running (and
>> hotplug operations are not possible).
>>
>> There is also sched_cache_active_set() which acquires the hotplug lock
>> before invoking any of the _cpuslocked() functions.
>>
>> This is only a problem with CONFIG_CPUSETS=n because in the =y case the
>> other implementation of rebuild_sched_domains acquires the CPU-hotplug
>> lock.
>>
>> Acquire CPU hotplug lock before in rebuild_sched_domains(), before
>> partition_sched_domains() is invoked for the CONFIG_CPUSETS=n case.
>>
>> Fixes: a7660ce1590fc ("sched/cache: Fix has_multi_llcs iff at least one partition has multiple LLCs")
>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>> ---
>> v1…v2: https://lore.kernel.org/all/20260812095800.gl06ANul@linutronix.de/
>> - Move the lock from partition_sched_domains() to
>> rebuild_sched_domains() in the CONFIG_CPUSETS=n since this is the
>> only affected case. Noticed by Yu C Chen and Tim Chen.
>>
>> include/linux/cpuset.h | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
>> index 65d76a38974ba..bf3999daa080a 100644
>> --- a/include/linux/cpuset.h
>> +++ b/include/linux/cpuset.h
>> @@ -273,6 +273,7 @@ static inline void dl_rebuild_rd_accounting(void)
>>
>> static inline void rebuild_sched_domains(void)
>> {
>> + guard(cpus_read_lock)();
>> partition_sched_domains(1, NULL, NULL);
>> }
>>
>> --
>> 2.55.0
>>
LGTM. Thanks.
Reivewed-by: Ridong Chen <ridong.chen@linux.dev>
--
Best regards
Ridong
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-13 9:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 7:38 [PATCH v2] sched/topology: Add a cpus_read_lock to rebuild_sched_domains() Sebastian Andrzej Siewior
2026-08-13 7:48 ` Sebastian Andrzej Siewior
2026-08-13 9:20 ` Chen Yu
2026-08-13 9:43 ` Ridong Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox