mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guopeng Zhang <guopeng.zhang@linux.dev>
To: "Waiman Long" <longman@redhat.com>,
	"Ridong Chen" <ridong.chen@linux.dev>,
	"Tejun Heo" <tj@kernel.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutný" <mkoutny@suse.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Randy Dunlap" <rdunlap@infradead.org>
Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Hui Peng <benquike@gmail.com>
Subject: Re: [PATCH-next v3 1/9] cgroup/cpuset: Fix a missing isolated_cpus update in update_cpumasks_hier()
Date: Thu, 15 Oct 2026 21:02:54 +0800	[thread overview]
Message-ID: <0bd7f6ff-3675-4447-a62a-a2047241e3e6@linux.dev> (raw)
In-Reply-To: <20261014140548.575122-2-longman@redhat.com>



在 2026/10/14 22:05, Waiman Long 写道:
> It is found that when a local isolated partition is being invalidated
> because its root partition parent is no longer valid, the isolated_cpus
> cpumask may not be properly updated. If the parent was previously
> an isolated partition, its invalidation should have properly updated
> isolated_cpus before and no action will be needed.
> 
> Fix that by calling isolated_cpus_update() in this invalidation case
> to update isolated_cpus. A test case in test_cpuset_prs.sh is modified
> to test that.
> 
> Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---
>  kernel/cgroup/cpuset.c                        | 19 ++++++++++++++-----
>  .../selftests/cgroup/test_cpuset_prs.sh       |  4 ++--
>  2 files changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 0ebba2d646c3..6b5c870e5607 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -2229,7 +2229,9 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
>  		 * cpuset if the parent's effective_cpus changes.
>  		 */
>  		if ((cp != cs) && old_prs) {
> -			switch (parent->partition_root_state) {
> +			int parent_prs = parent->partition_root_state;
> +
> +			switch (parent_prs) {
>  			case PRS_ROOT:
>  			case PRS_ISOLATED:
>  				update_parent = true;
> @@ -2238,11 +2240,18 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
>  			default:
>  				/*
>  				 * When parent is not a partition root or is
> -				 * invalid, child partition roots become
> -				 * invalid too.
> +				 * invalid, child partition roots become invalid
> +				 * too. For an isolated partition with root
> +				 * partition parent, isolated_cpus_updated()
> +				 * is called to update isolated_cpus.
>  				 */
> -				if (is_partition_valid(cp))
> -					new_prs = -cp->partition_root_state;
> +				if (is_partition_valid(cp)) {
> +					new_prs = -old_prs;
> +					if ((old_prs == PRS_ISOLATED) &&
> +					    (parent_prs == -PRS_ROOT))
> +						isolated_cpus_update(old_prs, new_prs,
> +								     cp->effective_xcpus);
> +				}

I tested switching a parent partition from root to member and found that
CPUs can remain listed in cpuset.cpus.isolated. CPUs 0-15 are online, with
nohz_full=2-15 and no isolcpus:

    # cd /sys/fs/cgroup
    # echo +cpuset > cgroup.subtree_control
    # mkdir A
    # echo 1-2 > A/cpuset.cpus
    # echo root > A/cpuset.cpus.partition
    # echo +cpuset > A/cgroup.subtree_control
    # mkdir A/C
    # echo 2 > A/C/cpuset.cpus
    # echo isolated > A/C/cpuset.cpus.partition
    # cat cpuset.cpus.isolated
    2
    # echo member > A/cpuset.cpus.partition
    # cat A/C/cpuset.cpus.partition
    isolated invalid (Parent is not a partition root)
    # cat cpuset.cpus.isolated
    2

A is now a member and C is invalid, so cpuset.cpus.isolated should be
empty here, but CPU 2 remains.

Thanks,
Guopeng>  				WRITE_ONCE(cp->prs_err,
>  					   is_partition_invalid(parent)
>  					   ? PERR_INVPARENT : PERR_NOTPART);
> diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> index 7efd5e645767..874a8a161236 100755
> --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> @@ -292,9 +292,9 @@ TEST_MATRIX=(
>  								       A1:P0|A2:P2|A3:P1 2-4|2-3"
>  	"   C0-4    C1-4  C2-4     .    X2-4  X2-4:P2 X3-4:P1   .    0 A1:0-1|A2:2|A3:3-4 \
>  								       A1:P0|A2:P2|A3:P1 2"
> -	" C0-4:X2-4 C1-4:X2-4:P2 C2-4:X4:P1 \
> +	" C0-4:X2-4 C1-4:X2-4:P1 C2-4:X4:P2 \
>  				   .      .      X5      .      .    0 A1:0-4|A2:1-4|A3:2-4 \
> -								       A1:P0|A2:P-2|A3:P-1 ."
> +								       A1:P0|A2:P-1|A3:P-2 ."
>  	" C0-4:X2-4 C1-4:X2-4:P2 C2-4:X4:P1 \
>  				   .      .      .      X1      .    0 A1:0-1|A2:2-4|A3:2-4 \
>  								       A1:P0|A2:P2|A3:P-1 2-4"


  reply	other threads:[~2026-10-15 13:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 14:05 [PATCH-next v3 0/9] cgroup/cpuset: Fix various housekeeping check problems Waiman Long
2026-10-14 14:05 ` [PATCH-next v3 1/9] cgroup/cpuset: Fix a missing isolated_cpus update in update_cpumasks_hier() Waiman Long
2026-10-15 13:02   ` Guopeng Zhang [this message]
2026-10-14 14:05 ` [PATCH-next v3 2/9] cgroup/cpuset: Consolidate isolated_cpus_can_update() into prstate_housekeeping_conflict() Waiman Long
2026-10-15 13:03   ` Guopeng Zhang
2026-10-14 14:05 ` [PATCH-next v3 3/9] cgroup/cpuset: Consider all the exclusive CPUs when doing housekeeping check Waiman Long
2026-10-14 14:05 ` [PATCH-next v3 4/9] cgroup/cpuset: Do housekeeping check before converting invalid partition to valid Waiman Long
2026-10-14 14:05 ` [PATCH-next v3 5/9] cgroup/cpuset: Properly disabling partition when partition state switching fails Waiman Long
2026-10-14 14:05 ` [PATCH-next v3 6/9] cgroup/cpuset: Don't allow a child root partition under an isolated parent Waiman Long
2026-10-14 14:05 ` [PATCH-next v3 7/9] selftests/cgroup: Add tests for isolcpus housekeeping check Waiman Long
2026-10-14 14:05 ` [PATCH-next v3 8/9] selftests/cgroup: Add tests for nohz_full " Waiman Long
2026-10-14 14:05 ` [PATCH-next v3 9/9] selftests/cgroup: Skip test_cpuset_prs.sh test if some required CPUs are offline Waiman Long

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=0bd7f6ff-3675-4447-a62a-a2047241e3e6@linux.dev \
    --to=guopeng.zhang@linux.dev \
    --cc=benquike@gmail.com \
    --cc=cgroups@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=hannes@cmpxchg.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mkoutny@suse.com \
    --cc=rdunlap@infradead.org \
    --cc=ridong.chen@linux.dev \
    --cc=shuah@kernel.org \
    --cc=tj@kernel.org \
    /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®