cpuset_nodes_allowed(9)
π 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 tostruct cgroup. your cgroup of interest, your main character β¨maskβ a pointer tostruct nodemask_tthat 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 thecpuset_mutexorcallback_lockwhen it accesseseffective_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
maskmay be empty, becausecs->effective_memscan be rebound during this very call πͺοΈ - also, nodes in
maskare 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:
cpuset_lock(9)cpuset_full_lock(9)partition_is_populated(9)alloc_cpumasks(9)alloc_tmpmasks(9)free_tmpmasks(9)dup_or_alloc_cpuset(9)free_cpuset(9)cpus_excl_conflict(9)cpuset_update_tasks_cpumask(9)compute_effective_cpumask(9)compute_effective_nodemask(9)rm_siblings_excl_cpus(9)update_parent_effective_cpumask(9)compute_partition_effective_cpumask(9)update_sibling_cpumasks(9)validate_partition(9)partition_cpus_change(9)update_cpumask(9)update_exclusive_cpumask(9)cpuset_update_tasks_nodemask(9)update_prstate(9)cpuset_css_alloc(9)cpuset_init(9)cpuset_hotplug_update_tasks(9)cpuset_handle_hotplug(9)cpuset_init_smp(9)cpuset_cpus_allowed_locked(9)cpuset_cpus_allowed(9)cpuset_cpus_allowed_fallback(9)cpuset_mems_allowed(9)cpuset_nodemask_valid_mems_allowed(9)cpuset_spread_node(9)cpuset_mem_spread_node(9)cpuset_mems_allowed_intersects(9)cpuset_print_current_mems_allowed(9)
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
- 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