This patchset aims to start a discussion about potential applications of BPF to the scheduler. It also aims to land some very basic BPF infrastructure necessary to add new BPF hooks to the scheduler, a minimal set of useful helpers, corresponding libbpf changes, etc.
[Testing] kernel options: CONFIG_BPF_SCHED=y CONFIG_BPF_SYSCALL=y CONFIG_BPF_EVENTS=y
Test passed with below step: 1.cd tools/testing/selftests/bpf & make 2.run cmd: ./test_progs -t test_sched 3.it will show like this: # ./test_progs -t test_sched #113/1 sched_tgidpid_mode:OK #113/2 sched_cgid_mode:OK #113 test_sched:OK Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED
Chen Hui (1): sched: Move some definition to sched.h
Ren Zhijie (1): bpf: sched: add selftests for BPF_PROG_TYPE_SCHED
Roman Gushchin (6): bpf: sched: basic infrastructure for scheduler bpf bpf: sched: add convenient helpers to identify sched entities bpf: sched: introduce bpf_sched_enable() sched: cfs: add bpf hooks to control wakeup and tick preemption libbpf: add support for scheduler bpf programs bpftool: recognize scheduler programs
include/linux/bpf_sched.h | 50 +++++ include/linux/bpf_types.h | 4 + include/linux/sched_hook_defs.h | 5 + include/uapi/linux/bpf.h | 25 +++ init/Kconfig | 10 + kernel/bpf/btf.c | 1 + kernel/bpf/syscall.c | 20 ++ kernel/bpf/trampoline.c | 1 + kernel/bpf/verifier.c | 11 +- kernel/sched/Makefile | 1 + kernel/sched/bpf_sched.c | 138 ++++++++++++ kernel/sched/fair.c | 79 +++---- kernel/sched/sched.h | 52 +++++ scripts/bpf_helpers_doc.py | 2 + tools/bpf/bpftool/common.c | 1 + tools/bpf/bpftool/prog.c | 1 + tools/include/uapi/linux/bpf.h | 25 +++ tools/lib/bpf/bpf.c | 3 +- tools/lib/bpf/libbpf.c | 33 ++- tools/lib/bpf/libbpf.h | 4 + tools/lib/bpf/libbpf.map | 3 + .../selftests/bpf/prog_tests/test_sched.c | 160 ++++++++++++++ tools/testing/selftests/bpf/progs/sched.c | 203 ++++++++++++++++++ 23 files changed, 780 insertions(+), 52 deletions(-) create mode 100644 include/linux/bpf_sched.h create mode 100644 include/linux/sched_hook_defs.h create mode 100644 kernel/sched/bpf_sched.c create mode 100644 tools/testing/selftests/bpf/prog_tests/test_sched.c create mode 100644 tools/testing/selftests/bpf/progs/sched.c