scx_bpf_select_cpu_dfl(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… scx_bpf_select_cpu_dfl(9) β€” like, the default CPU picker, bestie

okay so this is a Kernel API Manual page, section 9 (kernel API, iykyk), and it's about scx_bpf_select_cpu_dfl β€” literally the built-in, off-the-shelf version of ops.select_cpu(). if you're writing an sched_ext scheduler and you don't wanna hand-roll your own CPU picking logic, this is your girl πŸŽ€


✨ NAME ✨

scx_bpf_select_cpu_dfl β€” the default implementation of ops.select_cpu(), no cap 🫢


✨ SYNOPSIS ✨

__bpf_kfunc s32 scx_bpf_select_cpu_dfl (struct task_struct *p , s32
prev_cpu , u64 wake_flags , bool *is_idle , const struct bpf_prog_aux
*aux );

✨ ARGUMENTS ✨

  • p β€” the task_struct you're picking a CPU for. the main character, honestly πŸ‘‘
  • prev_cpu β€” the CPU that p was hanging out on before. its last known location πŸ—ΊοΈ
  • wake_flags β€” the SCX_WAKE_* flags. the vibe check for the wakeup 🌸
  • is_idle β€” an out parameter, bestie. it tells you whether the CPU that got returned is idle β€” so like, is it a good candidate for direct dispatching or not πŸ€”
  • aux β€” an implicit BPF argument used to access bpf_prog_aux, and it's hidden from BPF progs πŸ™ˆ don't worry about it, it's not for you

✨ DESCRIPTION ✨

so basically you can call this from ops.select_cpu, from ops.enqueue, or even from an unlocked context like a BPF test_run call β€” as long as built-in CPU selection is enabled. and "enabled" here means: ops.update_idle is missing, or SCX_OPS_KEEP_BUILTIN_IDLE is set. one of those two, periodt ✨

it returns the picked CPU, and *is_idle tells you whether that picked CPU is currently idle β€” which lowkey makes it a great candidate for direct dispatching πŸ”₯


✨ SEE ALSO ✨

kernel file ./kernel/sched/ext/idle.c, plus the whole friend group 🫢:


anyway that's the whole page, mwah πŸ’‹ this one came from ./kernel/sched/ext and it's dated October 2026 β€” go pick some CPUs, bestie, you got this πŸ¦‹πŸ’–

πŸ“¦ where this page comes from