bpf_cpumask_..._and_set_cpu(9)
π 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βcpuis set in thecpumaskβfalseβcpuwas not set in thecpumask, orcpuis invalid π
ngl thefalsecase is doing double duty β "not there" and "bad CPU" both come back asfalse, so if you need to tell those apart, that's on you, bestie π
π SEE ALSO π
- Kernel file
./kernel/bpf/cpumask.c struct bpf_cpumask(9)bpf_cpumask_create(9)bpf_cpumask_acquire(9)bpf_cpumask_release(9)bpf_cpumask_first(9)bpf_cpumask_first_zero(9)bpf_cpumask_first_and(9)bpf_cpumask_set_cpu(9)bpf_cpumask_clear_cpu(9)bpf_cpumask_test_cpu(9)bpf_cpumask_test_and_clear_cpu(9)bpf_cpumask_setall(9)bpf_cpumask_clear(9)bpf_cpumask_and(9)bpf_cpumask_or(9)bpf_cpumask_xor(9)bpf_cpumask_equal(9)bpf_cpumask_intersects(9)bpf_cpumask_subset(9)bpf_cpumask_empty(9)bpf_cpumask_full(9)bpf_cpumask_copy(9)bpf_cpumask_any_distribute(9)bpf_cpumask_any_and_distribute(9)bpf_cpumask_weight(9)bpf_cpumask_populate(9)
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
- 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