[tip: sched/urgent] sched/topology: Add a cpus_read_lock to rebuild_sched_domains()
From: tip-bot2 for Sebastian Andrzej Siewior
Date: Thu Aug 20 2026 - 05:12:51 EST
The following commit has been merged into the sched/urgent branch of tip:
Commit-ID: 666a32836c8f9daf9b0067c49b04d5201fb8f3ba
Gitweb: https://git.kernel.org/tip/666a32836c8f9daf9b0067c49b04d5201fb8f3ba
Author: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
AuthorDate: Thu, 13 Aug 2026 09:38:55 +02:00
Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CommitterDate: Thu, 20 Aug 2026 11:01:34 +02:00
sched/topology: Add a cpus_read_lock to rebuild_sched_domains()
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@xxxxxxxxxxxxx>
Reivewed-by: Ridong Chen <ridong.chen@xxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Reviewed-by: Chen Yu <yu.c.chen@xxxxxxxxx>
Reviewed-by: Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx>
Reviewed-by: Waiman Long <longman@xxxxxxxxxx>
Reviewed-by: Valentin Schneider <vschneid@xxxxxxxxxx>
Reviewed-by: Shrikanth Hegde <sshegde@xxxxxxxxxxxxx>
Reviewed-by: Aaron Tomlin <atomlin@xxxxxxxxxxx>
Tested-by: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
Link: https://patch.msgid.link/20260813073855.ji2UrtVh@xxxxxxxxxxxxx
---
include/linux/cpuset.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 9db2d4f..6a3f4d4 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -279,6 +279,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);
}