mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCHSET v2 sched_ext/for-7.4] sched_ext: Add scx_bpf_cgroup_nr_cpus()
@ 2026-09-30  9:00 Andrea Righi
  2026-09-30  9:00 ` [PATCH 1/2] sched_ext: Introduce scx_bpf_cgroup_nr_cpus() Andrea Righi
  2026-09-30  9:00 ` [PATCH 2/2] selftests/sched_ext: Test scx_bpf_cgroup_nr_cpus() Andrea Righi
  0 siblings, 2 replies; 3+ messages in thread
From: Andrea Righi @ 2026-09-30  9:00 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Changwoo Min
  Cc: Waiman Long, Michal Koutny, sched-ext, cgroups, linux-kernel

Hierarchical BPF schedulers need to know how many CPUs a cgroup can run
on when distributing group-wide weights. For example, fair's group share
calculation scales a group's weight by the smaller of its estimated
runnable task count and the number of CPUs in its effective cpuset.
Without that count, a BPF scheduler can only use the machine-wide CPU
count and may give a group confined to a few CPUs excessive shares.

This series adds scx_bpf_cgroup_nr_cpus(), a kfunc that returns the same
count fair uses. This allows scx_eevdf to compute per-cgroup shares for
groups confined to a subset of CPUs through cpuset. A selftest covers
effective and inherited cpusets, changes to the allowed CPUs, and calls
with and without a scheduler attached.

This series requires Waiman Long's cpuset fix to avoid a potential
use-after-free in a rare cgroup filesystem rebind race:
https://lore.kernel.org/r/20260930031833.660267-1-longman@redhat.com

Changes in v2:
 - Drop the cpuset RCU guard patch
 - Link to v1:
   https://lore.kernel.org/r/20260929084124.626693-1-arighi@nvidia.com

Andrea Righi (2):
  sched_ext: Introduce scx_bpf_cgroup_nr_cpus()
  selftests/sched_ext: Test scx_bpf_cgroup_nr_cpus()

 kernel/sched/ext/ext.c                        |  18 +
 tools/sched_ext/include/scx/common.bpf.h      |   1 +
 tools/sched_ext/include/scx/compat.bpf.h      |   7 +
 tools/testing/selftests/sched_ext/Makefile    |   6 +-
 .../selftests/sched_ext/cgroup_nr_cpus.bpf.c  |  60 +++
 .../selftests/sched_ext/cgroup_nr_cpus.c      | 419 ++++++++++++++++++
 tools/testing/selftests/sched_ext/config      |   1 +
 7 files changed, 510 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/sched_ext/cgroup_nr_cpus.bpf.c
 create mode 100644 tools/testing/selftests/sched_ext/cgroup_nr_cpus.c

-- 
2.55.0

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

end of thread, other threads:[~2026-09-30  9:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-30  9:00 [PATCHSET v2 sched_ext/for-7.4] sched_ext: Add scx_bpf_cgroup_nr_cpus() Andrea Righi
2026-09-30  9:00 ` [PATCH 1/2] sched_ext: Introduce scx_bpf_cgroup_nr_cpus() Andrea Righi
2026-09-30  9:00 ` [PATCH 2/2] selftests/sched_ext: Test scx_bpf_cgroup_nr_cpus() 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®