mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Guopeng Zhang <guopeng.zhang@linux.dev>,
	Tejun Heo <tj@kernel.org>, Ridong Chen <ridong.chen@linux.dev>
Cc: "Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutný" <mkoutny@suse.com>,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Guopeng Zhang" <zhangguopeng@kylinos.cn>
Subject: Re: [PATCH 2/2] cgroup/cpuset: Fix invalid local partition recovery
Date: Wed, 21 Oct 2026 23:28:40 -0400	[thread overview]
Message-ID: <16db5b91-677e-47ec-b1de-760111b99d23@redhat.com> (raw)
In-Reply-To: <20261010075947.333549-3-guopeng.zhang@linux.dev>

On 10/10/26 3:59 AM, Guopeng Zhang wrote:
> From: Guopeng Zhang <zhangguopeng@kylinos.cn>
>
> An invalid local partition may fail to recover after its exclusive CPU
> list is changed to a valid one.
>
> This can be reproduced on a cgroup v2 system with CPUs 0-7 online:
>
>      cd /sys/fs/cgroup
>      echo +cpuset > cgroup.subtree_control
>      mkdir A
>      echo 0-7 > A/cpuset.cpus
>      echo 0-7 > A/cpuset.cpus.exclusive
>      echo root > A/cpuset.cpus.partition
>      cat A/cpuset.cpus.partition
>      echo 1 > A/cpuset.cpus.exclusive
>      cat A/cpuset.cpus.partition
>
> The first read reports root invalid because all CPUs were requested.
> After the mask is changed to CPU 1, the partition should become valid,
> but it remains invalid with PERR_NOCPUS.
>
> update_exclusive_cpumask() calls partition_cpus_change() before updating
> cs->exclusive_cpus. update_parent_effective_cpumask() then gets the
> old 0-7 mask from user_xcpus() and sets PERR_NOCPUS even though the new
> mask leaves CPUs for the parent.
>
> Move the exclusive_cpus update before partition_cpus_change() so that
> the partition update sees the new mask.
>
> Fixes: 46c521bac592 ("cgroup/cpuset: Enable invalid to valid local partition transition")
> Signed-off-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
> ---
>   kernel/cgroup/cpuset.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index de7553459adc..e96bc66ffa07 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -2546,10 +2546,14 @@ static int update_exclusive_cpumask(struct cpuset *cs, struct cpuset *trialcs,
>   		return -ENOMEM;
>   
>   	trialcs->prs_err = PERR_NONE;
> -	partition_cpus_change(cs, trialcs, &tmp);
>   
>   	spin_lock_irq(&callback_lock);
>   	cpumask_copy(cs->exclusive_cpus, trialcs->exclusive_cpus);
> +	spin_unlock_irq(&callback_lock);
> +
> +	partition_cpus_change(cs, trialcs, &tmp);
> +
> +	spin_lock_irq(&callback_lock);
>   	cpumask_copy(cs->effective_xcpus, trialcs->effective_xcpus);
>   	if ((old_prs > 0) && !is_partition_valid(cs))
>   		reset_partition_data(cs);

With the patch series that I have just sent out, I can't reproduce this 
problem. My patch 2 of the series change 
update_parent_effective_cpumask() to not use user_xcpus() anymore. So 
that should fix the problem.

Cheers, Longman


  reply	other threads:[~2026-10-22  3:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10  7:59 [PATCH 0/2] cgroup/cpuset: Fix partition updates using stale CPU masks Guopeng Zhang
2026-10-10  7:59 ` [PATCH 1/2] cgroup/cpuset: Fix cpuset.cpus update in a remote partition Guopeng Zhang
2026-10-22  3:23   ` Waiman Long
2026-10-10  7:59 ` [PATCH 2/2] cgroup/cpuset: Fix invalid local partition recovery Guopeng Zhang
2026-10-22  3:28   ` Waiman Long [this message]
2026-10-20  2:51 ` [PATCH 0/2] cgroup/cpuset: Fix partition updates using stale CPU masks Guopeng Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16db5b91-677e-47ec-b1de-760111b99d23@redhat.com \
    --to=longman@redhat.com \
    --cc=cgroups@vger.kernel.org \
    --cc=guopeng.zhang@linux.dev \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=ridong.chen@linux.dev \
    --cc=tj@kernel.org \
    --cc=zhangguopeng@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®