Re: [PATCH-next v3 07/11] cgroup/cpuset: Make sure compute_partition_effective_cpumask() is only called for valid partition

From: Guopeng Zhang

Date: Mon Oct 26 2026 - 03:15:06 EST




在 2026/10/26 05:44, Waiman Long 写道:
> With visual inspection to make sure that
> compute_partition_effective_cpumask() is only called for valid partition
> root, it was found that the function can be called for an invalidated
> partition near the end of cpuset_hotplug_update_tasks(). When partcmd is
> set, update_parent_effective_cpumask() is called to either invalidate a
> valid partition or with partcmd_update to check if an invalid partition
> can be switched back to valid. In both cases, cpuset_force_rebuild()
> should be invoked. However, compute_partition_effective_cpumask()
> should only be called when an invalid partition is switched back to
> valid. When a partition is invalidated, compute_effective_cpumask()
> should be called instead.
>
> Also add a WARN_ON_ONCE() in compute_partition_effective_cpumask() to
> ensure that a valid partition root is passed in.
>
> Fixes: 72c6303acfa1 ("cgroup/cpuset: Take isolated CPUs out of workqueue unbound cpumask")
> Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
> ---
> kernel/cgroup/cpuset.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 8903e441ecc1..53fa3970946e 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -2163,6 +2163,8 @@ static void compute_partition_effective_cpumask(struct cpuset *cs,
> struct cpuset *child;
> bool populated = partition_is_populated(cs, NULL);
>
> + WARN_ON_ONCE(!is_partition_valid(cs));
> +
> /*
> * Check child partition roots to see if they should be
> * invalidated when
> @@ -4035,9 +4037,12 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)
>
> if (partcmd >= 0) {
> update_parent_effective_cpumask(cs, partcmd, NULL, tmp);
> - if ((partcmd == partcmd_invalidate) || is_partition_valid(cs)) {
> + if (is_partition_valid(cs)) {
> compute_partition_effective_cpumask(cs, &new_cpus);
> cpuset_force_rebuild();
> + } else if (partcmd == partcmd_invalidate) {
> + compute_effective_cpumask(&new_cpus, cs, parent);
> + cpuset_force_rebuild();
> }
> }
>

Acked-by: Guopeng Zhang <zhangguopeng@xxxxxxxxxx>

Thanks,
Guopeng