scx_bpf_pick_any_cpu_node(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 first
  • flags β€” your SCX_PICK_IDLE_* flags, the little switches that change how the search behaves
  • aux β€” the implicit BPF argument that gives you access to bpf_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: 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. 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:


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