mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCHSET sched_ext/for-7.4] sched_ext: Add NUMA balancing support
@ 2026-10-04  7:27 Andrea Righi
  2026-10-04  7:27 ` [PATCH 1/5] sched/numa: Let other scheduling classes drive NUMA scanning Andrea Righi
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Andrea Righi @ 2026-10-04  7:27 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Changwoo Min
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, K Prateek Nayak, Vladimir Vdovin,
	Emil Tsalapatis, Christian Loehle, Balbir Singh, Lee Trager,
	sched-ext, linux-kernel

Tasks running under a BPF scheduler are currently invisible to NUMA balancing:
their address space is never scanned for hinting faults, so they never record
NUMA fault statistics and never acquire a preferred node. A BPF scheduler
therefore has no information about where a task's memory is when deciding where
to run it.

This series lets a BPF scheduler opt into the NUMA hinting-fault scan with
SCX_OPS_NUMA_BALANCING. The existing scan is driven from the sched_ext tick for
the tasks of such a scheduler, and the hinting faults then work for them as they
do for fair tasks: the kernel maintains their NUMA fault statistics and
preferred node, and migrates the memory a task accesses toward the node it runs
on. The tasks themselves are not migrated: their placement is left to the BPF
scheduler.

The resulting preferred node is exposed to BPF schedulers with
scx_bpf_task_numa_nid(), which they can use to keep a task close to its memory
when placing or balancing it. The value is advisory; nothing in the kernel acts
on it for these tasks.

The ultimate goal is to give BPF schedulers both controls that NUMA balancing
combines: moving a task to the node where its memory is and moving the memory a
task uses to the node where the task runs. This series provides the first: with
the preferred node available, a scheduler can decide where to run the task. A
second series, to follow once this one lands, will provide the second: a kfunc
that hints the memory manager to migrate the task's memory toward the node its
scheduler has chosen.

Vladimir Vdovin recently posted an RFC [1] that drives the scan from the
sched_ext tick in the same way and skips the fair-class task migration for tasks
under a BPF scheduler. This series covers what that RFC proposed and adds the
opt-in flag and the kfunc on top.

Patches 1 and 2 are small preparatory changes to the generic NUMA balancing
code: the first makes the scan available to other scheduling classes, the second
skips the fair-class task migration for tasks owned by a BPF scheduler. Neither
changes the behavior of fair, RT or deadline tasks. Patches 3 and 4 add the
opt-in flag and the kfunc and patch 5 adds a selftest.

[1] https://lore.kernel.org/r/20261002124559.10367-1-deliran@verdict.gg

Git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/arighi/linux.git scx-numa-balancing

Andrea Righi (5):
      sched/numa: Let other scheduling classes drive NUMA scanning
      sched/numa: Leave the placement of a BPF-scheduled task to its scheduler
      sched_ext: Scan NUMA hinting faults for opted-in BPF schedulers
      sched_ext: Add scx_bpf_task_numa_nid()
      selftests/sched_ext: Add a test for scx_bpf_task_numa_nid()

 kernel/sched/ext/ext.c                           |  39 ++++++++
 kernel/sched/ext/internal.h                      |  16 +++-
 kernel/sched/fair.c                              |  14 ++-
 kernel/sched/sched.h                             |   5 +
 tools/sched_ext/include/scx/compat.bpf.h         |  10 ++
 tools/sched_ext/include/scx/compat.h             |   1 +
 tools/sched_ext/include/scx/enum_defs.autogen.h  |   1 +
 tools/sched_ext/include/scx/enums_abi.autogen.h  |   3 +-
 tools/testing/selftests/sched_ext/Makefile       |   1 +
 tools/testing/selftests/sched_ext/numa_nid.bpf.c |  52 +++++++++++
 tools/testing/selftests/sched_ext/numa_nid.c     | 111 +++++++++++++++++++++++
 11 files changed, 246 insertions(+), 7 deletions(-)
 create mode 100644 tools/testing/selftests/sched_ext/numa_nid.bpf.c
 create mode 100644 tools/testing/selftests/sched_ext/numa_nid.c

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

end of thread, other threads:[~2026-10-04  7:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-04  7:27 [PATCHSET sched_ext/for-7.4] sched_ext: Add NUMA balancing support Andrea Righi
2026-10-04  7:27 ` [PATCH 1/5] sched/numa: Let other scheduling classes drive NUMA scanning Andrea Righi
2026-10-04  7:27 ` [PATCH 2/5] sched/numa: Leave the placement of a BPF-scheduled task to its scheduler Andrea Righi
2026-10-04  7:27 ` [PATCH 3/5] sched_ext: Scan NUMA hinting faults for opted-in BPF schedulers Andrea Righi
2026-10-04  7:27 ` [PATCH 4/5] sched_ext: Add scx_bpf_task_numa_nid() Andrea Righi
2026-10-04  7:27 ` [PATCH 5/5] selftests/sched_ext: Add a test for scx_bpf_task_numa_nid() Andrea Righi

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®