The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [REGRESSION] sched/fair: SIS_UTIL limit in select_idle_capacity() leaves busy tasks on little CPUs while big CPUs are idle
@ 2026-11-24 11:56 James Buck
  2026-11-24 13:15 ` Andrea Righi
  0 siblings, 1 reply; 2+ messages in thread
From: James Buck @ 2026-11-24 11:56 UTC (permalink / raw)
  To: K Prateek Nayak, Andrea Righi
  Cc: Peter Zijlstra, Ingo Molnar, Vincent Guittot, Juri Lelli,
	Dietmar Eggemann, Valentin Schneider,
	linux-kernel@vger.kernel.org, regressions@lists.linux.dev

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.

#regzbot introduced: 61ea17a63719

System
------
Orange Pi 6 (CIX CD8180 "Sky1"), 12 CPUs in five clusters, ACPI boot, no SMT:
  
CPUs     capacity
0-1       1024  
2-5         279   (little)
6-7         905
8-9         866
10-11     984

The firmware's PPTT gives one MC domain over all 12 CPUs. It has SD_ASYM_CPUCAPACITY(_FULL) and SD_SHARE_LLC, with a CLS domain per cluster below it. The kernel is v7.3.5 plus the out-of-tree Sky1 SoC
driver patches the board needs to boot. None of them touch kernel/sched/; the only one in drivers/base/arch_topology.c adds a helper that updates capacity_freq_ref when boost is toggled.

Workload
--------
llama.cpp llama-bench, Qwen2.5 1.5B Instruct Q4_K_M, CPU only, 8 threads, pp512 / tg128, tokens/s:
  
6.18.64                           123.5 / 36.5
7.3.5                               109.0 / 29.5
  
7.3.5, taskset to the 8 big CPUs   121.4 / 34.7
7.3.5, NO_SIS_UTIL at runtime     122.1 / 35.9
7.3.5, patch below                       121.7 / 35.7

Sampling each worker thread's CPU every 5 s on stock 7.3.5 showed one to four of the 8 threads on cpu2-5 in every sample, with big CPUs idle. With NO_SIS_UTIL, or with the patch below, threads only make brief visits to the little CPUs. That costs nothing measurable, and 6.18 does the same. llama.cpp syncs all threads at a barrier after every operation, so one thread on a 279-capacity CPU holds up the other seven.

Other things I ruled out with runtime toggles or test builds: EAS off, llc_balancing off, the performance governor, NI_RATE/NI_RANDOM, the 6.18 misfit logic, and restoring the old sd_init() rule that cleared SD_PREFER_SIBLING on the child of an asymmetric domain. None of them changed the result. The slowdown only shows when prompt processing is part of the run, where the workers block and wake far more often than during generation, which points at the wakeup path.

What I think happens
--------------------
The workers' util is about 850-1018, so they fit no CPU, not even a 1024 one (the limit there is about 819). select_idle_capacity() therefore never returns early. It returns the highest-capacity idle CPU among those it scanned. 

With 8 of 12 CPUs busy, nr_idle_scan comes out at about 6:
  
x = 7200 / 12 = 600
y = 1024 - 600^2 * 117^2 / (10000 * 1024) = ~543

nr = 12 * 543 / 1024 = ~6

So the scan stops after six CPUs counted from target. From cpu0 that is cpu0-5. With cpu0 and cpu1 busy, the best idle CPU it can see is a little one, and the idle cpu6-11 are never checked. From cpu10 the scan covers 10, 11, 0, 1, 2 and 3, with the same result. Once a thread is on a little CPU, its next scan starts there, so it tends to stay.
Above about 85% load nr drops to 1 and the function returns -1 at once.

The CPU numbering here (littles between two groups of bigs) makes it easy to hit. But the effect looks general: for a task that fits no CPU, a scan cut short by nr returns the best of a partial set. On a system with the littles at 0-3 and the bigs at 4-7, a wakeup with target on a little CPU and nr <= 4 sees only little CPUs.

The patch below (drop the limit from select_idle_capacity() only; select_idle_cpu() keeps SIS_UTIL) is what I run now.

I'm not proposing it as the fix, since it gives up what the commit wanted on large asymmetric domains.

One option might be to keep scanning past nr while nothing has been found that fits. I'm happy to test anything on this board, and I can send the topology and sched domain dumps, /proc/schedstat, or traces if they help.

Thanks,
James



--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9049,7 +9049,6 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
 	int fits, best_fits = ASYM_IDLE_THREAD_MISFIT;
 	int cpu, best_cpu = -1;
 	struct cpumask *cpus;
-	int nr = INT_MAX;
 
 	cpus = this_cpu_cpumask_var_ptr(select_rq_mask);
 	cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr);
@@ -9058,28 +9057,17 @@ 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) {
-		/*
-		 * Same nr_idle_scan hint as select_idle_cpu(), nr only limits
-		 * the scan when not preferring an idle core.
-		 */
-		nr = READ_ONCE(sd->shared->nr_idle_scan) + 1;
-		/* overloaded domain is unlikely to have idle cpu/core */
-		if (nr == 1)
-			return -1;
-	}
-
+	/*
+	 * Scan the whole domain, as 6.18 did. Do not cut the scan short with
+	 * the SIS_UTIL nr_idle_scan hint: on a busy system the hint drops to a
+	 * few CPUs, the scan then stops at whatever idle CPU it met first, and
+	 * a task that fits no CPU (util above every capacity margin) lands on
+	 * an idle little core while an idle big core is never looked at.
+	 */
 	for_each_cpu_wrap(cpu, cpus, target) {
 		bool preferred_core = !has_idle_core || is_core_idle(cpu);
 		unsigned long cpu_cap = capacity_of(cpu);
 
-		/*
-		 * Stop when the nr_idle_scan is exhausted (mirrors
-		 * select_idle_cpu() logic).
-		 */
-		if (!has_idle_core && --nr <= 0)
-			return best_cpu;
-
 		if (!choose_idle_cpu(cpu, p))
 			continue;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [REGRESSION] sched/fair: SIS_UTIL limit in select_idle_capacity() leaves busy tasks on little CPUs while big CPUs are idle
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Andrea Righi @ 2026-11-24 13:15 UTC (permalink / raw)
  To: James Buck
  Cc: K Prateek Nayak, Peter Zijlstra, Ingo Molnar, Vincent Guittot,
	Juri Lelli, Dietmar Eggemann, Valentin Schneider, Usama Arif,
	linux-kernel@vger.kernel.org, regressions@lists.linux.dev

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.

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?

Thanks,
-Andrea

> 
> #regzbot introduced: 61ea17a63719
> 
> System
> ------
> Orange Pi 6 (CIX CD8180 "Sky1"), 12 CPUs in five clusters, ACPI boot, no SMT:
>   
> CPUs     capacity
> 0-1       1024  
> 2-5         279   (little)
> 6-7         905
> 8-9         866
> 10-11     984
> 
> The firmware's PPTT gives one MC domain over all 12 CPUs. It has SD_ASYM_CPUCAPACITY(_FULL) and SD_SHARE_LLC, with a CLS domain per cluster below it. The kernel is v7.3.5 plus the out-of-tree Sky1 SoC
> driver patches the board needs to boot. None of them touch kernel/sched/; the only one in drivers/base/arch_topology.c adds a helper that updates capacity_freq_ref when boost is toggled.
> 
> Workload
> --------
> llama.cpp llama-bench, Qwen2.5 1.5B Instruct Q4_K_M, CPU only, 8 threads, pp512 / tg128, tokens/s:
>   
> 6.18.64                           123.5 / 36.5
> 7.3.5                               109.0 / 29.5
>   
> 7.3.5, taskset to the 8 big CPUs   121.4 / 34.7
> 7.3.5, NO_SIS_UTIL at runtime     122.1 / 35.9
> 7.3.5, patch below                       121.7 / 35.7
> 
> Sampling each worker thread's CPU every 5 s on stock 7.3.5 showed one to four of the 8 threads on cpu2-5 in every sample, with big CPUs idle. With NO_SIS_UTIL, or with the patch below, threads only make brief visits to the little CPUs. That costs nothing measurable, and 6.18 does the same. llama.cpp syncs all threads at a barrier after every operation, so one thread on a 279-capacity CPU holds up the other seven.
> 
> Other things I ruled out with runtime toggles or test builds: EAS off, llc_balancing off, the performance governor, NI_RATE/NI_RANDOM, the 6.18 misfit logic, and restoring the old sd_init() rule that cleared SD_PREFER_SIBLING on the child of an asymmetric domain. None of them changed the result. The slowdown only shows when prompt processing is part of the run, where the workers block and wake far more often than during generation, which points at the wakeup path.
> 
> What I think happens
> --------------------
> The workers' util is about 850-1018, so they fit no CPU, not even a 1024 one (the limit there is about 819). select_idle_capacity() therefore never returns early. It returns the highest-capacity idle CPU among those it scanned. 
> 
> With 8 of 12 CPUs busy, nr_idle_scan comes out at about 6:
>   
> x = 7200 / 12 = 600
> y = 1024 - 600^2 * 117^2 / (10000 * 1024) = ~543
> 
> nr = 12 * 543 / 1024 = ~6
> 
> So the scan stops after six CPUs counted from target. From cpu0 that is cpu0-5. With cpu0 and cpu1 busy, the best idle CPU it can see is a little one, and the idle cpu6-11 are never checked. From cpu10 the scan covers 10, 11, 0, 1, 2 and 3, with the same result. Once a thread is on a little CPU, its next scan starts there, so it tends to stay.
> Above about 85% load nr drops to 1 and the function returns -1 at once.
> 
> The CPU numbering here (littles between two groups of bigs) makes it easy to hit. But the effect looks general: for a task that fits no CPU, a scan cut short by nr returns the best of a partial set. On a system with the littles at 0-3 and the bigs at 4-7, a wakeup with target on a little CPU and nr <= 4 sees only little CPUs.
> 
> The patch below (drop the limit from select_idle_capacity() only; select_idle_cpu() keeps SIS_UTIL) is what I run now.
> 
> I'm not proposing it as the fix, since it gives up what the commit wanted on large asymmetric domains.
> 
> One option might be to keep scanning past nr while nothing has been found that fits. I'm happy to test anything on this board, and I can send the topology and sched domain dumps, /proc/schedstat, or traces if they help.
> 
> Thanks,
> James
> 
> 
> 
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9049,7 +9049,6 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
>  	int fits, best_fits = ASYM_IDLE_THREAD_MISFIT;
>  	int cpu, best_cpu = -1;
>  	struct cpumask *cpus;
> -	int nr = INT_MAX;
>  
>  	cpus = this_cpu_cpumask_var_ptr(select_rq_mask);
>  	cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr);
> @@ -9058,28 +9057,17 @@ 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) {
> -		/*
> -		 * Same nr_idle_scan hint as select_idle_cpu(), nr only limits
> -		 * the scan when not preferring an idle core.
> -		 */
> -		nr = READ_ONCE(sd->shared->nr_idle_scan) + 1;
> -		/* overloaded domain is unlikely to have idle cpu/core */
> -		if (nr == 1)
> -			return -1;
> -	}
> -
> +	/*
> +	 * Scan the whole domain, as 6.18 did. Do not cut the scan short with
> +	 * the SIS_UTIL nr_idle_scan hint: on a busy system the hint drops to a
> +	 * few CPUs, the scan then stops at whatever idle CPU it met first, and
> +	 * a task that fits no CPU (util above every capacity margin) lands on
> +	 * an idle little core while an idle big core is never looked at.
> +	 */
>  	for_each_cpu_wrap(cpu, cpus, target) {
>  		bool preferred_core = !has_idle_core || is_core_idle(cpu);
>  		unsigned long cpu_cap = capacity_of(cpu);
>  
> -		/*
> -		 * Stop when the nr_idle_scan is exhausted (mirrors
> -		 * select_idle_cpu() logic).
> -		 */
> -		if (!has_idle_core && --nr <= 0)
> -			return best_cpu;
> -
>  		if (!choose_idle_cpu(cpu, p))
>  			continue;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24 13:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox