SCX
The kernel concludes a number of example sched_ext BPF schedulers. These examples make use of some common header files that aid in writing schedulers. These are located in tools/sched_ext/include/scx
. We document macros inside of these to make following examples easier and because kfuncs and the sched_ext_ops reference them.
Note
These in-tree headers are based on files developed in an out of tree sched-ext/scx project, which moves faster than the kernel. If you are looking for a library to use in your own projects, you may want to look at the out of tree project.
common.bpf.h
This header file provides a number of macros that might be useful when writing schedulers. It also contains forward declarations for most kfuncs that might be of use.
Definitions in this file are:
BPF_FOR_EACH_ITER
scx_bpf_bstr_preamble
scx_bpf_exit
scx_bpf_error
scx_bpf_dump
BPF_STRUCT_OPS
BPF_STRUCT_OPS_SLEEPABLE
RESIZABLE_ARRAY
ARRAY_ELEM_PTR
MEMBER_VPTR
__contains
private
bpf_obj_new
bpf_obj_drop
bpf_rbtree_add
bpf_refcount_acquire
cast_mask
likely
unlikely
READ_ONCE
WRITE_ONCE
log2_u32
log2_u64
compat.bpf.h
This header file provides compatibility wrappers that pick the right implementation based on the kernel version, dealing with the fact that the sched_ext implementation is still in flux.
Definitions in this file are: