bpf_cpumask_..._and_set_cpu(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… bpf_cpumask_..._and_set_cpu(9) β€” from the Kernel API Manual, bestie πŸŽ€

okay so real talk, this one lives in the Linux kernel's Kernel API Manual section 9, and it's a little kfunc with main character energy: it checks a CPU and sets it at the same time. one move, two jobs. periodt. ✨


🌸 NAME 🌸

bpf_cpumask_test_and_set_cpu β€” atomically test and set a CPU in a BPF cpumask. that's the whole vibe: atomic, so no one can slide in and mess with it halfway through. πŸ¦‹


✨ SYNOPSIS ✨

__bpf_kfunc bool bpf_cpumask_test_and_set_cpu (u32 cpu , struct
bpf_cpumask *cpumask );

it's giving: give it a cpu and a cpumask, get a bool back. no cap. 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • cpu β€” the CPU that's getting set and being queried for. yes bestie, both, in the same breath πŸ’…
  • cpumask β€” the BPF cpumask we're setting and querying, i.e. the one we're asking "do you contain this CPU tho?" 🧚

πŸ‘‘ RETURN πŸ‘‘

  • true β€” cpu is set in the cpumask βœ…
  • false β€” cpu was not set in the cpumask, or cpu is invalid πŸ™ˆ

ngl the false case is doing double duty β€” "not there" and "bad CPU" both come back as false, so if you need to tell those apart, that's on you, bestie 😭

πŸ’œ SEE ALSO πŸ’œ

fr fr the whole cpumask friend group is iconic, go say hi 🌈


okay that's the page!! this one shipped out of ./kernel/bpf and it's dated October 2026 β€” so screenshot it, cite it, love it πŸ’– mwah, study hard, and remember: test and set, atomically, every time ⭐

πŸ“¦ where this page comes from