Skip to content

KFunc scx_bpf_pick_idle_cpu

v6.12

This function picks and claims an idle CPU.

Definition

Pick and claim an idle CPU in cpus_allowed.

Idle CPU tracking may race against CPU scheduling state transitions. For example, this function may return -EBUSY as CPUs are transitioning into the idle state. If the caller then assumes that there will be dispatch events on the CPUs as they were all busy, the scheduler may end up stalling with CPUs idling while there are pending tasks. Use scx_bpf_pick_any_cpu and scx_bpf_kick_cpu to guarantee that there will be at least one dispatch event in the near future.

Unavailable if ops.update_idle() is implemented and SCX_OPS_KEEP_BUILTIN_IDLE is not set.

Parameters

cpus_allowed: Allowed cpumask

flags: SCX_PICK_IDLE_* flags

Flags

  • SCX_PICK_IDLE_CORE - pick a CPU whose SMT siblings are also idle

Returns

The picked idle CPU number on success. -EBUSY if no matching cpu was found.

Signature

s32 scx_bpf_pick_idle_cpu(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