[PATCH] sched/topology: Add a cpus_read_lock to partition_sched_domains()

From: Sebastian Andrzej Siewior

Date: Wed Aug 12 2026 - 06:12:38 EST


A read from /proc/sys/kernel/sched_rt_runtime_us leads to backtrace due
to missing cpu_hotplug_lock. 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
via before invoking any of the _cpuslocked() functions.

Acquire CPU hotplug lock before in partition_sched_domains(), before
sched_domains_mutex before the _cpuslocked() functions are invoked.

Fixes: a7660ce1590fc ("sched/cache: Fix has_multi_llcs iff at least one partition has multiple LLCs")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
kernel/sched/topology.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 622e2e01974c4..ef037d6664d98 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -3498,6 +3498,7 @@ static void partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new
void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
struct sched_domain_attr *dattr_new)
{
+ guard(cpus_read_lock)();
sched_domains_mutex_lock();
partition_sched_domains_locked(ndoms_new, doms_new, dattr_new);
sched_domains_mutex_unlock();
--
2.55.0