cpumask_first_and(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 NAME 🌸

cpumask_first_and β€” bestie, this is the one that returns the first cpu from *srcp1 & *srcp2, okay?? Like, you hand it two cpumasks, it finds the CPUs they share, and it gives you the lowest-numbered one of that overlap. Iconic behaviour, honestly. πŸ’…


✨ SYNOPSIS ✨

unsigned int cpumask_first_and (const struct cpumask *srcp1 , const struct cpumask *srcp2 );

Lowkey the whole personality of this function is right there in one line. 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • srcp1 β€” the first input. that's it, that's the descriptor, she's your first mask πŸ’–
  • srcp2 β€” the second input. the other half of the &, she's the second mask πŸ’–
ngl the manpage keeps these two descriptions so short, but the vibe check is clear: both are const struct cpumask *, both get AND-ed together, both matter. no cap. ✨

πŸŽ€ RETURN πŸŽ€

>= nr_cpu_ids if no cpus set in both. 😭

Read that again, gently: if the two masks share zero CPUs, you don't get a real CPU back β€” you get a value >= nr_cpu_ids (i.e. not a valid CPU id at all), so go check for it, bestie, don't just index an array with it. fr fr.

See also cpumask_next_and. πŸ‘‘


🌈 SEE ALSO 🌈

Okay so the friend group is huge, and honestly they all ate. Kernel file ./include/linux/cpumask.h:

Like… the whole cpumask family showed up to the group chat. obsessed. πŸ§šπŸ’œ


πŸ’€ reminder bestie: >= nr_cpu_ids means no shared CPUs, not "cpu number thirty-something". do not pass go, do not index anything.

and that's the page!! πŸ“ source is ./include/linux, dated October 2026, and the manual is cpumask_first_and(9) β€” mwah, go read cpumask_next_and(9) next, ily, bye!! πŸ’–πŸŽ€βœ¨

πŸ“¦ where this page comes from