cpumask_any_andnot_but(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

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

okay so we're in the Kernel API Manual today and the star of the show is cpumask_any_andnot_but(9). she's a cpu picker. she's got opinions. let's go ✨


🌸 NAME 🌸

cpumask_any_andnot_but β€” pick an arbitrary cpu from *mask1 & ~*mask2, but not this one. 🚫 like she's literally excluding one specific cpu from the whole situation, no cap.


✨ SYNOPSIS ✨

unsigned int cpumask_any_andnot_but (const struct cpumask *mask1 , const
struct cpumask *mask2 , int cpu );

that's the whole signature, character for character, don't @ me 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • mask1 β€” the first input cpumask πŸ’– one half of the equation.
  • mask2 β€” the second input cpumask πŸ’œ the other half, the one getting andnot-ed out.
  • cpu β€” the cpu to ignore πŸ™ˆ miss girl gets left on read.

πŸ”₯ DESCRIPTION πŸ”₯

so the vibe is: you give her two masks and a cpu to skip, and she hands you back a cpu. simple. iconic.

if cpu == -1, the function returns the first matching cpu. periodt. πŸ’…

and she returns >= nr_cpu_ids if no cpus are set β€” so like, if there's literally nothing matching, you get a value that's out of range, which is your signal that the well was dry 😭 no cpus for you.

ngl, always check that return value against nr_cpu_ids before you go using it as an actual cpu id. that's the whole warning, bestie, don't skip it πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

she did NOT come alone. this is her whole friend group, and they all live in the kernel file ./include/linux/cpumask.h:

like, that's the entire cpumask cinematic universe and she's in it πŸ“


okay that's the page!! source is ./include/linux, dated October 2026, and she's filed under cpumask_any_andnot_but(9) in the Kernel API Manual β€” go pick some cpus responsibly bestie, mwah πŸ§šβ€β™€οΈπŸ’œ

πŸ“¦ where this page comes from