cpumask_nth(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… NAME πŸ’…

cpumask_nth β€” bestie, this is the one that grabs the Nth cpu out of a cpumask πŸŽ€

(also hi, this is the cpumask_nth(9) page from the Kernel API Manual, welcome to the group chat ✨)


✨ SYNOPSIS ✨

okay so here's the exact signature, no cap, don't let the line break jump-scare you:

unsigned int cpumask_nth (unsigned int cpu , const struct cpumask *srcp
);

πŸŽ€ ARGUMENTS πŸŽ€

  • cpu β€” the Nth cpu to find, starting from 0. yes it's called cpu but it's literally the index, starting at zero, that's just how it is πŸ’€
  • srcp β€” the cpumask pointer 🫢 the list you're digging through

πŸ”₯ RETURN πŸ”₯

it hands you back an unsigned int, and if that cpu doesn't exist? you get >= nr_cpu_ids. that's your "girl she's not here" signal πŸ™ˆ so always check it before you go indexing anything, periodt.


πŸ¦‹ SEE ALSO πŸ¦‹

the whole friend group lives in the kernel file ./include/linux/cpumask.h and honestly there are so many siblings, here's the full roll call 🧚:

like I said. huge family. iconic behavior honestly πŸ‘‘


ngl the only gotcha: if cpumask_nth gives you >= nr_cpu_ids, that cpu is not in the mask. don't be delulu, check it πŸ’€

okay that's the whole page bestie, love u, bye 🫢

this cutie pie was served straight out of ./include/linux, dated October 2026, and you can cite it as cpumask_nth(9) β€” mwah πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from