From: Usama Arif <usama.arif@linux.dev>
To: Chen Yu <yu.c.chen@intel.com>
Cc: Usama Arif <usama.arif@linux.dev>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
aghav@meta.com, K Prateek Nayak <kprateek.nayak@amd.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Andrea Righi <arighi@nvidia.com>,
Christian Loehle <christian.loehle@arm.com>,
James Buck <jbuck2005.linux@outlook.com>,
Tim Chen <tim.c.chen@intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/fair: Expand SIS_UTIL scan depth for small LLC system
Date: Wed, 2 Dec 2026 07:05:32 -0800 [thread overview]
Message-ID: <20261202150534.4049760-1-usama.arif@linux.dev> (raw)
In-Reply-To: <20261130081607.3814336-1-yu.c.chen@intel.com>
On Mon, 30 Nov 2026 16:16:07 +0800 Chen Yu <yu.c.chen@intel.com> wrote:
> It was reported that scanning more CPUs on a system with a small LLC
> benefits the workload more than limiting the scan depth, because
> scanning more CPUs does not cost much and work conservation is
> preferred. After commit 61ea17a63719 ("sched/fair: Add SIS_UTIL support
> to select_idle_capacity()"), James reported that one CPU-bound
> multi-threaded work on his big.LITTLE arm64 board Orange Pi 6 was
> impacted a little bit.
>
> Expand the scan depth so that systems with fewer than 32 CPUs per LLC
> behave like a 32-CPU system. This way, the scan number can be scaled up
> for such small systems.
>
> The effect is as below:
> nr_idle_scan before -> after the patch
> (LLC = 8, 12 and 16 CPUs for example)
> Cell format: util_sum : nr_scan before -> after
> Util% = util_sum / (llc_weight * 1024)
>
> Util% | LLC=8 | LLC=12 | LLC=16
> ------+------------------+------------------+------------------
> 10% | 819 : 7 -> 8 | 1228 : 11 -> 12 | 1638 : 15 -> 16
> 20% | 1638 : 7 -> 8 | 2457 : 11 -> 12 | 3276 : 15 -> 16
> 30% | 2457 : 7 -> 8 | 3686 : 10 -> 12 | 4915 : 14 -> 16
> 40% | 3276 : 6 -> 8 | 4915 : 9 -> 12 | 6553 : 12 -> 16
> 50% | 4096 : 5 -> 8 | 6144 : 7 -> 12 | 8192 : 10 -> 16
> 55% | 4505 : 4 -> 8 | 6758 : 7 -> 12 | 9011 : 9 -> 16
> 60% | 4915 : 4 -> 8 | 7372 : 6 -> 12 | 9830 : 8 -> 16
> 65% | 5324 : 3 -> 8 | 7987 : 5 -> 12 | 10649 : 6 -> 13
> 70% | 5734 : 2 -> 8 | 8601 : 3 -> 10 | 11468 : 5 -> 10
> 75% | 6144 : 1 -> 7 | 9216 : 2 -> 7 | 12288 : 3 -> 7
> 80% | 6553 : 1 -> 4 | 9830 : 1 -> 4 | 13107 : 2 -> 4
> 82% | 6717 : 0 -> 2 | 10076 : 0 -> 2 | 13434 : 1 -> 2
> 84% | 6881 : 0 -> 1 | 10321 : 0 -> 1 | 13762 : 0 -> 1
> 85% | 6963 : 0 -> 0 | 10444 : 0 -> 0 | 13926 : 0 -> 0
> 86% | 7045 : 0 -> 0 | 10567 : 0 -> 0 | 14090 : 0 -> 0
>
> With this change, the regression was gone on Orange Pi 6 and Radxa O6.
> However, this change can not deal with the performance regression on
> Usama's 72-CPU NVIDIA Grace arm64 server. More investigation needs to
> be carried out for the large asymmetric CPU system [1], considering the
> number of idle CPUs besides the utilization in SIS_UTIL, e.g.
Hello!
Thanks for the patch and also keeping Grace in mind!
Minor: the quoted sentence ends at "e.g." with nothing after it.
Confirming it doesn't change anything there: with a 72-CPU LLC,
max(llc_weight, 32) is still 72. The depth would be 0 at our load
anyway, since per-CPU utilization is ~870 (~930 with util_est).
I agree that for Grace the signal has to be idle CPUs rather than
utilization. The machines are ~92% busy, so several of the 72 CPUs are
idle at any moment; they enter idle 33K times a second even with the
scan cut off.
The kernel already tracks this for SMT: has_idle_cores is set when a
core goes idle and cleared when a scan finds none, and
select_idle_capacity() does not cut short a scan that is looking for an
idle core. Without SMT a CPU is a core, so the same hint can report an
idle CPU if update_idle_core() also runs on asym-capacity systems.
Something like the patch below (untested in production), which skips
the SIS_UTIL limit while that hint is set.
I can test below in production if the approach looks acceptable? (though
it will take some time to setup)
From: Usama Arif <usama.arif@linux.dev>
Subject: [RFC PATCH] sched/fair: Use the idle hint to bypass SIS_UTIL on !SMT asym systems
Since commit 61ea17a63719 ("sched/fair: Add SIS_UTIL support to
select_idle_capacity()"), select_idle_capacity() returns without
scanning when sd->shared->nr_idle_scan is 0. SIS_UTIL sets it to 0 once
the average utilization of the domain reaches ~85%, whatever the size
of the domain.
NVIDIA Grace (72 Neoverse V2 cores, one LLC, no SMT) takes this path:
its CPUs do not all report the same capacity, so the MC domain is
flagged SD_ASYM_CPUCAPACITY_FULL. A production workload runs
these machines at a per-CPU utilization of ~870 (~930 with util_est),
so nr_idle_scan stays at 0. Only 7% of wakeups land on an idle CPU
(69% on 6.16) and p50 request latency nearly doubles. Disabling
SIS_UTIL at runtime brings most of it back within minutes.
On a domain this large, average utilization says little about whether
a CPU is idle right now. The machines are ~92% busy, so several of the
72 CPUs are idle at any moment, and they enter idle 33K times a second
even with the scan cut off.
On SMT systems, that commit does not cut short a scan that is looking
for an idle core. That never applies without SMT, because
update_idle_core() only maintains the hint when SMT is active. Without
SMT a CPU is a core, so maintain the hint on asym-capacity systems too,
where it reports an idle CPU. While it is set, select_idle_capacity()
ignores nr_idle_scan, including the early return at 0. A scan that
finds nothing idle clears it, so a domain that is really overloaded
keeps the SIS_UTIL limit.
SMT and symmetric systems are unchanged. On !SMT asym-capacity systems
the cost is what SMT systems already pay for has_idle_cores: a read of
the shared hint on idle entry, a write when it is clear, and one full
scan each time the hint turns out to be stale.
Fixes: 61ea17a63719 ("sched/fair: Add SIS_UTIL support to select_idle_capacity()")
Reported-by: Arnav Aghav <aghav@meta.com>
Signed-off-by: Usama Arif <usama.arif@linux.dev>
---
kernel/sched/fair.c | 16 ++++++++++++++--
kernel/sched/sched.h | 20 ++++++++++++--------
2 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 731d78155e6540..55ea2329eeb897 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9062,9 +9062,11 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
/*
* On !SMT systems, has_idle_core is always false and preferred_core
* is always true (CPU == core), so the SMT preference logic below
- * collapses to the plain capacity scan.
+ * collapses to the plain capacity scan. There, update_idle_core()
+ * sets the hint whenever a CPU goes idle, so it reports an idle CPU.
*/
bool has_idle_core = sched_smt_active() && test_idle_cores(target);
+ bool has_idle_cpu = !sched_smt_active() && test_idle_cores(target);
unsigned long task_util, util_min, util_max, best_cap = 0;
int fits, best_fits = ASYM_IDLE_THREAD_MISFIT;
int cpu, best_cpu = -1;
@@ -9078,7 +9080,13 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
util_min = uclamp_eff_value(p, UCLAMP_MIN);
util_max = uclamp_eff_value(p, UCLAMP_MAX);
- if (sched_feat(SIS_UTIL) && sd->shared) {
+ /*
+ * nr_idle_scan comes from average utilization, and on a large domain
+ * it can be 0 while CPUs keep going idle. Without SMT, don't limit
+ * the scan while the hint says a CPU went idle since the last scan
+ * that found nothing.
+ */
+ if (sched_feat(SIS_UTIL) && sd->shared && !has_idle_cpu) {
/*
* Same nr_idle_scan hint as select_idle_cpu(), nr only limits
* the scan when not preferring an idle core.
@@ -9170,6 +9178,10 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
if (has_idle_core && best_fits > ASYM_IDLE_COMPLETE_MISFIT)
set_idle_cores(target, false);
+ /* Nothing was idle: fall back to nr_idle_scan until a CPU goes idle. */
+ if (has_idle_cpu && best_cpu < 0)
+ set_idle_cores(target, false);
+
return best_cpu;
}
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 32f76551a0c5e4..02ec8a6e1dec8d 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1796,14 +1796,6 @@ do { \
flags = _raw_spin_rq_lock_irqsave(rq); \
} while (0)
-extern void __update_idle_core(struct rq *rq);
-
-static inline void update_idle_core(struct rq *rq)
-{
- if (sched_smt_active())
- __update_idle_core(rq);
-}
-
#ifdef CONFIG_FAIR_GROUP_SCHED
static inline struct task_struct *task_of(struct sched_entity *se)
{
@@ -2326,6 +2318,18 @@ static __always_inline bool sched_asym_cpucap_active(void)
return static_branch_unlikely(&sched_asym_cpucapacity);
}
+extern void __update_idle_core(struct rq *rq);
+
+/*
+ * Without SMT a CPU is a core, so on asym-capacity systems the idle-core
+ * hint reports an idle CPU; select_idle_capacity() relies on it.
+ */
+static inline void update_idle_core(struct rq *rq)
+{
+ if (sched_smt_active() || sched_asym_cpucap_active())
+ __update_idle_core(rq);
+}
+
struct sched_group_capacity {
atomic_t ref;
/*
--
2.53.1-Meta
> Since Intel servers usually have >= 32 CPUs per LLC, this change does
> not impact Intel servers much. AMD servers have 16 CPUs per CCX, testing
> on AMD Milan showed no significant difference on redis/mysql, and a slight
> improvement on hackbench/schbench:
>
> =========================================
> hackbench threads+pipe
> num_runs: 5
> host: AMD-Milan
> kernel: 7.4.0-rc4-sis-patched+
> =========================================
> G FD | baseline s/se% | patched s/se% | SPEEDUP | RESULT
> ------------------------------------------------------------------
> 1 1 | 6.352/ 7.57% | 5.680/ 5.74% | 1.12x | noise
> 1 2 | 6.225/ 8.75% | 5.624/ 7.27% | 1.11x | noise
> 1 4 | 8.834/10.23% | 8.799/10.24% | 1.00x | noise
> 1 8 | 4.833/ 1.70% | 5.060/ 1.72% | 0.96x | noise
> 1 16 | 5.471/ 1.61% | 5.551/ 0.60% | 0.99x | noise
> 1 20 | 5.220/ 1.17% | 5.298/ 0.82% | 0.99x | noise
> 2 1 | 5.558/ 6.23% | 6.114/ 8.63% | 0.91x | noise
> 2 2 | 8.056/10.44% | 8.029/12.53% | 1.00x | noise
> 2 4 | 5.292/ 1.26% | 5.152/ 1.89% | 1.03x | noise
> 2 8 | 5.493/ 2.15% | 5.403/ 3.38% | 1.02x | noise
> 2 16 | 5.557/ 1.68% | 5.407/ 0.88% | 1.03x | noise
> 2 20 | 5.224/ 0.68% | 5.341/ 1.19% | 0.98x | noise
> 4 1 | 6.047/ 2.89% | 5.797/ 4.41% | 1.04x | noise
> 4 2 | 5.597/ 2.19% | 5.791/ 1.77% | 0.97x | noise
> 4 4 | 5.397/ 1.62% | 5.501/ 1.18% | 0.98x | noise
> 4 8 | 5.468/ 2.67% | 5.155/ 0.95% | 1.06x | IMPROVED
> 4 16 | 5.989/ 3.31% | 5.507/ 1.36% | 1.09x | IMPROVED
> 4 20 | 5.267/ 0.79% | 5.101/ 0.60% | 1.03x | IMPROVED
> 8 1 | 5.322/ 3.12% | 5.273/ 1.96% | 1.01x | noise
> 8 2 | 5.531/ 2.38% | 5.367/ 1.64% | 1.03x | noise
> 8 4 | 5.672/ 0.70% | 5.814/ 2.60% | 0.98x | noise
> 8 8 | 5.037/ 0.93% | 5.100/ 0.97% | 0.99x | noise
> 8 16 | 5.455/ 0.45% | 5.290/ 0.39% | 1.03x | IMPROVED
> 8 20 | 5.388/ 0.36% | 5.285/ 0.18% | 1.02x | IMPROVED
> 16 1 | 5.519/ 2.49% | 5.296/ 2.10% | 1.04x | noise
> 16 2 | 5.398/ 0.77% | 5.503/ 3.05% | 0.98x | noise
> 16 4 | 5.274/ 1.72% | 5.363/ 1.72% | 0.98x | noise
> 16 8 | 5.416/ 0.37% | 5.185/ 0.20% | 1.04x | IMPROVED
> 16 16 | 5.596/ 0.41% | 5.337/ 0.24% | 1.05x | IMPROVED
> 16 20 | 5.292/ 0.88% | 5.076/ 0.55% | 1.04x | IMPROVED
>
> redis (redis-benchmark -t set)
> =========================================
> THR | baseline rps/se% | patched rps/se% | SPEEDUP | p99 ms b/p | RESULT
> -----------------------------------------------------------------------
> 4 | 1492165/ 0.76% | 1480823/ 0.00% | 0.992x | 0.541 0.546 | noise
> 8 | 1665556/ 0.01% | 1665501/ 0.00% | 1.000x | 0.490 0.489 | noise
> 16 | 984279/ 0.60% | 974545/ 0.00% | 0.990x | 1.124 1.109 | noise
> 32 | 887091/ 0.01% | 883212/ 0.44% | 0.996x | 1.713 1.721 | noise
>
> mysql
> =========================================
> THR | baseline tps/se% | patched tps/se% | SPEEDUP | p95 ms b/p | RESULT
> -----------------------------------------------------------------------
> 8 | 151897/ 0.76% | 152428/ 0.54% | 1.003x | 0.07 0.08 | noise
> 16 | 294014/ 0.59% | 296699/ 0.28% | 1.009x | 0.07 0.07 | noise
> 32 | 386817/ 2.18% | 377835/ 0.31% | 0.977x | 0.09 0.09 | noise
> 64 | 560950/16.97% | 481494/ 5.68% | 0.858x | 0.19 0.23 | noise
> 128 | 752079/ 4.92% | 729685/ 3.89% | 0.970x | 0.36 0.38 | noise
> 256 | 772771/ 0.62% | 771630/ 0.21% | 0.999x | 0.79 0.78 | noise
>
> schbench
> =========================================
> T WRK METRIC | baseline/se% | patched/se% | SPEEDUP | RESULT
> -----------------------------------------------------------------------
> 2 8 rps | 1683.8/ 0.04% | 1681.3/ 0.10% | 0.999x | noise
> 2 8 wake_p99 | 10.2/ 1.96% | 9.8/ 3.82% | 1.041x | noise
> 2 8 req_p99 | 4904.0/ 0.00% | 4904.0/ 0.00% | 1.000x | noise
> 4 16 rps | 3369.0/ 0.03% | 3353.9/ 0.44% | 0.996x | noise
> 4 16 wake_p99 | 10.0/ 0.00% | 10.0/ 0.00% | 1.000x | noise
> 4 16 req_p99 | 4904.0/ 0.00% | 4904.0/ 0.00% | 1.000x | noise
> 8 32 rps | 6724.6/ 0.04% | 6722.0/ 0.16% | 1.000x | noise
> 8 32 wake_p99 | 9.8/ 2.04% | 10.0/ 0.00% | 0.980x | noise
> 8 32 req_p99 | 4904.0/ 0.00% | 4904.0/ 0.00% | 1.000x | noise
> 16 64 rps | 10933.0/ 4.10% | 11179.8/ 1.80% | 1.023x | noise
> 16 64 wake_p99 | 12.0/ 0.00% | 12.0/ 0.00% | 1.000x | noise
> 16 64 req_p99 | 10051.2/ 0.13% | 10051.2/ 0.08% | 1.000x | noise
> 24 96 rps | 12970.1/ 0.22% | 12971.0/ 0.48% | 1.000x | noise
> 24 96 wake_p99 | 13.4/ 3.81% | 12.4/ 1.98% | 1.081x | noise
> 24 96 req_p99 | 10179.2/ 0.21% | 10185.6/ 0.21% | 0.999x | noise
> 32 128 rps | 12613.1/ 0.09% | 12667.2/ 0.11% | 1.004x | IMPROVED
> 32 128 wake_p99 | 37.2/ 3.55% | 34.2/ 1.43% | 1.088x | IMPROVED
> 32 128 req_p99 | 10467.2/ 0.59% | 10358.4/ 0.06% | 1.011x | noise
>
> Link: https://lore.kernel.org/all/20261113153157.2495664-1-usama.arif@linux.dev/ #1
>
> Fixes: 61ea17a63719 ("sched/fair: Add SIS_UTIL support to select_idle_capacity()")
> Reported-by: James Buck <jbuck2005.linux@outlook.com>
> Closes: https://lore.kernel.org/lkml/CY5P221MB09262B7D6A68954CC1B3199FBD442@CY5P221MB0926.NAMP221.PROD.OUTLOOK.COM/
> Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> Tested-by: James Buck <jbuck2005.linux@outlook.com>
> Tested-by: Vincent Guittot <vincent.guittot@linaro.org>
> Tested-by: Christian Loehle <christian.loehle@arm.com>
> Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
> Reviewed-by: Christian Loehle <christian.loehle@arm.com>
> ---
> kernel/sched/fair.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index da0d9e19c457..15ddfce49cb7 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -12936,9 +12936,16 @@ static void update_idle_cpu_scan(struct lb_env *env,
> tmp = min_t(long, tmp, SCHED_CAPACITY_SCALE);
> y = SCHED_CAPACITY_SCALE - tmp;
>
> - /* equation [2] */
> - y *= llc_weight;
> + /*
> + * equation [2]
> + * Scanning a small LLC is cheap, work conservation is
> + * preferred over limiting the scan depth. Treat a small
> + * LLC as if it had 32 CPUs, then the number of CPUs suggested
> + * by SIS_UTIL is scaled up for small LLCs.
> + */
> + y *= max(llc_weight, 32);
> do_div(y, SCHED_CAPACITY_SCALE);
> + y = min_t(u64, y, llc_weight);
> if ((int)y != sd_share->nr_idle_scan)
> WRITE_ONCE(sd_share->nr_idle_scan, (int)y);
> }
> --
> 2.25.1
>
>
prev parent reply other threads:[~2026-12-02 15:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 8:16 Chen Yu
2026-11-30 9:20 ` Andrea Righi
2026-12-01 13:25 ` Chen Yu
2026-11-30 10:28 ` K Prateek Nayak
2026-12-01 13:28 ` Chen Yu
2026-12-01 8:29 ` Li kunyu
2026-12-01 13:50 ` Chen Yu
2026-12-02 2:17 ` Li kunyu
2026-12-02 15:05 ` Usama Arif [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=20261202150534.4049760-1-usama.arif@linux.dev \
--to=usama.arif@linux.dev \
--cc=aghav@meta.com \
--cc=arighi@nvidia.com \
--cc=christian.loehle@arm.com \
--cc=jbuck2005.linux@outlook.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tim.c.chen@intel.com \
--cc=vincent.guittot@linaro.org \
--cc=yu.c.chen@intel.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®