From: Qiliang Yuan <qiliang.yuan@linux.dev>
To: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>
Cc: linux-kernel@vger.kernel.org, Qiliang Yuan <qiliang.yuan@linux.dev>
Subject: [PATCH v2 3/3] sched/fair: Avoid re-syncing runtime_enabled on root domain changes
Date: Wed, 18 Nov 2026 19:57:23 -0500 [thread overview]
Message-ID: <20261118-bug-sched-fair-offline-active-v2-3-b6ede596c6a6@linux.dev> (raw)
In-Reply-To: <20261118-bug-sched-fair-offline-active-v2-0-b6ede596c6a6@linux.dev>
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@linux.dev>
---
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
prev parent reply other threads:[~2026-11-19 0:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 0:57 [PATCH v2 0/3] sched/fair: Cut per-group work from sched domain rebuilds Qiliang Yuan
2026-11-19 0:57 ` [PATCH v2 1/3] sched: Tell rq_online() and rq_offline() whether the CPU changes state Qiliang Yuan
2026-11-19 0:57 ` [PATCH v2 2/3] sched/fair: Skip rq_offline_fair() work for CPUs that stay active Qiliang Yuan
2026-11-19 0:57 ` Qiliang Yuan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118-bug-sched-fair-offline-active-v2-3-b6ede596c6a6@linux.dev \
--to=qiliang.yuan@linux.dev \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®