Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Waiman Long <longman@redhat.com>,
	Ridong Chen <ridong.chen@linux.dev>, Tejun Heo <tj@kernel.org>,
	Sasha Levin <sashal@kernel.org>
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	[thread overview]
Message-ID: <20261204100609.071946026@linuxfoundation.org> (raw)
In-Reply-To: <20261204100603.988357525@linuxfoundation.org>

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

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




  parent reply	other threads:[~2026-12-04 10:23 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 001/555] net: ipv6: keep room for the mac header in dst_dev_overhead() Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 002/555] virtgpu: dont reset on shutdown Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 003/555] virtio: add virtio_device_shutdown() helper Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 004/555] virtio_balloon: factor out virtballoon_quiesce() Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 005/555] virtio_balloon: quiesce balloon work before device shutdown Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 006/555] mm/page_alloc: snapshot the preferred zone against shrink rebuilds Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 007/555] pidfd: restrict task access ioctls to the callers pid namespace Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 008/555] net/smc: fix link group ownership in handshake abort Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 009/555] net/mlx5e: Fix queue stats access to queues without stats Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 010/555] tcp: do not coalesce segments after FIN Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 011/555] tcp: fastopen: note that a child socket was created Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 012/555] tcp: fix request_sock use-after-free during Fast Open accept() Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 013/555] net: gro: invalidate frag0 after a pull Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 014/555] wifi: mac80211: fix use-after-free on TTLM disconnect Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 015/555] dm: fix infinite loop in dm_blk_do_report_zones() Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 016/555] iio: common: scmi_sensors: fix truncating 64-bit divisions Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 017/555] iio: proximity: sx9500: ignore event config writes that dont change state Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 018/555] iio: imu: inv_mpu6050: fix swapped accel and gyro startup times Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 019/555] mmc: jz4740: Remove the host before resetting the controller Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 020/555] ALSA: hda: Fix [codec] ID matching in patch files for IDs with bit 31 set Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 021/555] kprobes: Adopt guard() and scoped_guard() Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 022/555] mmc: omap: synchronize clock timer before disabling fclk Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 023/555] mmc: sunxi: Use devm_mmc_alloc_host() helper Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 024/555] mmc: sunxi: fix clock and runtime PM leaks on probe failure Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 025/555] errseq: eliminate special limitation for macro MAX_ERRNO Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 026/555] errseq: dont let errseq_check_and_advance() hide later errors Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 027/555] xsk: defer software checksum until the skb is complete Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 028/555] cpufreq: Improve suspend-resume synchronization Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 029/555] tpm: flush timeout work outside buffer_mutex to avoid deadlock Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 030/555] spi: tegra210-quad: Track DMA mapping state Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 031/555] watchdog: npcm: Remove unnecessary NULL check before clk_prepare_enable/clk_disable_unprepare Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 032/555] watchdog: npcm: fix clock prepare leak when setting timeout on a running watchdog Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 033/555] tracing/probes: Enable newly appended probe when target event is enabled Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 034/555] tracing/probes: Fix missing BTF kind checks in char pointer/array helpers Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 035/555] xfrm: Dont clobber inner headers when already set Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 036/555] Bluetooth: hci_core: Fix not checking skb length on hci_scodata_packet Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 037/555] mtd: core: avoid double-free of OTP NVMEM device Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 038/555] bpf: Introduce jit_required flag and remove bpf_prog_has_kfunc_call() Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 039/555] bpf: Reject programs with inlined helpers if JIT is not available Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 040/555] bpf: Disallow interpreter fallback for arena-related insns Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 041/555] bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 042/555] mm/page_alloc: dont increase highatomic reserve after pcp alloc Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 043/555] mm/page_alloc: use existing highatomic reserves on the buddy fastpath Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 044/555] xprtrdma: serialize unmap_sync with xprt_disconnect Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 045/555] gve: Fix race between stats query and queue reconfig Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 046/555] gve: Block invalid ring sizes when device options are 0 Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 047/555] net: wait for in-flight device unregistrations before netns dismantle Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 048/555] ksmbd: pin parent dentries in SMB2 CREATE ACL path Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 049/555] ksmbd: refuse to read a handle that is not open for reading Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 050/555] tracing/probes: Fix BTF bitfield parsing and out-of-bounds buffer write Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 051/555] comedi: comedi_bond: Fix leak of opened device references Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 052/555] Bluetooth: btusb: fix use-after-free in force_poll_sync Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 053/555] tools/bootconfig: Close only opened braces in compact output Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 054/555] ipv6: Remove IPV6_ADDRFORM Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 055/555] iio: proximity: sx9360: fix sampling frequency write and available range Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 056/555] KEYS: Expand key->{datalen,quotalen} to unsigned int Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 057/555] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 058/555] KEYS: Protect pkey method checks against type removal Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 059/555] tcp: move __reqsk_free() out of line Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 060/555] tcp: free saved_syn after an RCU grace period Greg Kroah-Hartman
2026-12-04 10:01 ` Greg Kroah-Hartman [this message]
2026-12-04 10:01 ` [PATCH 6.12 062/555] arm64: suspend: rely on daif helpers to handle PMR Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 063/555] arm64: suspend: Only track cpuidle context for idle tasks Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 064/555] pNFS: avoid repeatedly cancelling I/O for the same lseg Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 065/555] watchdog: rz: Discard pm_runtime_put() return values Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 066/555] watchdog: rzv2h: Use pm_runtime_put_sync() Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 067/555] hwmon: (nct6775) Handle dual use registers Greg Kroah-Hartman

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=20261204100609.071946026@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=longman@redhat.com \
    --cc=patches@lists.linux.dev \
    --cc=ridong.chen@linux.dev \
    --cc=sashal@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox