for_each_cpu_andnot(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… for_each_cpu_andnot(9) β€” Kernel API Manual, but make it make sense πŸŽ€

okay so bestie, welcome to the <pink>Kernel API Manual</pink> ✨ β€” this one's a macro, it's iconic, and it's about to save you so much temporary-mask drama. Let's get into it πŸ¦‹


✨ NAME ✨

for_each_cpu_andnot β€” loop over every cpu that's chillin' in one mask but not in the other. it's giving "you're invited but she's not" πŸ’…


🌸 SYNOPSIS 🌸

for_each_cpu_andnot (cpu , mask1 , mask2 );

πŸŽ€ ARGUMENTS πŸŽ€

  • cpu β€” the iterator, an (optionally unsigned) integer. it's the little counter that goes brrr through your cpus πŸ”₯
  • mask1 β€” pointer to the first cpumask. the "yes bestie" list πŸ’–
  • mask2 β€” pointer to the second cpumask. the "nope, excluded" list πŸ™ˆ

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜•: this macro literally saves you from declaring a temporary CPU mask in, like, a million different places. no cap. it is equivalent to:

struct cpumask tmp; cpumask_andnot(tmp, mask1, mask2); for_each_cpu(cpu, tmp) ...

like, same energy, less clutter. obsessed πŸ’œ

lowkey important: after the loop finishes, cpu is >= nr_cpu_ids. fr fr, don't be surprised by that, it's by design ✨

πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./include/linux/cpumask.h β€” and honestly, the whole cpumask friend group showed up. main character energy all around 🌈


and that's the whole page, bestie 🫢 this lil macro came from ./include/linux and it's dated October 2026 β€” go forth and iterate responsibly, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from