KFunc __scx_bpf_select_cpu_and
Argument-wrapped CPU selection with cpumask.
Definition
Wrapper kfunc that takes arguments via struct to work around the 5 argument limit for BPF functions. BPF programs should use scx_bpf_select_cpu_and which is provided as an inline wrapper in common.bpf.h.
Can be called from sched_ext_ops.select_cpu, sched_ext_ops.enqueue, or from an unlocked context such as a BPF test_run call, as long as built-in CPU selection is enabled: sched_ext_ops.update_idle is missing or SCX_OPS_KEEP_BUILTIN_IDLE is set.
p, args->prev_cpu and args->wake_flag match sched_ext_ops.select_cpu.
Returns the selected idle CPU, which will be automatically awakened upon returning from sched_ext_ops.select_cpu and can be used for direct dispatch, or a negative value if no idle CPU is available.
Parameters
p: task_struct to select a CPU for
cpus_allowed: cpumask of allowed CPUs
args: Structure of additional arguments
struct scx_bpf_select_cpu_and_args {
/* @p and @cpus_allowed can't be packed together as KF_RCU is not transitive */
s32 prev_cpu;
u64 wake_flags;
u64 flags;
};
args->prev_cpu: CPU p was on previously
args->wake_flags: SCX_WAKE_*, possible values are:
SCX_WAKE_FORK(0x02) - Wakeup after execSCX_WAKE_TTWU(0x04) - Wakeup after forkSCX_WAKE_SYNC(0x08) - Wakeup
args->cpus_allowed: cpumask of allowed CPUs
args->flags: SCX_PICK_IDLE_CPU_* flags
Flags
enum scx_pick_idle_cpu_flags {
SCX_PICK_IDLE_CORE = 1LLU << 0,
SCX_PICK_IDLE_IN_NODE = 1LLU << 1,
};
SCX_PICK_IDLE_CORE: pick a CPU whose SMT siblings are also idle
SCX_PICK_IDLE_IN_NODE: pick a CPU in the same target NUMA node
Returns
The selected idle CPU, which will be automatically awakened upon returning from sched_ext_ops.select_cpu and can be used for direct dispatch, or a negative value if no idle CPU is available.
Signature
s32 __scx_bpf_select_cpu_and(struct task_struct *p, const struct cpumask *cpus_allowed, struct scx_bpf_select_cpu_and_args *args)
Usage
Docs could be improved
This part of the docs is incomplete, contributions are very welcome
Program types
The following program types can make use of this kfunc:
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome