The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Chen Yu <yu.c.chen@intel.com>
To: Vincent Guittot <vincent.guittot@linaro.org>,
	James Buck <jbuck2005.linux@outlook.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>,
	Andrea Righi <arighi@nvidia.com>,
	James Buck <jbuck2005.linux@outlook.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Valentin Schneider <vschneid@redhat.com>,
	Usama Arif <usama.arif@linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"regressions@lists.linux.dev" <regressions@lists.linux.dev>
Subject: Re: [REGRESSION] sched/fair: SIS_UTIL limit in select_idle_capacity() leaves busy tasks on little CPUs while big CPUs are idle
Date: Fri, 27 Nov 2026 17:14:00 +0800	[thread overview]
Message-ID: <awlJ2Fp94knZQDxS@chenyu-dev> (raw)
In-Reply-To: <CAKfTPtCukFOD6nKD6oDYvjEiXXUY5fHui4w6fgnhNw+jpE=0RA@mail.gmail.com>

On Wed, Nov 25, 2026 at 03:27:46PM +0100, Vincent Guittot wrote:
> On Wed, 25 Nov 2026 at 11:38, Chen Yu <yu.c.chen@intel.com> wrote:
> >
> > On Wed, Nov 25, 2026 at 08:51:39AM +0100, Vincent Guittot wrote:
> > > On Wed, 25 Nov 2026 at 03:53, K Prateek Nayak <kprateek.nayak@amd.com> wrote:
> > > >
> > > > Hello Andrea,
> > > >
> > > > On 11/24/2026 6:45 PM, Andrea Righi wrote:
> > > > > Hi James,
> > > > >
> > > > > On Tue, Nov 24, 2026 at 11:56:52AM +0000, James Buck wrote:
> > > > >> Hi,
> > > > >>
> > > > >> Since commit 61ea17a63719 ("sched/fair: Add SIS_UTIL support to select_idle_capacity()"), first in v7.2, CPU-bound multi-threaded work on my big.LITTLE arm64 board runs 12-19% slower than on v7.1 and earlier, because waking threads are placed on idle little CPUs while idle big CPUs are never looked at.
> > > > >>
> > > > >> Turning SIS_UTIL off at runtime restores the old speed. select_idle_capacity() and update_idle_cpu_scan() are unchanged in v7.4-rc4, so I expect mainline to behave the same.
> > > > >
> > > > > A related regression from the same commit was reported by Usama here:
> > > > > https://lore.kernel.org/r/20261113153157.2495664-1-usama.arif@linux.dev/
> > > > >
> > > > > On Grace, a zero SIS_UTIL budget skips the search despite suitable CPUs
> > > > > being idle. Your case shows that a nonzero budget can stop the scan
> > > > > before reaching an idle big CPU.
> > > > >
> > > > > We've discussed a minimum scan budget and accounting for idle CPU
> > > > > availability, though a small minimum alone may not fix your case.
> > > >
> > > > This had problems in the past when Chenyu was iterating on SIS_UTIL
> > > > where the search opportunity at higher utilization is actually very
> > > > low and cutting off search for !idle core was beneficial for SMT
> > > > systems.
> > > >
> > > > Now, for systems without SMT, it has its benefits too but a system
> > > > without SMT should be equivalent to a SMT one where test_idle_core()
> > > > returns true always if an idle CPU is present.
> > > >
> > > > So I'm wondering if {set,test}_idle_cores() can be extended !SMT
> > > > to act like a gating indicator to say if an idle core exists or
> > > > not much like how !get_rd_overloaded(this_rq->rd) serves as a
> > > > gate for newidle balance - it can be flipped to true when a CPU
> > > > goes idle or if load balancer sees an idle CPU. Thoughts?
> > >
> > > I tested idle_cores tracking for !SMT and EAS months ago [1]
> > > [1] https://lore.kernel.org/all/20251202181242.1536213-6-vincent.guittot@linaro.org/
> > >
> > > >
> > > > > Given both reports, reverting the commit seems the safest thing to do
> > > > > for now. That would restore the previous asym search behavior and we can
> > > > > revisit a better consistent strategy to cover both sym and asym CPU
> > > > > selection later.
> > > > >
> > > > > Prateek, Vincent, what do you think?
> > > >
> > > > IMO it still makes sense for SMT systems since capacity on systems
> > > > with SMT only makes sense if the entire core is idle and then it is
> > > > just a best effort thing right?
> > > >
> > > > set_idle_cores(), would flip the flag as soon as an idle core is
> > > > available and after that SIS_UTIL is bypassed. I don't think the
> > > > SIS_UTIL cut-off for non-SMT ASYM_CAPACITY systems makes that much
> > > > sense given misfit penalty is much higher.
> > >
> > > In fact that depends on the number of CPUs in your LLC.
> > > The current SIS_UTIL is unfair for small system because you skip the
> > > loop with "low" utilization:
> > > - with 12 cores per LLC, you skip the loop if the avg utilization per
> > > cpu is above 839 whereas it also means that you have the compute
> > > capacity of more than 2 CPUs that is not used and util_est can worse
> > > the situation
> > > - but with 64 cores LLC, you still tries 5 CPUs for the same avg
> > > utilization per CPU
> > > - and with 12864 cores LLC, it's 10 CPUs
> > >
> > >
> >
> > As you suggested in [1], maybe we can give a floor value of 3 when has_idle_core
> > is true both for SMT and !SMT case(mainly for nr_scan = 0 case). Besides, we can
> > scale up the number of CPUs to be scanned by their llc_weight, to fake
> > a 32 CPUs LLC for the small LLC system, this should mitigate
> > the issue of current report and the issue reported at [1].
> 
> This fixes the regression on my radxa O6 by keeping nr_idle_scan full
> for llc smaller than 32 CPUs while the avg utilization per CPU is
> below ~550
>

