On 2025/12/22 14:09, Bing Jiao wrote:
On Mon, Dec 22, 2025 at 10:51:49AM +0800, Chen Ridong wrote:
On 2025/12/22 7:36, Bing Jiao wrote:
-void cpuset_node_filter_allowed(struct cgroup *cgroup, nodemask_t *mask) -{
- struct cgroup_subsys_state *css;
- struct cpuset *cs;
- if (!cpuset_v2())
return;- css = cgroup_get_e_css(cgroup, &cpuset_cgrp_subsys);
- if (!css)
return;- /* Follows the same assumption in cpuset_node_allowed() */
- cs = container_of(css, struct cpuset, css); nodes_and(*mask, *mask, cs->effective_mems); css_put(css);
}
Oh, I see you merged these two functions here.
However, I think cpuset_get_mem_allowed would be more versatile in general use.
You can then check whether the returned nodemask intersects with your target mask. In the future, there may be scenarios where users simply want to retrieve the effective masks directly.
Hi Ridong, thank you for the suggestions.
I agree that returning a nodemask would provide greater versatility.
I think cpuset_get_mem_allowed_relax() would be a better name, since we do not need the locking and online mem guarantees compared to an similar function cpuset_mems_allowed().
I think the key difference between cpuset_mems_allowed and the helper you intend to implement lies not in locking or online memory guarantees, but in the input parameter: you want to retrieve cpuset->effective_mems for a cgroup from another subsystem.
The cs->effective_mems should typically only include online nodes, except during brief transitional periods such as hotplug operations. Similarly, node migration logic also requires online nodes.
Therefore, cpuset_get_mem_allowed seems acceptable to me.
Additionally, you may consider calling guarantee_online_mems inside your new helper to ensure consistency.