KFunc scx_bpf_select_cpu_and
Pick an idle CPU usable by task p
, prioritizing those in cpus_allowed
Definition
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
, prev_cpu
and wake_flag
match sched_ext_ops.select_cpu
.
Parameters
p
: task_struct to select a CPU for
prev_cpu
: CPU p
was on previously
wake_flags
: SCX_WAKE_*
, possible values are:
SCX_WAKE_FORK
(0x02
) - Wakeup after execSCX_WAKE_TTWU
(0x04
) - Wakeup after forkSCX_WAKE_SYNC
(0x08
) - Wakeup
cpus_allowed
: cpumask of allowed CPUs
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, s32 prev_cpu, u64 wake_flags, const struct cpumask *cpus_allowed, u64 flags)
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