cpumask_nth_and(9)
π cpumask_nth_and β kernel API manual, but make it cute
okay so bestie, you know how there's a whole family of cpumask functions and they all kinda blur together? yeah. this one is cpumask_nth_and, and it lives in the kernel API manual. it's the "give me the Nth cpu" girlie, but with a twist: she's only looking at the cpus that are in both masks. intersection core, no cap. π
πΈ NAME πΈ
cpumask_nth_and β get the Nth cpu in 2 cpumasks
like, literally. the Nth cpu that shows up in the intersection of two cpumasks. that's the whole vibe. β¨
π¦ SYNOPSIS π¦
unsigned int cpumask_nth_and (unsigned int cpu , const struct cpumask
*srcp1 , const struct cpumask *srcp2 );
she takes a cpu, a srcp1 and a srcp2, and hands you back an unsigned int. it's giving "trust me bestie, I got the index." π
π ARGUMENTS π
cpuβ the Nth cpu to find, starting from0. so if you want the very first one, you pass0. zero-indexed like a good little array, periodt. πsrcp1β the cpumask pointer. one half of the intersection situation.srcp2β the cpumask pointer. the other half. together they're like, the main character duo. π«Ά
π₯ RETURN π₯
>= nr_cpu_ids if such cpu doesn't exist.
translation: if you ask for an Nth cpu that isn't there, you don't get an error, you get a number that's >= nr_cpu_ids. so check it, bestie. don't just assume she found something. π
π SEE ALSO π
all her siblings and cousins, because this family is huge and we love her for it. the kernel file is ./include/linux/cpumask.h. π§
cpumask_pr_args(9)cpumask_first(9)cpumask_first_zero(9)cpumask_first_and(9)cpumask_first_andnot(9)cpumask_first_and_and(9)cpumask_last(9)cpumask_next(9)cpumask_next_zero(9)cpumask_next_and(9)cpumask_next_andnot(9)cpumask_next_and_wrap(9)cpumask_next_wrap(9)cpumask_random(9)for_each_cpu(9)for_each_cpu_wrap(9)for_each_cpu_and(9)for_each_cpu_andnot(9)for_each_cpu_or(9)for_each_cpu_from(9)cpumask_any_but(9)cpumask_any_and_but(9)cpumask_any_andnot_but(9)cpumask_nth(9)cpumask_nth_and_andnot(9)cpumask_set_cpu(9)cpumask_clear_cpus(9)cpumask_clear_cpu(9)cpumask_test_cpu(9)cpumask_test_and_set_cpu(9)cpumask_test_and_clear_cpu(9)cpumask_setall(9)cpumask_clear(9)cpumask_and(9)cpumask_or(9)cpumask_weighted_or(9)cpumask_xor(9)cpumask_andnot(9)cpumask_equal(9)cpumask_or_equal(9)cpumask_intersects(9)cpumask_subset(9)cpumask_empty(9)cpumask_full(9)cpumask_weight(9)cpumask_weight_and(9)cpumask_weight_andnot(9)cpumask_shift_right(9)cpumask_shift_left(9)cpumask_copy(9)cpumask_any(9)cpumask_any_and(9)cpumask_of(9)cpumask_parse_user(9)cpumask_parselist_user(9)cpumask_parse(9)cpulist_parse(9)cpumask_size(9)alloc_cpumask_var(9)to_cpumask(9)num_online_cpus(9)cpumap_print_bitmask_to_buf(9)cpumap_print_list_to_buf(9)
okay that's the whole page, no notes. this one's from ./include/linux, dated October 2026, and it's filed under the Kernel API Manual. go forth and find your Nth cpu, bestie. you're gonna slay. πβ¨π
π¦ 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