scx_bpf_pick_any_cpu_node(9)
π scx_bpf_pick_any_cpu_node(9)
okay so real talk, this is a page straight out of the Kernel API Manual β it's scx_bpf_pick_any_cpu_node(9) and bestie, it's literally the "gimme a CPU, any CPU" function. Let's get into it β¨
πΈ SYNOPSIS πΈ
__bpf_kfunc s32 scx_bpf_pick_any_cpu_node (const struct cpumask
*cpus_allowed , s32 node , u64 flags , const struct bpf_prog_aux *aux );
that's the whole vibe, no cap π«Ά
π ARGUMENTS π
cpus_allowedβ the allowed cpumask, aka the guest list for your CPU party πnodeβ the target NUMA node, like the specific venue you're tryna book firstflagsβ yourSCX_PICK_IDLE_*flags, the little switches that change how the search behavesauxβ the implicit BPF argument that gives you access tobpf_prog_aux, and it's hidden from BPF progs β so like, don't go looking for it, it's not for you π
π₯ DESCRIPTION π₯
So here's what it does: it picks and claims an idle cpu inside cpus_allowed. If there's literally no idle one available, it'll just pick any CPU in cpus_allowed anyway. It is guaranteed to succeed and returns the number of the picked idle cpu as long as cpus_allowed isn't empty. And if cpus_allowed is empty? You get -EBUSY back. π
The search starts at node and then hops to the other online NUMA nodes in order of increasing distance β unless you specified SCX_PICK_IDLE_IN_NODE, in which case the search is limited to the target node, regardless of the CPU idle state. periodt. π
β οΈ caveat time, bestie: ifops.update_idleis implemented andSCX_OPS_KEEP_BUILTIN_IDLEis not set, this function can't tell which CPUs are idle and will always pick any CPU. like it just gives up on the whole idle-detection thing π
π¦ SEE ALSO π¦
Kernel file ./kernel/sched/ext/idle.c, plus the whole friend group:
scx_bpf_cpu_node(9)scx_bpf_select_cpu_dfl(9)__scx_bpf_select_cpu_and(9)scx_bpf_get_idle_cpumask_node(9)scx_bpf_get_idle_cpumask(9)scx_bpf_get_idle_smtmask_node(9)scx_bpf_get_idle_smtmask(9)scx_bpf_put_idle_cpumask(9)scx_bpf_test_and_clear_cpu_idle(9)scx_bpf_pick_idle_cpu_node(9)scx_bpf_pick_idle_cpu(9)scx_bpf_pick_any_cpu(9)
and that's the page!! π§ this one ships from ./kernel/sched/ext, dated October 2026 β catch you on the next manpage bestie, mwah ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms