Re: [PATCH v2 2/3] cgroup/cpuset: Recompute effective cpumask in update_cpumasks_hier() after calling update_parent_effective_cpumask()

From: Guopeng Zhang

Date: Sun Nov 01 2026 - 20:29:55 EST




在 2026/10/31 03:07, Waiman Long 写道:
> It is reported by sashiko that calling update_parent_effective_cpumask()
> may clobber tmp->new_cpus when update_sibling_cpumasks() needs to be
> called due to possible change in the parent's effective_cpus value.
> Therefore the new effective cpumask has to be recomputed after calling
> update_parent_effective_cpumask() to get a correct value back into
> tmp->new_cpus.
>
> Fixes: f0af1bfc27b5 ("cgroup/cpuset: Relax constraints to partition & cpus changes")
> Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
> ---
> kernel/cgroup/cpuset.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 39c81a0a8ab9..ed014ecb770c 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -2359,12 +2359,12 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
> update_parent_effective_cpumask(cp, partcmd_update, NULL, tmp);
> /*
> * Capture current partition_root_state as it may have
> - * changed. Recompute effective cpumask if changed.
> + * changed. Always recompute effective cpumask as tmp->new_cpus
> + * may be clobbered when update_sibling_cpumasks() is called
> + * within update_parent_effective_cpumask().
> */
> new_prs = cp->partition_root_state;
> - if (new_prs != old_prs) {
> - compute_effective_cpumask(tmp->new_cpus, cp, parent);
> - }
> + compute_effective_cpumask(tmp->new_cpus, cp, parent);
> }
>
> spin_lock_irq(&callback_lock);

Reviewed-by: Guopeng Zhang <zhangguopeng@xxxxxxxxxx>
Tested-by: Guopeng Zhang <zhangguopeng@xxxxxxxxxx>

Thanks,
Guopeng