Thanks Vincent, James for testing.
Let me post this as a formal patch with some test data, mainly with
the AMD server's data, because I only have some Intel servers and one
AMD server, and this patch might impact AMD more than Intel.

Besides, for Usama's 72-CPU NVIDIA Grace arm64 server, it seems that
the above patch cannot deal with it, as we only cure the system with
<= 32 CPUs per LLC. Inspired by Andrea, I wonder if we can
leverage the number of idle CPUs together with SIS_UTIL to decide the
search depth. In summary, the more idle CPUs there are, the more we
should try to scan. Given a fixed lower limit 3 or 4 might not fully recover
the performance on Grace I'm afraid, because there are up to 72 CPUs in a LLC.

This can be seen as an extension of has_idle_cores to non-SMT systems.
Unlike has_idle_cores, which makes the wakeup path ignore the SIS_UTIL
hint entirely, the number of idle CPUs is only used as a floor of the
scan depth, so the SIS_UTIL hint is still respected in general, which
is a trade-off to not break other platform/workloads.

I'm also wondering if the system supports the cluster domain, the
has_idle_cores calculation can be extended to the cluster level, so that
a fully idle cluster lets the wakeup path ignore the SIS_UTIL hint for better
work conservation.

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 1c0e2ac7751d..079d1fc06344 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -12874,8 +12874,11 @@ sched_balance_find_dst_group(struct sched_domain *sd, struct task_struct *p, int
 	return idlest;
 }
 
+#define SIS_UTIL_IDLE_MIN	2
+
 static void update_idle_cpu_scan(struct lb_env *env,
-				 unsigned long sum_util)
+				 unsigned long sum_util,
+				 unsigned int nr_idle)
 {
 	struct sched_domain_shared *sd_share;
 	struct sched_domain *sd = env->sd;
@@ -12940,6 +12943,10 @@ static void update_idle_cpu_scan(struct lb_env *env,
 	y *= max(llc_weight, 32);
 	do_div(y, SCHED_CAPACITY_SCALE);
 	y = min_t(u64, y, llc_weight);
+
+	if (nr_idle > SIS_UTIL_IDLE_MIN)
+		y = max_t(u64, y, nr_idle);
+
 	if ((int)y != sd_share->nr_idle_scan)
 		WRITE_ONCE(sd_share->nr_idle_scan, (int)y);
 }
@@ -12956,6 +12963,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd
 	struct sg_lb_stats *local = &sds->local_stat;
 	struct sg_lb_stats tmp_sgs;
 	unsigned long sum_util = 0;
+	unsigned int nr_idle = 0;
 	bool sg_overloaded = 0, sg_overutilized = 0;
 
 	env->dst_core_idle = !sched_smt_active() || is_core_idle(env->dst_cpu);
@@ -12988,6 +12996,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd
 		sds->total_capacity += sgs->group_capacity;
 
 		sum_util += sgs->group_util;
+		nr_idle += sgs->idle_cpus;
 		sg = sg->next;
 	} while (sg != env->sd->groups);
 
@@ -13013,7 +13022,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd
 		set_rd_overutilized(env->dst_rq->rd, sg_overutilized);
 	}
 
-	update_idle_cpu_scan(env, sum_util);
+	update_idle_cpu_scan(env, sum_util, nr_idle);
 }
 
 /**
-- 
2.25.1


  parent reply	other threads:[~2026-11-27  9:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 11:56 [REGRESSION] sched/fair: SIS_UTIL limit in select_idle_capacity() leaves busy tasks on little CPUs while big CPUs are idle James Buck
2026-11-24 13:15 ` Andrea Righi
2026-11-25  2:53   ` K Prateek Nayak
2026-11-25  7:51     ` Vincent Guittot
2026-11-25 10:27       ` Chen Yu
2026-11-25 14:27         ` Vincent Guittot
2026-11-25 22:06           ` James Buck
2026-11-27  9:14           ` Chen Yu [this message]
2026-11-24 15:18 ` Vincent Guittot
2026-11-24 18:41   ` Christian Loehle

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=awlJ2Fp94knZQDxS@chenyu-dev \
    --to=yu.c.chen@intel.com \
    --cc=arighi@nvidia.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=jbuck2005.linux@outlook.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=regressions@lists.linux.dev \
    --cc=usama.arif@linux.dev \
    --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