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>
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH-next v3 03/11] cgroup/cpuset: Fix incorrect effective_cpus bug in update_cpumasks_hier()
Date: Mon, 26 Oct 2026 14:46:47 +0800 [thread overview]
Message-ID: <a72f4a2d-4028-4bf9-906e-e270ab21623b@linux.dev> (raw)
In-Reply-To: <20261025214449.310715-4-longman@redhat.com>
在 2026/10/26 05:44, Waiman Long 写道:
> With the introduction of cpuset.cpus.exclusive, the computation of
> effective_cpus differs depending on if a cpuset is a valid partition
> root or not.
>
> In update_cpumasks_hier(), effective_cpus is computed early
> to check if the current subtree can be skipped. Later on
> update_parent_effective_cpumask() may be called which can change the
> partition state from valid to invalid or vice versa. If the partition
> state changes, the previously computed effective_cpus may no longer be
> valid. Fix that by recomputing effective_cpus again when that happens.
>
> Also add a new test case into test_cpuset_prs.sh to verify this change.
>
> Fixes: e2ffe502ba45 ("cgroup/cpuset: Add cpuset.cpus.exclusive for v2")
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---
> kernel/cgroup/cpuset.c | 10 ++++++++--
> tools/testing/selftests/cgroup/test_cpuset_prs.sh | 3 +++
> 2 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index b850aba4d907..37bc79d0c647 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -2327,10 +2327,16 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
> if (update_parent) {
> update_parent_effective_cpumask(cp, partcmd_update, NULL, tmp);
> /*
> - * The cpuset partition_root_state may become
> - * invalid. Capture it.
> + * Capture current partition_root_state as it may have
> + * changed. Recompute effective cpumask if changed.
> */
> new_prs = cp->partition_root_state;
> + if (new_prs != old_prs) {
> + if (new_prs > 0)
> + compute_partition_effective_cpumask(cp, tmp->new_cpus);
> + else
> + compute_effective_cpumask(tmp->new_cpus, cp, parent);
> + }
> }
>
> spin_lock_irq(&callback_lock);
> diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> index 8bdda955b4a7..f4eb984752a0 100755
> --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> @@ -364,6 +364,9 @@ TEST_MATRIX=(
> " C1-4:X2-4 C2-4:X3-4:P1 C3-4:X4:P2 \
> . . X5 . . 0 A1:1-4|A2:2-4|A3:3-4 \
> A1:P0|A2:P-1|A3:P-2 ."
> + " C1-5:X3-5:P2 C3-5:X4-5:P2 C4-5:X5:P2 \
> + . X1-4 . . . 0 A1:1-3|A2:4|A3:4 \
> + A1:P2|A2:P2|A3:P-2 1-4"
> " C1-4:X2-4 C1-4:X3-4:P1 C3-4:X4:P2 \
> . . . X1 . 0 A1:1-2|A2:3-4|A3:3-4 \
> A1:P0|A2:P1|A3:P-2 ."
Reviewed-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
Thanks,
Guopeng
next prev parent reply other threads:[~2026-10-26 6:46 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 21:44 [PATCH-next v3 00/11] cgroup/cpuset: Miscellaneous bug fixes & cleanup Waiman Long
2026-10-25 21:44 ` [PATCH-next v3 01/11] cgroup/cpuset: Find furthest isolated ancestor for invalidated isolated partition Waiman Long
2026-10-26 6:33 ` Guopeng Zhang
2026-10-25 21:44 ` [PATCH-next v3 02/11] cgroup/cpuset: Properly compute effective xcpus in update_parent_effective_cpumask() Waiman Long
2026-10-26 6:39 ` Guopeng Zhang
2026-10-25 21:44 ` [PATCH-next v3 03/11] cgroup/cpuset: Fix incorrect effective_cpus bug in update_cpumasks_hier() Waiman Long
2026-10-26 6:46 ` Guopeng Zhang [this message]
2026-10-25 21:44 ` [PATCH-next v3 04/11] cgroup/cpuset: Minor fixes to prstate_housekeeping_conflict() Waiman Long
2026-10-26 6:57 ` Guopeng Zhang
2026-10-25 21:44 ` [PATCH-next v3 05/11] selftests/cgroup: Check for a single range nohz_full CPUs before running test matrix Waiman Long
2026-10-25 21:44 ` [PATCH-next v3 06/11] cgroup/cpuset: Prevent recursive call of remote_cpus_update() via update_cpumasks_hier() Waiman Long
2026-10-25 21:44 ` [PATCH-next v3 07/11] cgroup/cpuset: Make sure compute_partition_effective_cpumask() is only called for valid partition Waiman Long
2026-10-26 7:14 ` Guopeng Zhang
2026-10-25 21:44 ` [PATCH-next v3 08/11] cgroup/cpuset: Release invalid isolated CPUs in compute_partition_effective_cpumask() Waiman Long
2026-10-26 8:49 ` Guopeng Zhang
2026-10-25 21:44 ` [PATCH-next v3 09/11] cgroup/cpuset: Release invalid isolated CPUs with a shrunk root partition parent Waiman Long
2026-10-25 23:53 ` [PATCH-next v3.1 " Waiman Long
2026-10-26 8:51 ` Guopeng Zhang
2026-10-25 23:56 ` [PATCH-next v3 " Waiman Long
2026-10-25 21:44 ` [PATCH-next v3 10/11] cgroup/cpuset: Relocate compute_*effective_cpumask() and compute_effective_nodemask() Waiman Long
2026-10-26 9:08 ` Guopeng Zhang
2026-10-25 21:44 ` [PATCH-next v3 11/11] cgroup/cpuset: Integrate compute_partition_effective_cpumask() into compute_effective_cpumask() Waiman Long
2026-10-26 9:44 ` Guopeng Zhang
2026-10-26 18:26 ` [PATCH-next v3 00/11] cgroup/cpuset: Miscellaneous bug fixes & cleanup 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=a72f4a2d-4028-4bf9-906e-e270ab21623b@linux.dev \
--to=guopeng.zhang@linux.dev \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mkoutny@suse.com \
--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 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.