Linux Documentation
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: "Guopeng Zhang" <guopeng.zhang@linux.dev>,
	"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 6/9] cgroup/cpuset: Don't allow a child root partition under an isolated parent
Date: Mon, 19 Oct 2026 11:58:44 -0400	[thread overview]
Message-ID: <32462fc4-8a28-47f2-a32a-aaaaa9a501d7@redhat.com> (raw)
In-Reply-To: <497db854-17ba-47ae-a9e0-8f1dacb0b205@linux.dev>

On 10/15/26 11:30 PM, Guopeng Zhang wrote:
>
> 在 2026/10/14 22:05, Waiman Long 写道:
>> Although it is not typical for real users to create a complicated nested
>> partition hierarchy, it is currently allowed to create nested root and
>> isolated partitions. In addition, disabling or invalidating a partition
>> should always be allowed especially when the cpuset is being deleted.
>>
>> With a nested root and isolated partition hierarchy, it is possible
>> that all active housekeeping CPUs can be exhausted when disabling or
>> invalidating a root partition and returning its CPUs to the isolated
>> parent.
>>
>> One way to avoid this problem is to disallow the creation of a root
>> partition under an isolated parent. It is indeed a new limitation imposed
>> on the existing cpuset partition functionality. However an isolated
>> partition is usually a left node where scheduling and some other kernel
>> noises are disabled. It doesn't make much sense to create a child root
>> partition under an isolated parent and remove some CPUs from the set
>> of isolated CPUs again. Creation of a child isolated partition under a
>> root or isolated parent is still allowed.
>>
>> The cgroup-v2 documentation is also updated to reflect this new
>> limitation. New test cases are added to test_cpuset_prs.sh to verify
>> this new behavior. Some existing test cases are also updated accordingly.
>>
>> Signed-off-by: Waiman Long <longman@redhat.com>
>> ---
>>   Documentation/admin-guide/cgroup-v2.rst           |  4 +++-
>>   kernel/cgroup/cpuset-internal.h                   |  1 +
>>   kernel/cgroup/cpuset.c                            | 13 +++++++++++++
>>   tools/testing/selftests/cgroup/test_cpuset_prs.sh | 14 ++++++++------
>>   4 files changed, 25 insertions(+), 7 deletions(-)
>>
>> diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
>> index bd8c80f3bbc9..2c445829e24d 100644
>> --- a/Documentation/admin-guide/cgroup-v2.rst
>> +++ b/Documentation/admin-guide/cgroup-v2.rst
>> @@ -2767,7 +2767,9 @@ Cpuset Interface Files
>>   	be retained, but behaves more like a "member".
>>   
>>   	All possible state transitions among "member", "root" and
>> -	"isolated" are allowed.
>> +	"isolated" are allowed with the exception that a local child
>> +	"root" partition is not allowed to be created under an "isolated"
>> +	parent partition.
>>   
>>   	On read, the "cpuset.cpus.partition" file can show the following
>>   	values.
>> diff --git a/kernel/cgroup/cpuset-internal.h b/kernel/cgroup/cpuset-internal.h
>> index 5da9c91295b0..2e44dc8634dc 100644
>> --- a/kernel/cgroup/cpuset-internal.h
>> +++ b/kernel/cgroup/cpuset-internal.h
>> @@ -35,6 +35,7 @@ enum prs_errcode {
>>   	PERR_HKEEPING,
>>   	PERR_ACCESS,
>>   	PERR_REMOTE,
>> +	PERR_ISOPARENT,
>>   };
>>   
>>   /* bits in struct cpuset flags field */
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index 40c004386af0..681701ba46e1 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -60,6 +60,7 @@ static const char * const perr_strings[] = {
>>   	[PERR_HKEEPING]  = "partition config conflicts with housekeeping setup",
>>   	[PERR_ACCESS]    = "Enable partition not permitted",
>>   	[PERR_REMOTE]    = "Have remote partition underneath",
>> +	[PERR_ISOPARENT] = "Root partition is not allowed with isolated parent",
>>   };
>>   
>>   /*
>> @@ -2865,6 +2866,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
>>   	int err = PERR_NONE, old_prs = cs->partition_root_state;
>>   	struct cpuset *parent = parent_cs(cs);
>>   	struct tmpmasks tmpmask;
>> +	int parent_prs = parent->partition_root_state;
>>   	bool isolcpus_updated = false;
>>   	bool disable_partition = false;
>>   
>> @@ -2910,6 +2912,14 @@ static int update_prstate(struct cpuset *cs, int new_prs)
>>   			enum partition_cmd cmd = (new_prs == PRS_ROOT)
>>   					       ? partcmd_enable : partcmd_enablei;
>>   
>> +			/*
>> +			 * It is not allowed to create a root partition under
>> +			 * an isolated parent partition.
>> +			 */
>> +			if ((new_prs == PRS_ROOT) && (parent_prs == PRS_ISOLATED)) {
>> +				err = PERR_ISOPARENT;
>> +				goto out;
>> +			}
> I tested the following case. Writing root initially leaves C invalid, but
> updating its cpuset.cpus makes it valid again.
>
> 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 isolated > A/cpuset.cpus.partition
>      # echo +cpuset > A/cgroup.subtree_control
>      # mkdir A/C
>      # echo 1 > A/C/cpuset.cpus
>      # echo root > A/C/cpuset.cpus.partition
>      # cat A/C/cpuset.cpus.partition
>      root invalid (Root partition is not allowed with isolated parent)
>      # echo 1-2 > A/C/cpuset.cpus
>      # cat A/C/cpuset.cpus.partition
>      root
>
> C becomes a valid root partition.

Thank for finding this bug. Yes, the patch is missing check in some 
places. Will fix in the next version.

Cheers,
Longman


  reply	other threads:[~2026-10-19 15:58 UTC|newest]

Thread overview: 20+ 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
2026-10-19 15:20     ` Waiman Long
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-16  2:18   ` Guopeng Zhang
2026-10-19 15:24     ` 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-16  2:21   ` Guopeng Zhang
2026-10-14 14:05 ` [PATCH-next v3 5/9] cgroup/cpuset: Properly disabling partition when partition state switching fails Waiman Long
2026-10-16  2:22   ` Guopeng Zhang
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-16  3:30   ` Guopeng Zhang
2026-10-19 15:58     ` Waiman Long [this message]
2026-10-14 14:05 ` [PATCH-next v3 7/9] selftests/cgroup: Add tests for isolcpus housekeeping check Waiman Long
2026-10-16  3:32   ` Guopeng Zhang
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=32462fc4-8a28-47f2-a32a-aaaaa9a501d7@redhat.com \
    --to=longman@redhat.com \
    --cc=benquike@gmail.com \
    --cc=cgroups@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=guopeng.zhang@linux.dev \
    --cc=hannes@cmpxchg.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --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