All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET v2 sched_ext/for-6.16] sched_ext: Extend usability of scx_bpf_select_cpu_and()
@ 2025-05-15 19:11 Andrea Righi
  2025-05-15 19:11 ` [PATCH 1/4] sched_ext: Make scx_kf_allowed_if_unlocked() available outside ext.c Andrea Righi
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Andrea Righi @ 2025-05-15 19:11 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Changwoo Min; +Cc: linux-kernel

Many scx schedulers implement their own idle CPU selection policy, which
may be invoked from different contexts, not just from ops.select_cpu().

For example, some schedulers may need to trigger a proactive CPU wakeup
from ops.enqueue() after enqueuing a task, while others may expose this
functionality to user space, relying on a BPF test_run call to pick an idle
CPU.

To maintain a consistent selection policy, these schedulers often implement
their own idle CPU selection logic, since the built-in one is only usable
from ops.select_cpu(), leading to unnecessary code duplication and
fragmentation.

To address this, allow scx_bpf_select_cpu_and() to be called not only from
ops.select_cpu() and ops.enqueue(), but also from unlocked contexts (e.g.,
when triggered from user space via a BPF test_run call).

This allows scx schedulers to consistently leverage the built-in idle CPU
selection logic, helping reduce code duplication and fragmentation.

This patchset is also available in the following git branch:

 git://git.kernel.org/pub/scm/linux/kernel/git/arighi/linux.git scx-select-cpu-and

Changes in v2:
 - Enable scx_bpf_select_cpu_and() to be called from ops.enqueue()
   ops.select_cpu() and unlocked context
 - Add locking validation to ensure safe access to p->cpus_ptr and
   p->nr_cpus_allowed
 - Extend selftest to cover scx_bpf_select_cpu_and() when invoked from user
   space
 - Link to v1: https://lore.kernel.org/all/20250512151743.42988-1-arighi@nvidia.com/

Andrea Righi (4):
      sched_ext: Make scx_kf_allowed_if_unlocked() available outside ext.c
      sched_ext: idle: Validate locking correctness in scx_bpf_select_cpu_and()
      sched_ext: idle: Allow scx_bpf_select_cpu_and() from unlocked context
      selftests/sched_ext: Add test for scx_bpf_select_cpu_and() via test_run

 kernel/sched/ext.c                                 |  5 ---
 kernel/sched/ext.h                                 |  5 +++
 kernel/sched/ext_idle.c                            | 45 +++++++++++++++++-----
 .../testing/selftests/sched_ext/allowed_cpus.bpf.c | 23 +++++++++++
 tools/testing/selftests/sched_ext/allowed_cpus.c   | 27 +++++++++++++
 5 files changed, 91 insertions(+), 14 deletions(-)

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

end of thread, other threads:[~2025-05-19 18:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-15 19:11 [PATCHSET v2 sched_ext/for-6.16] sched_ext: Extend usability of scx_bpf_select_cpu_and() Andrea Righi
2025-05-15 19:11 ` [PATCH 1/4] sched_ext: Make scx_kf_allowed_if_unlocked() available outside ext.c Andrea Righi
2025-05-15 19:11 ` [PATCH 2/4] sched_ext: idle: Validate locking correctness in scx_bpf_select_cpu_and() Andrea Righi
2025-05-15 19:11 ` [PATCH 3/4] sched_ext: idle: Allow scx_bpf_select_cpu_and() from unlocked context Andrea Righi
2025-05-17 17:54   ` David Vernet
2025-05-17 22:50     ` Andrea Righi
2025-05-18  0:40       ` David Vernet
2025-05-18  5:52         ` Andrea Righi
2025-05-18 13:49           ` David Vernet
2025-05-15 19:11 ` [PATCH 4/4] selftests/sched_ext: Add test for scx_bpf_select_cpu_and() via test_run Andrea Righi
2025-05-19 18:02 ` [PATCHSET v2 sched_ext/for-6.16] sched_ext: Extend usability of scx_bpf_select_cpu_and() 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.