From: Tejun Heo <tj@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Xuewen Yan <xuewen.yan@unisoc.com>,
mingo@redhat.com, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, lukasz.luba@arm.com,
linux-kernel@vger.kernel.org, rui.zhang@intel.com,
di.shen@unisoc.com, ke.wang@unisoc.com, xuewen.yan94@gmail.com
Subject: Re: [RFC PATCH] sched: Add scx_cpuperf_target in sched_cpu_util()
Date: Wed, 18 Mar 2026 15:08:43 -1000 [thread overview]
Message-ID: <abtMmzntD4XCrG2M@slm.duckdns.org> (raw)
In-Reply-To: <20260318124718.GC3738786@noisy.programming.kicks-ass.net>
On Wed, Mar 18, 2026 at 01:47:18PM +0100, Peter Zijlstra wrote:
> On Wed, Mar 18, 2026 at 08:17:55PM +0800, Xuewen Yan wrote:
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index bf948db905ed..20adb6fede2a 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -8198,7 +8198,12 @@ unsigned long effective_cpu_util(int cpu, unsigned long util_cfs,
> >
> > unsigned long sched_cpu_util(int cpu)
> > {
> > - return effective_cpu_util(cpu, cpu_util_cfs(cpu), NULL, NULL);
> > + unsigned long util = scx_cpuperf_target(cpu);
> > +
> > + if (!scx_switched_all())
> > + util += cpu_util_cfs(cpu);
> > +
> > + return effective_cpu_util(cpu, util, NULL, NULL);
> > }
>
> This puts the common case of no ext muck into the slow path of that
> static_branch.
>
> This wants to be something like:
>
> unsigned long sched_cpu_util(int cpu)
> {
> unsigned long util = cpu_util_cfs(cpu);
>
> if (scx_enabled()) {
> unsigned long scx_util = scx_cpuperf_target(cpu);
>
> if (!scx_switched_all())
> scx_util += util;
>
> util = scx_util;
> }
>
> return effective_cpu_util(cpu, util, NULL, NULL);
> }
scx_switched_all() is an unlikely static branch just like scx_enabled() and
scx_cpuperf_target() has scx_enabled() in it too, so the difference for the
fair path between the two versions is two noop run-throughs vs. one. Either
way is fine but it is more code for likely no discernible gain.
Thanks.
--
tejun
next prev parent reply other threads:[~2026-03-19 1:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 12:17 [RFC PATCH] sched: Add scx_cpuperf_target in sched_cpu_util() Xuewen Yan
2026-03-18 12:47 ` Peter Zijlstra
2026-03-18 12:55 ` Vincent Guittot
2026-03-18 13:44 ` Qais Yousef
2026-03-19 2:13 ` Xuewen Yan
2026-03-19 7:09 ` Vincent Guittot
2026-03-19 10:18 ` Lukasz Luba
2026-03-24 1:32 ` Qais Yousef
2026-03-18 13:03 ` [PATCH] sched/cpufreq: Reorder so non-SCX is common path Christian Loehle
2026-03-19 1:08 ` Tejun Heo [this message]
2026-03-19 2:24 ` [RFC PATCH] sched: Add scx_cpuperf_target in sched_cpu_util() Xuewen Yan
2026-03-19 2:38 ` Xuewen Yan
2026-03-19 9:02 ` Peter Zijlstra
2026-03-19 10:01 ` Uros Bizjak
2026-03-19 10:26 ` Peter Zijlstra
2026-03-19 11:02 ` Uros Bizjak
2026-03-19 11:12 ` Peter Zijlstra
2026-03-19 11:19 ` Uros Bizjak
2026-03-19 11:33 ` Peter Zijlstra
2026-03-19 11:22 ` Peter Zijlstra
2026-03-18 12:54 ` Christian Loehle
2026-03-19 1:21 ` Tejun Heo
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=abtMmzntD4XCrG2M@slm.duckdns.org \
--to=tj@kernel.org \
--cc=bsegall@google.com \
--cc=di.shen@unisoc.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=ke.wang@unisoc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rui.zhang@intel.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=xuewen.yan94@gmail.com \
--cc=xuewen.yan@unisoc.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