Skip to content

KFunc scx_bpf_pick_any_cpu_node

v6.15

Pick and claim an idle cpu if available or pick any CPU from node

Definition

Pick and claim an idle cpu in cpus_allowed. If none is available, pick any CPU in cpus_allowed. Guaranteed to succeed and returns the picked idle cpu number if cpus_allowed is not empty.

The search starts from node and proceeds to other online NUMA nodes in order of increasing distance (unless SCX_PICK_IDLE_IN_NODE is specified, in which case the search is limited to the target @node, regardless of the CPU idle state).

If ops.update_idle is implemented and SCX_OPS_KEEP_BUILTIN_IDLE is not set, this function can't tell which CPUs are idle and will always pick any CPU.

Parameters

cpus_allowed: Allowed cpumask

node: target NUMA node

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

-%EBUSY is returned if cpus_allowed is empty.

Signature

s32 scx_bpf_pick_any_cpu_node(const struct cpumask *cpus_allowed, int node, 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