Skip to contentSkip to conversation

sched_ext: idle: use active idle domain in WAKE_SYNC check

PATCH In review Joseph Salisbury 2 participants 3 messages Mar 24 – Mar 26

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched_ext: idle: use active idle domain in WAKE_SYNC check

The WAKE_SYNC fast path checks whether there are idle CPUs before biasing wakeups to the waker CPU. After per-node idle masks were introduced, this path started indexing idle_cpumask() with cpu_to_node().

When per-node idle tracking is disabled, per-node masks are not kept in sync and may be stale. Reading them here can mis-detect system utilization and lead to incorrect WAKE_SYNC wakeup placement.

Use scx_cpu_node_if_enabled() for the waker node lookup so this check uses the global idle mask when per-node tracking is disabled and the per-node mask only when that mode is enabled.

Fixes 48849271e661 ("sched_ext: idle: Per-node idle cpumasks")
Cc [email protected] # v6.15+
Assisted-by Codex:GPT-5
---
 kernel/sched/ext_idle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/ext_idle.c +1 -1
index 8cfe0e9a7319..6b4520ed563d 100644
@@ -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)) &&
Signature · 1 line
2.47.3
reviewer
#1 lore raw

Hi Joe,

Quoted 9 lines · Joseph Salisbury

The WAKE_SYNC fast path checks whether there are idle CPUs before biasing wakeups to the waker CPU. After per-node idle masks were introduced, this path started indexing idle_cpumask() with cpu_to_node().

When per-node idle tracking is disabled, per-node masks are not kept in sync and may be stale. Reading them here can mis-detect system utilization and lead to incorrect WAKE_SYNC wakeup placement.

Quoted 8 lines

Use scx_cpu_node_if_enabled() for the waker node lookup so this check uses the global idle mask when per-node tracking is disabled and the per-node mask only when that mode is enabled.

Fixes 48849271e661 ("sched_ext: idle: Per-node idle cpumasks")
Cc [email protected] # v6.15+
Assisted-by Codex:GPT-5

This is good, but it's already fixed:
https://lore.kernel.org/all/[email protected]

You can probably use Tejun's branch to search for new issues/bugs:

git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git

Thanks,
-Andrea

Quoted 19 lines
---
 kernel/sched/ext_idle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/ext_idle.c +1 -1
index 8cfe0e9a7319..6b4520ed563d 100644
@@ -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)) &&
Signature · 1 line
2.47.3
#2 lore raw

Re: [External] : Re: [PATCH] sched_ext: idle: use active idle domain in WAKE_SYNC check

Quoted 20 lines · Andrea Righi

Hi Joe,

Quoted 9 lines · Joseph Salisbury

The WAKE_SYNC fast path checks whether there are idle CPUs before biasing wakeups to the waker CPU. After per-node idle masks were introduced, this path started indexing idle_cpumask() with cpu_to_node().

When per-node idle tracking is disabled, per-node masks are not kept in sync and may be stale. Reading them here can mis-detect system utilization and lead to incorrect WAKE_SYNC wakeup placement.

Quoted 8 lines

Use scx_cpu_node_if_enabled() for the waker node lookup so this check uses the global idle mask when per-node tracking is disabled and the per-node mask only when that mode is enabled.

Fixes 48849271e661 ("sched_ext: idle: Per-node idle cpumasks")
Cc [email protected] # v6.15+
Assisted-by Codex:GPT-5
Quoted 6 lines

This is good, but it's already fixed:
https://urldefense.com/v3/__https://lore.kernel.org/all/[email protected]__;!!ACWV5N9M2RV99hQ!M88Tr7SYG3FHedTvBFVj_5kAPCVI-WVHWNdHhvaysPHoUD3qbj9bZ8kNj8TwcjHXNvVTnhx0BvGh7pM5R6fC$

You can probably use Tejun's branch to search for new issues/bugs:

git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git

Thanks for the pointer!  I'll review this branch prior to sending/fixing any more bugs.

Quoted 23 lines

Thanks,
-Andrea

Quoted 19 lines
---
  kernel/sched/ext_idle.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/ext_idle.c +1 -1
index 8cfe0e9a7319..6b4520ed563d 100644
@@ -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)) &&
Signature · 1 line
2.47.3