scx_bpf_pick_any_cpu(9)
π scx_bpf_pick_any_cpu β from the Kernel API Manual, bestie β¨
Okay so picture this: it's a scx_bpf_pick_any_cpu(9) kind of day, the manual name is Kernel API Manual, and this function is literally the friend who's like "I'll find us a seat, don't even worry." Obsessed. Let's get into it π«Ά
πΈ NAME πΈ
scx_bpf_pick_any_cpu β picks and claims an idle CPU if there's one available, or just picks any CPU. No cap, that's the whole vibe check π
β¨ SYNOPSIS β¨
__bpf_kfunc s32 scx_bpf_pick_any_cpu (const struct cpumask *cpus_allowed
, u64 flags , const struct bpf_prog_aux *aux );
π ARGUMENTS π
cpus_allowedβ the allowed cpumask, aka the guest list for this CPU party πflagsβ theSCX_PICK_IDLE_*flags. Cute little modifiers, iykyk.auxβ the implicit BPF argument that gives you access tobpf_prog_aux, which is hidden from BPF progs. Lowkey a backstage pass ποΈ
π¦ DESCRIPTION π¦
So here's the tea: this function picks and claims an idle CPU inside cpus_allowed. And if none of them is available? It just picks any CPU in there anyway. It's guaranteed to succeed, and it returns the picked idle CPU number as long as cpus_allowed isn't empty. Slay β¨
If cpus_allowed is empty, you get -EBUSY back instead. Not the vibe, but that's the deal π
Heads up bestie: ifops.update_idleis implemented andSCX_OPS_KEEP_BUILTIN_IDLEis not set, this function literally can't tell which CPUs are idle, so it will always just pick any CPU. It's giving "no thoughts, head empty" π
Also important: ifSCX_OPS_BUILTIN_IDLE_PER_NODEis set, this function always returns an error, no exceptions. In that case usescx_bpf_pick_any_cpu_nodeinstead, periodt.
π SEE ALSO π
The Kernel file ./kernel/sched/ext/idle.c is where the magic lives, and honestly the whole friend group is iconic:
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_node(9)
Okay that's the whole page, mwah π This one came straight outta ./kernel/sched/ext, dated October 2026 β go off, king ππ¦π
π¦ 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