cpuset_nodes_allowed(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… cpuset_nodes_allowed β€” the kernel API manual, bestie edition

okay so you're looking at cpuset_nodes_allowed(9), and yes, it's exactly as niche as it sounds. It lives in the Kernel API Manual. Sit down, hydrate, and let's get into it 🫢


✨ NAME ✨

cpuset_nodes_allowed β€” grab the effective_mems mask out of a cgroup cpuset. that's the whole gig πŸ’–


🌸 SYNOPSIS 🌸

void cpuset_nodes_allowed (struct cgroup *cgroup , nodemask_t *mask );

Like, look at her. Void return, two args, zero drama.


πŸŽ€ ARGUMENTS πŸŽ€

  • cgroup β€” a pointer to struct cgroup. your cgroup of interest, your main character ✨
  • mask β€” a pointer to struct nodemask_t that gets returned to you. this is where the answer lands πŸ’Œ

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's what actually happens πŸ‘‘: this returns the effective_mems mask from a cgroup cpuset if it's cgroup v2 and it has the cpuset subsys. Otherwise? You get node_states[N_MEMORY]. That's the fallback, no cap πŸ’€

Now the part you need to know, and I'm gonna say it with my whole chest:

This function intentionally avoids taking the cpuset_mutex or callback_lock when it accesses effective_mems. Not a bug. Not an oopsie. On purpose.

Why tho?? Because the effective_mems you get is stale immediately after the query anyway. Like, genuinely instantly. The example given is exactly that: effective_mems gets updated right after the lock is released but before the function returns. So locking would've been doing all that work for literally nothing 😭

Consequences, and please read these fr fr:

  • the returned mask may be empty, because cs->effective_mems can be rebound during this very call πŸŒͺ️
  • also, nodes in mask are not guaranteed to be online due to hot plugins πŸ”₯

So like… callers beware. You should check the mask for validity on return, based on whatever you're planning to do with it next. Your subsequent use, your responsibility, iykyk πŸ’…


🌈 SEE ALSO 🌈

Kernel file ./kernel/cgroup/cpuset.c, plus the whole friend group:

like, the entire cpuset extended universe, slay 🧚


and that's the page!! mwah πŸ’‹ this little icon came out of ./kernel/cgroup, dated October 2026, and it answers to the name cpuset_nodes_allowed(9). go forth and check your masks for validity bestie πŸ“πŸ’œ

πŸ“¦ where this page comes from