* FAILED: patch "[PATCH] cgroup/cpuset: Correctly set isolated_cpus when switching" failed to apply to 6.12-stable tree
@ 2026-11-25 9:18 gregkh
2026-11-25 16:17 ` [PATCH 6.12.y] cgroup/cpuset: Correctly set isolated_cpus when switching partition state Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2026-11-25 9:18 UTC (permalink / raw)
To: longman, ridong.chen, tj; +Cc: stable
The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 56681bc448a80bb2473026b41c44c133766bc38d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026112532-stitch-earthy-8c0e@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 56681bc448a80bb2473026b41c44c133766bc38d Mon Sep 17 00:00:00 2001
From: Waiman Long <longman@redhat.com>
Date: Mon, 9 Nov 2026 21:24:00 -0500
Subject: [PATCH] cgroup/cpuset: Correctly set isolated_cpus when switching
partition state
When update_prstate() is called to switch the partition state from
root to isolated or vice versa, the whole effective_xcpus is passed to
isolated_cpus_update(). However, if there are child partitions present,
some of the effective_xcpus are dedicated to those child partitions
and their partition states will remain the same or get invalidated in
the case of child root partition with isolated parent in the latter
update_cpumasks_hier() call. In the latter case, their exclusive CPUs
will be returned to their parent.
Therefore isolated_cpus may be set incorrectly with child partitions
underneath. Fix that by excluding their exclusive CPUs in computing
the correct cpumask of exclusive CPUs used by that partition alone.
Add new test cases into test_cpuset_prs.sh to test for such cases.
Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
Cc: stable@vger.kernel.org # v6.8+
Signed-off-by: Waiman Long <longman@redhat.com>
Reviewed-by: Ridong Chen <ridong.chen@linux.dev>
Tested-by: Ridong Chen <ridong.chen@linux.dev>
Signed-off-by: Tejun Heo <tj@kernel.org>
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 87600628e080..06ceeb0ac8c0 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -3073,12 +3073,32 @@ static int update_prstate(struct cpuset *cs, int new_prs)
cs->effective_xcpus, NULL))
err = PERR_HKEEPING;
else if (parent_prs == PRS_ISOLATED)
- err = PERR_ISOPARENT;
+ err = PERR_ISOPARENT; /* old_prs should be isolated */
- if (!err)
- isolcpus_updated = true;
- else
+ if (err) {
disable_partition = true;
+ } else {
+ struct cgroup_subsys_state *css;
+ struct cpuset *child;
+
+ /*
+ * Need to scan child partitions, if present, and
+ * exclude their effective_xcpus from cs. In the case
+ * of switching to isolated partition with child root
+ * partitions, those child partitions will be
+ * invalidated in update_cpumasks_hier().
+ */
+ isolcpus_updated = true;
+ cpumask_copy(tmpmask.new_cpus, cs->effective_xcpus);
+ rcu_read_lock();
+ cpuset_for_each_child(child, css, cs) {
+ if (!is_partition_valid(child))
+ continue;
+ cpumask_andnot(tmpmask.new_cpus, tmpmask.new_cpus,
+ child->effective_xcpus);
+ }
+ rcu_read_unlock();
+ }
} else {
/*
* Switching back to member is always allowed even if it
@@ -3112,7 +3132,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
if (!is_partition_valid(cs))
reset_partition_data(cs);
else if (isolcpus_updated)
- isolated_cpus_update(old_prs, new_prs, cs->effective_xcpus);
+ isolated_cpus_update(old_prs, new_prs, tmpmask.new_cpus);
spin_unlock_irq(&callback_lock);
/* Force update if partition is disabled & update effective_xcpus */
diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
index 2d4744f2d6ac..1e9e6b4c6f7b 100755
--- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
+++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
@@ -556,6 +556,13 @@ TEST_MATRIX=(
" C2-6:X2-5:P1 CX3-6:P2 \
. . T:X4-6 . . . 0 A1:4-6|A2:4-6 A1:P1|A2:P-2 ."
+ # Switch PRS state (root <=> isolated) will properly update cpuset.cpus.isolated
+ # even if child partitions are present.
+ " C1-6:P1 C3-6:P1 C5-6:P2 . . P2 . . 0 A1:1-2|A2:3-4|A3:5-6 \
+ A1:P1|A2:P2|A3:P2 3-6"
+ " C1-6:P1 C3-6:P2 C5-6:P2 . . P1 . . 0 A1:1-2|A2:3-4|A3:5-6 \
+ A1:P1|A2:P1|A3:P2 5-6"
+
#
# old-A1 old-A2 old-A3 old-B1 new-A1 new-A2 new-A3 new-B1 fail ECPUs Pstate ISOLCPUS
# ------ ------ ------ ------ ------ ------ ------ ------ ---- ----- ------ --------
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH 6.12.y] cgroup/cpuset: Correctly set isolated_cpus when switching partition state
2026-11-25 9:18 FAILED: patch "[PATCH] cgroup/cpuset: Correctly set isolated_cpus when switching" failed to apply to 6.12-stable tree gregkh
@ 2026-11-25 16:17 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-11-25 16:17 UTC (permalink / raw)
To: stable; +Cc: Waiman Long, Ridong Chen, Tejun Heo, Sasha Levin
From: Waiman Long <longman@redhat.com>
[ Upstream commit 56681bc448a80bb2473026b41c44c133766bc38d ]
When update_prstate() is called to switch the partition state from
root to isolated or vice versa, the whole effective_xcpus is passed to
isolated_cpus_update(). However, if there are child partitions present,
some of the effective_xcpus are dedicated to those child partitions
and their partition states will remain the same or get invalidated in
the case of child root partition with isolated parent in the latter
update_cpumasks_hier() call. In the latter case, their exclusive CPUs
will be returned to their parent.
Therefore isolated_cpus may be set incorrectly with child partitions
underneath. Fix that by excluding their exclusive CPUs in computing
the correct cpumask of exclusive CPUs used by that partition alone.
Add new test cases into test_cpuset_prs.sh to test for such cases.
Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
Cc: stable@vger.kernel.org # v6.8+
Signed-off-by: Waiman Long <longman@redhat.com>
Reviewed-by: Ridong Chen <ridong.chen@linux.dev>
Tested-by: Ridong Chen <ridong.chen@linux.dev>
Signed-off-by: Tejun Heo <tj@kernel.org>
[ sashal: Adapted to the older helper names and control flow, with no housekeeping error path; test rows use :S+ for nested partitions, and the comment says child CPUs stay dedicated. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/cgroup/cpuset.c | 19 ++++++++++++++++++-
.../selftests/cgroup/test_cpuset_prs.sh | 7 +++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 7e7ef1469a4d3..a8024feac0bd6 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2950,7 +2950,24 @@ static int update_prstate(struct cpuset *cs, int new_prs)
/*
* A change in load balance state only, no change in cpumasks.
*/
+ struct cgroup_subsys_state *css;
+ struct cpuset *child;
+
+ /*
+ * Need to scan child partitions, if present, and exclude
+ * their effective_xcpus from cs, as those CPUs remain
+ * dedicated to the child partitions.
+ */
new_xcpus_state = true;
+ cpumask_copy(tmpmask.new_cpus, cs->effective_xcpus);
+ rcu_read_lock();
+ cpuset_for_each_child(child, css, cs) {
+ if (!is_partition_valid(child))
+ continue;
+ cpumask_andnot(tmpmask.new_cpus, tmpmask.new_cpus,
+ child->effective_xcpus);
+ }
+ rcu_read_unlock();
} else {
/*
* Switching back to member is always allowed even if it
@@ -2983,7 +3000,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
if (!is_partition_valid(cs))
reset_partition_data(cs);
else if (new_xcpus_state)
- partition_xcpus_newstate(old_prs, new_prs, cs->effective_xcpus);
+ partition_xcpus_newstate(old_prs, new_prs, tmpmask.new_cpus);
spin_unlock_irq(&callback_lock);
update_unbound_workqueue_cpumask(new_xcpus_state);
diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
index f52678bb2efee..c49228c603d96 100755
--- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
+++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
@@ -406,6 +406,13 @@ TEST_MATRIX=(
# affect cpuset.cpus.exclusive.effective.
" C1-4:X3:S+ C1:X3 . . . C . . 0 A2:1-4|XA2:3"
+ # Switch PRS state (root <=> isolated) will properly update cpuset.cpus.isolated
+ # even if child partitions are present.
+ " C1-6:P1:S+ C3-6:P1:S+ C5-6:P2 . . P2 . . 0 A1:1-2|A2:3-4|A3:5-6 \
+ A1:P1|A2:P2|A3:P2 3-6"
+ " C1-6:P1:S+ C3-6:P2:S+ C5-6:P2 . . P1 . . 0 A1:1-2|A2:3-4|A3:5-6 \
+ A1:P1|A2:P1|A3:P2 5-6"
+
# old-A1 old-A2 old-A3 old-B1 new-A1 new-A2 new-A3 new-B1 fail ECPUs Pstate ISOLCPUS
# ------ ------ ------ ------ ------ ------ ------ ------ ---- ----- ------ --------
# Failure cases:
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 16:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 9:18 FAILED: patch "[PATCH] cgroup/cpuset: Correctly set isolated_cpus when switching" failed to apply to 6.12-stable tree gregkh
2026-11-25 16:17 ` [PATCH 6.12.y] cgroup/cpuset: Correctly set isolated_cpus when switching partition state Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox