All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH sched_ext/for-7.1 0/2] sched_ext: Reduce idle CPU NUMA traversal from O(N^2) to O(N)
@ 2026-03-15 18:10 Cheng-Yang Chou
  2026-03-15 18:10 ` [PATCH 1/2] sched_ext: Cache per-node NUMA distance order in scx_idle_init_masks() Cheng-Yang Chou
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Cheng-Yang Chou @ 2026-03-15 18:10 UTC (permalink / raw)
  To: sched-ext, Tejun Heo, David Vernet, Andrea Righi, Changwoo Min
  Cc: Ching-Chun Huang, Chia-Ping Tsai, yphbchou0911

pick_idle_cpu_from_online_nodes() uses for_each_node_numadist() which
performs an O(N^2) traversal on every call to find the nearest idle
CPU across NUMA nodes.

Since NUMA distances are fixed at boot and do not change at runtime,
the per-node traversal order can be computed once during initialization
and reused on every subsequent call. This series pre-computes the
sorted order into scx_numa_node_order[], reducing the per-call cost
to O(N).

Patch 1 allocates and populates scx_numa_node_order[] and
scx_numa_node_order_cnt[] in scx_idle_init_masks() using the existing
for_each_node_numadist() traversal, paying the O(N^2) cost only once
at init time.

Patch 2 switches pick_idle_cpu_from_online_nodes() to iterate the
cached arrays, removes the now-unnecessary per_cpu_unvisited nodemask,
and adds a node_online() check so CPU hotplug is handled correctly
without needing to rebuild the arrays.

Tested with make -j only. I do not have access to a NUMA machine to
run runtime tests.

Thanks,
Cheng-Yang

---

Cheng-Yang Chou (2):
  sched_ext: Cache per-node NUMA distance order in scx_idle_init_masks()
  sched_ext: Use cached NUMA order in pick_idle_cpu_from_online_nodes()

 kernel/sched/ext_idle.c | 81 +++++++++++++++++++++++++----------------
 1 file changed, 49 insertions(+), 32 deletions(-)

-- 
2.48.1


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

end of thread, other threads:[~2026-03-17 19:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-15 18:10 [PATCH sched_ext/for-7.1 0/2] sched_ext: Reduce idle CPU NUMA traversal from O(N^2) to O(N) Cheng-Yang Chou
2026-03-15 18:10 ` [PATCH 1/2] sched_ext: Cache per-node NUMA distance order in scx_idle_init_masks() Cheng-Yang Chou
2026-03-16 15:51   ` Andrea Righi
2026-03-17 15:04     ` Cheng-Yang Chou
2026-03-17 17:32       ` Tejun Heo
2026-03-17 18:02         ` Andrea Righi
2026-03-17 19:00           ` Cheng-Yang Chou
2026-03-15 18:10 ` [PATCH 2/2] sched_ext: Use cached NUMA order in pick_idle_cpu_from_online_nodes() Cheng-Yang Chou
2026-03-16 12:27 ` [PATCH sched_ext/for-7.1 0/2] sched_ext: Reduce idle CPU NUMA traversal from O(N^2) to O(N) Christian Loehle
2026-03-16 14:50   ` Andrea Righi

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.