All of lore.kernel.org
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: "Hui Peng" <benquike@gmail.com>,
	"Ridong Chen" <ridong.chen@linux.dev>,
	"Guopeng Zhang" <guopeng.zhang@linux.dev>,
	"Tejun Heo" <tj@kernel.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutný" <mkoutny@suse.com>
Cc: Shuah Khan <shuah@kernel.org>,
	Chen Ridong <chenridong@huawei.com>,
	cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v4 2/3] cgroup/cpuset: prevent activating local partition over remote one
Date: Sat, 26 Sep 2026 21:45:10 -0400	[thread overview]
Message-ID: <b5926447-1b52-4a8b-86d8-8adf40ca5f3f@redhat.com> (raw)
In-Reply-To: <20260924042729.1908863-3-benquike@gmail.com>

On 9/24/26 12:27 AM, Hui Peng wrote:
> Commit 6da580ec656a ("cgroup/cpuset: Don't allow creation of local
> partition over a remote one") added a check in update_prstate() to reject
> creating a top-level local partition whose cs->exclusive_cpus intersects
> subpartitions_cpus.
>
> However, if a top-level cgroup A1 has a child A1/A2 enabled as a remote
> partition on a subset of its exclusive CPUs (X2-3 on A1, CX2-3:P2 on
> A1/A2), and A1 is then set to "root" (P1, becoming "root invalid" via
> update_prstate() because its exclusive CPUs intersect subpartitions_cpus)
> followed by expanding its CPUs to include additional non-remote CPUs
> (CX1-3), update_cpumask() / update_exclusive_cpumask() calls
> validate_partition() without going through update_prstate(). Because
> validate_partition() does not check trialcs->exclusive_cpus against
> subpartitions_cpus, A1 transitions from "root invalid" to a valid local
> partition over the existing remote partition A1/A2 and triggers:
>
>    WARNING: kernel/cgroup/cpuset.c:1943 at update_parent_effective_cpumask+0x189b/0x1fd0
>
> Check trialcs->exclusive_cpus against subpartitions_cpus in
> validate_partition() when !is_partition_valid(cs), and add a regression
> test case to tools/testing/selftests/cgroup/test_cpuset_prs.sh.
>
> Tested in QEMU on Linux 7.3.0-rc3 using
> tools/testing/selftests/cgroup/test_cpuset_prs.sh.
>
> Fixes: 6da580ec656a ("cgroup/cpuset: Don't allow creation of local partition over a remote one")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Hui Peng <benquike@gmail.com>
> ---
>   kernel/cgroup/cpuset.c                            | 4 ++++
>   tools/testing/selftests/cgroup/test_cpuset_prs.sh | 2 ++
>   2 files changed, 6 insertions(+)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 7381fa8502e7..7c5b4a8f1f3a 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -2415,6 +2415,10 @@ static enum prs_errcode validate_partition(struct cpuset *cs, struct cpuset *tri
>   	if (cpumask_empty(trialcs->effective_xcpus))
>   		return PERR_INVCPUS;
>   
> +	if ((parent == &top_cpuset) && !is_partition_valid(cs) &&
> +	    cpumask_intersects(trialcs->exclusive_cpus, subpartitions_cpus))
> +		return PERR_REMOTE;
> +
>   	if (prstate_housekeeping_conflict(trialcs->partition_root_state,
>   					  trialcs->effective_xcpus))
>   		return PERR_HKEEPING;
The code change looks good to me.
> diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> index b732078bf319..4a451350ad84 100755
> --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> @@ -321,6 +321,8 @@ TEST_MATRIX=(
>   	" C1-3:P2  X4:P2    .      .      .    X3:P2    .      .     0 A1:1-2|XA1:1-3|A2:3:XA2:3 A1:P2|A2:P2 1-3"
>   	" C0-3:P2    .      .    C4-6   C0-4     .      .      .     0 A1:0-4|B1:5-6 A1:P2|B1:P0"
>   	" C0-3:P2    .      .    C4-6 C0-4:C0-3  .      .      .     0 A1:0-3|B1:4-6 A1:P2|B1:P0 0-3"
> +	"   X2-3  CX2-3:P2  .      .  P1:CX1-3   .      .      .     0 A1:1|A2:2-3|XA2:2-3 \
> +								       A1:P-1|A2:P2 2-3"
>   

This test case is problematic as it fails on my test system because of a 
bug in the SCHED_DEADLINE task shrink test in validate_change() that can 
be triggered if there are deadline tasks in the system which will fail 
the test. I am going to post a patch to fix that bug. Can you take out 
this test case from this patch as I don't want this test to be 
backported to stable releases? You can send this out as a separate 
testing patch if you want to.

Cheers,
Longman

>   	# Local partition invalidation tests
>   	" C0-3:X1-3:P2 C1-3:X2-3:P2 C2-3:X3:P2 \


  reply	other threads:[~2026-09-27  1:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  4:27 [PATCH v4 0/3] cgroup/cpuset: fix exclusive CPU conflict checks for local and remote partitions Hui Peng
2026-09-24  4:27 ` [PATCH v4 1/3] cgroup/cpuset: return PERR_NOCPUS in remote_partition_enable() on subpartitions_cpus conflict Hui Peng
2026-09-25 19:22   ` Waiman Long
2026-09-26 19:11   ` Tejun Heo
2026-09-28  1:25   ` Ridong Chen
2026-09-24  4:27 ` [PATCH v4 2/3] cgroup/cpuset: prevent activating local partition over remote one Hui Peng
2026-09-27  1:45   ` Waiman Long [this message]
2026-09-28  1:40   ` Ridong Chen
2026-09-28 16:13     ` Waiman Long
2026-09-24  4:27 ` [PATCH v4 3/3] cgroup/cpuset: check sibling effective_xcpus in cpus_excl_conflict() Hui Peng
2026-09-27 23:44   ` Waiman Long
2026-09-28 17:30   ` Tejun Heo

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=b5926447-1b52-4a8b-86d8-8adf40ca5f3f@redhat.com \
    --to=longman@redhat.com \
    --cc=benquike@gmail.com \
    --cc=cgroups@vger.kernel.org \
    --cc=chenridong@huawei.com \
    --cc=guopeng.zhang@linux.dev \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=ridong.chen@linux.dev \
    --cc=shuah@kernel.org \
    --cc=stable@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.