cpumask_test_and_clear_cpu(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… cpumask_test_and_clear_cpu(9) β€” a Kernel API Manual moment

okay so bestie, this is a page from the Kernel API Manual, and today's main character is cpumask_test_and_clear_cpu. it lives in ./include/linux/cpumask.h and honestly? she's giving one-job-and-she-does-it energy. let's get into it ✨


🌸 NAME 🌸

cpumask_test_and_clear_cpu β€” atomically test and clear a cpu in a cpumask πŸŽ€

like, she checks if the cpu is there and wipes it in one go. atomic. no take-backs, no race conditions, periodt.


⭐ SYNOPSIS ⭐

bool cpumask_test_and_clear_cpu (int cpu , struct cpumask *cpumask );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • cpu β€” the cpu number, and heads up, it has to be < nr_cpu_ids. so like, stay in bounds bestie, don't be out here indexing into the void πŸ’€
  • cpumask β€” the cpumask pointer. that's the bitmap she's gonna poke at 🫢

πŸ‘‘ DESCRIPTION πŸ‘‘

real talk: this is a test_and_clear_bit wrapper for cpumasks. that's it. that's the whole vibe. she wraps, she tests, she clears, she slays πŸ’…


πŸ”₯ RETURN πŸ”₯

returns true if cpu is set in the old bitmap of cpumask, else it returns false.

no cap β€” key word is old bitmap. you're getting told what it looked like before she cleared it πŸ™ˆ


🌈 SEE ALSO 🌈

Kernel file ./include/linux/cpumask.h, plus the whole cpumask friend group (they're all linked, iykyk):


πŸ’– little reminder: cpu must be < nr_cpu_ids. that's not a suggestion, that's the contract. respect the bounds and nobody gets hurt 🧚

and that's the page!! big kisses from ./include/linux, dated October 2026, version vibes courtesy of the Kernel API Manual for cpumask_test_and_clear_cpu(9). she's iconic, she's atomic, she's out πŸŽ€βœ¨πŸ’œ

πŸ“¦ where this page comes from