From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379791; b=TkQiBEUagtFDsTcxW6MnCgAOHacOIaSCwqyq1qV2+bZBc6JaVNY1SiY4HCrBJA23auJr cwZJ7m+pdRbPXyylEzNUqDBeplBe4qU8GDfGn69OluTjTR+jnyvVT5maTEKnY6yafYFQn gnCiIXhBGoLPGnUmie1OKs56Ed2qTyKw7TFGLCNCRrCzd5ZfMAxP6GroXFrnoV2ovb5+0 57Cn0IsuLa+hdo9NOTXpFV3BemYYJmsM4IXNfxxC0PIek36ml9pKBk/aRCB8JpL/HpUvp ypaKg/PAWJMT+3pPEhVVGiADCjAON2CCxKz0HZRzmhLMQ7uJkS8to+BEAU97KUkXQlA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379791; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=YQ+zHA6Plk2F2O2F/NGBrlwccUG8ryzyqqKgKv4AD8w=; b=2/GDHOZhtY13eZk5EjeuVjxOFgrK6rFzapECsEtoz7keYDdi9RjvY/oUKK+XzS40kTxX WN0t2Xz/djFSWHqZcLfoYqyW563Uy4ZfUnZuCzjpS6gqBOl6lMrLTocoYERmO4U/By0SE BFxXIpLyscX06LCukV/TZQmMSN2J0bSv5re6vbu0LCH7KdjoRxaCduNRo09C/MUGEjWg1 Oq7W1apSWZP0A+xJws7FtkpnLOPRWhxa41FXqez8oHI22ENa5BhQwAfyS+5JVwB5dg7eE pOzXWvv5UY+YLOS1/H6MkwSsNJYSWxDxONktcoJA0Cyd+yhj8SziMQPD4HWQ0O/UChA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=1zjdVCw0; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FD05606A322; Fri, 4 Dec 2026 10:23:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=1zjdVCw0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E2F61F000CE; Fri, 4 Dec 2026 10:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379790; bh=YQ+zHA6Plk2F2O2F/NGBrlwccUG8ryzyqqKgKv4AD8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1zjdVCw0nz4Ry+cc9ybyC7fEz/J3zi8mzegvG39quEMsyf+ZB8ly1aUah8cugljnO zahbVyAqj8WeHRUza9cbb2CeL+VcgX3TIMx6LCO7UcYTy1ItxFVS3HUB7znya8llER cxE5NWyUv6lsOTU/rUranaKWw3149VpU2mD1Og6o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Waiman Long , Ridong Chen , Tejun Heo , Sasha Levin Subject: [PATCH 6.12 061/555] cgroup/cpuset: Correctly set isolated_cpus when switching partition state Date: Fri, 4 Dec 2026 19:01:44 +0900 Message-ID: <20261204100609.071946026@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Waiman Long [ 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 Reviewed-by: Ridong Chen Tested-by: Ridong Chen Signed-off-by: Tejun Heo [ 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 --- 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