mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] sched/fair: Don't pick recent_used_cpu if target has no sched domain
@ 2026-11-25  0:36 Keisuke Nishimura
  2026-11-26 11:21 ` Vincent Guittot
  0 siblings, 1 reply; 5+ messages in thread
From: Keisuke Nishimura @ 2026-11-25  0:36 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, K Prateek Nayak, linux-kernel
  Cc: julia.lawall, jean-pierre.lozi, Keisuke Nishimura

select_idle_sibling() can return recent_used_cpu if it is idle and
shares the LLC with target. However, it does not check if target is an
isolated CPU where the scheduler should not move tasks.

Consider the following situation:
* isolcpus=1,2
* recent_used_cpu=1
* target=prev=2
* affinity=1,2

When CPU 1 is idle but CPU 2 is busy, select_idle_sibling() returns
recent_used_cpu (CPU 1).

To prevent the scheduler from moving the task among isolated CPUs, check
whether target has a sched domain before searching for an idle CPU.

This bug was found with the help of verification using Frama-C.

Fixes: 32e839dda3ba ("sched/fair: Use a recently used CPU as an idle candidate and the basis for SIS")
Signed-off-by: Keisuke Nishimura <keisuke.nishimura@inria.fr>
---
Changes in v2:
- Return early at the beginning of select_idle_sibling() if target has
  no sched domain.
- Instead of `per_cpu(sd_llc, target)`, use `cpu_rq(target)->sd` to
  check if target is isolated or not. A CPU might be in an asymmetric
  capacity domain, but not in an LLC domain. In this case, returning
  early based only on the LLC domain would miss the chance to run
  select_idle_capacity().
- Rewrite the explanation, because sd_llc is not the main issue anymore.
---
 kernel/sched/fair.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index da0d9e19c457..9746fc55241b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9155,6 +9155,10 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 	unsigned long task_util, util_min, util_max;
 	int i, recent_used_cpu, prev_aff = -1;
 
+	/* Do not search for idle CPUs if target has no sched domain. */
+	if (!rcu_dereference_all(cpu_rq(target)->sd))
+		return target;
+
 	/*
 	 * On asymmetric system, update task utilization because we will check
 	 * that the task fits with CPU's capacity.
-- 
2.34.1


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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25  0:36 [PATCH v2] sched/fair: Don't pick recent_used_cpu if target has no sched domain Keisuke Nishimura
2026-11-26 11:21 ` Vincent Guittot
2026-11-26 11:26   ` Vincent Guittot
2026-11-26 12:14     ` Keisuke Nishimura
2026-11-26 13:30       ` Vincent Guittot

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®