All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched_ext: Fix inconsistent NUMA node lookup in scx_select_cpu_dfl()
@ 2026-03-21 10:54 Cheng-Yang Chou
  2026-03-21 17:45 ` Andrea Righi
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Cheng-Yang Chou @ 2026-03-21 10:54 UTC (permalink / raw)
  To: sched-ext, Tejun Heo, David Vernet, Andrea Righi, Changwoo Min
  Cc: Ching-Chun Huang, Chia-Ping Tsai, yphbchou0911

In the WAKE_SYNC path of scx_select_cpu_dfl(), waker_node was computed
with cpu_to_node(), while node (for prev_cpu) was computed with
scx_cpu_node_if_enabled(). When scx_builtin_idle_per_node is disabled,
node is NUMA_NO_NODE but waker_node would be the actual NUMA node,
causing two issues:

1. The (waker_node == node) check always fails when SCX_PICK_IDLE_IN_NODE
   is set, preventing the waker CPU optimization from ever triggering.
2. idle_cpumask(waker_node) is called with a real node ID even though
   per-node idle tracking is disabled, resulting in undefined behavior.

Fix by using scx_cpu_node_if_enabled() for waker_node as well, ensuring
both variables are computed consistently.

Fixes: 48849271e6611 ("sched_ext: idle: Per-node idle cpumasks")
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
---
 kernel/sched/ext_idle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/ext_idle.c b/kernel/sched/ext_idle.c
index c7e405262697..8436c7df0a56 100644
--- a/kernel/sched/ext_idle.c
+++ b/kernel/sched/ext_idle.c
@@ -543,7 +543,7 @@ s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, u64 wake_flags,
 		 * piled up on it even if there is an idle core elsewhere on
 		 * the system.
 		 */
-		waker_node = cpu_to_node(cpu);
+		waker_node = scx_cpu_node_if_enabled(cpu);
 		if (!(current->flags & PF_EXITING) &&
 		    cpu_rq(cpu)->scx.local_dsq.nr == 0 &&
 		    (!(flags & SCX_PICK_IDLE_IN_NODE) || (waker_node == node)) &&
-- 
2.48.1


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

end of thread, other threads:[~2026-03-22  0:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-21 10:54 [PATCH] sched_ext: Fix inconsistent NUMA node lookup in scx_select_cpu_dfl() Cheng-Yang Chou
2026-03-21 17:45 ` Andrea Righi
2026-03-21 18:42 ` Tejun Heo
2026-03-21 19:39   ` Cheng-Yang Chou
2026-03-21 19:38 ` [PATCH v2] " Cheng-Yang Chou
2026-03-22  0:26   ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.