[PATCH v2 3/3] sched/fair: Avoid re-syncing runtime_enabled on root domain changes
From: Qiliang Yuan
Date: Wed Nov 18 2026 - 19:57:57 EST
rq_online_fair() calls update_runtime_enabled(), which walks every task
group and takes each group's cfs_bandwidth lock to copy its quota state
into the CPU's cfs_rq. A sched domain rebuild reaches it for every
active CPU through rq_attach_root(), with the rq lock held and
interrupts disabled.
The walk is only needed when the CPU comes up. While a CPU is online,
tg_set_cfs_bandwidth() updates runtime_enabled on it under the rq lock,
and it holds cpus_read_lock() so it cannot miss a CPU that is coming up.
Call update_runtime_enabled() only when the CPU comes up.
With 4000 cpu cgroups on a 32-CPU VM booted with rt_group_sched=0,
switching a 4-CPU cpuset to a partition root and offlining or onlining
one CPU take (median of 20 partition switches and 16 hotplug operations):
operation before (ms) after (ms) change
partition root 8.35 1.20 -86%
cpu offline 33.91 16.49 -51%
cpu online 31.02 12.87 -59%
Signed-off-by: Qiliang Yuan <qiliang.yuan@xxxxxxxxx>
---
kernel/sched/fair.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 1b38c4c47b656..e42c70e6ebeff 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -15082,7 +15082,9 @@ static void rq_online_fair(struct rq *rq, bool hotplug)
{
update_sysctl();
- update_runtime_enabled(rq);
+ /* tg_set_cfs_bandwidth() keeps an online CPU in sync */
+ if (hotplug)
+ update_runtime_enabled(rq);
}
static void rq_offline_fair(struct rq *rq, bool hotplug)
--
2.43.0