From nobody Mon Sep 28 16:20:25 2026 Received: from mta0.migadu.com (out-53.mta0.migadu.com [91.218.175.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FE39443AA3 for ; Thu, 20 Aug 2026 12:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229746; cv=none; b=Mg/BtP8LW8gb5TH2ViARxL/A7HbuHPuDzUjKwiJut6SxeRdJaunJCWJ0L6XvbfU/T0dj5QkOZ6Jqf3eUilOLfB6iLM6DSdPFA6PFGtkK6r9r+C1d6d+g2o3NV7yTKbHek+DfswSwLWM1//vy2PlTfKeomHGT17+uNiI/tChleXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229746; c=relaxed/simple; bh=+SgWMGaA7CDQAMPHI+yux+D8sc7tgzO72UDAwsRv8ow=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qHDoMcDyCYd34/5f6gh+cGN1LyESLzrwDoL2f+PMdLUcPdQKWHhtzwTf3jYPYkTICw3Hb7UQJfTKXYZUiFwtN/oBAgcCxVElngtHyiKDLhTTNO6zmbk6L/l6UYQ93xOv0f9LljYW2HnyQ2nXyTmVoqBgd5WT6NEHR5YeCVrj4zA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=aGBooXZy; arc=none smtp.client-ip=91.218.175.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="aGBooXZy" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=+SgWMGaA7CDQAMPHI+yux+D8sc7tgzO72UDAwsRv8ow=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229741; v=1; x=1787834541; b=aGBooXZyi3L2+WFmlQKjvD8HZRUOXkPV7MZxalfNTL7BlSuDYLKeywiBKZeMGiY+2weAlY7Z D7uG3wfp+KNwmLhe12vXi6nXVZjaDM9qIR8NAHz1idxYhrMSCAd6P5ClliGDw9mzcK15qBt2rSX Bv37AJ0RCTvTrRWN4gEkGPTw= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id ce2966af263b7a65; Thu, 20 Aug 2026 12:42:21 +0000 X-Mizu-Trace-ID: ce2966af263b7a65 X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 01/17] selftests/cgroup: Drop invalid boot isolation comparison Date: Thu, 20 Aug 2026 20:41:46 +0800 Message-ID: <20260820124202.517160-2-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang check_isolcpus() clears ISOLCPUS before rebuilding it from sched domain data. Comparing that empty value with /sys/devices/system/cpu/isolated makes the test fail whenever isolcpus=3Ddomain is present. The cpuset.cpus.isolated check above and the sched domain check below already validate their respective interfaces. Remove the comparison and the unused HKICPUS read. Fixes: 6df415aa46ec ("cgroup/cpuset: Defer housekeeping_update() calls from= CPU hotplug to workqueue") Signed-off-by: Guopeng Zhang --- tools/testing/selftests/cgroup/test_cpuset_prs.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/test= ing/selftests/cgroup/test_cpuset_prs.sh index da8f7b920178..fdb3185570d4 100755 --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh @@ -797,7 +797,6 @@ check_isolcpus() EXPECTED_ISOLCPUS=3D$1 ISCPUS=3D${CGROUP2}/cpuset.cpus.isolated ISOLCPUS=3D$(cat $ISCPUS) - HKICPUS=3D$(cat /sys/devices/system/cpu/isolated) LASTISOLCPU=3D SCHED_DOMAINS=3D/sys/kernel/debug/sched/domains if [[ $EXPECTED_ISOLCPUS =3D . ]] @@ -835,11 +834,6 @@ check_isolcpus() ISOLCPUS=3D EXPECTED_ISOLCPUS=3D$EXPECTED_SDOMAIN =20 - # - # The inverse of HK_TYPE_DOMAIN cpumask in $HKICPUS should match $ISOLCPUS - # - [[ "$ISOLCPUS" !=3D "$HKICPUS" ]] && return 1 - # # Use the sched domain in debugfs to check isolated CPUs, if available # --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta0.migadu.com (out-55.mta0.migadu.com [91.218.175.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23F31443E43 for ; Thu, 20 Aug 2026 12:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229749; cv=none; b=IACa6aLdN2G24mqvTuSG3e6zDPQ1hnJsnRONy4F06Ly7NUotEB8mRvOOPbQtWYeIVplczm/QwYzzT30izncQcsnCGVr6O6ucG2FczjE3q/BKKEJKIVwAVDCov9vM0fGAybqfOl7svHbxFQyLD/RVqjzcfU/iMh4TCdLvICDPCTI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229749; c=relaxed/simple; bh=6gabYFqQnKZwQPnrvz21HfNVbdBxpKDdatlnF6ReL1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cMrDr16NL9wB3Q4Fv5q8hVKyA761Hu38OnqJoPXVws3UIYZzMfIBo0dzbcIZhvAwtEIyPveA1+jNdp0wp1ilqxjCbLT8uAtS2UoEuPBDyYDCAXoJ/54o6d5lqvCNqmMxMHD8QWZQmiipNR8t7uiIYXCBzzNhqnnLGos83iGO3Ig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=EtLDgSWU; arc=none smtp.client-ip=91.218.175.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="EtLDgSWU" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=6gabYFqQnKZwQPnrvz21HfNVbdBxpKDdatlnF6ReL1Q=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229746; v=1; x=1787834546; b=EtLDgSWU5/gfiwD7SSHeTgwOtbYZ1uKnOeiQSMIzViNJ9cM6T+3+GRVZ2eWFkIaENPHAXaWZ pr7XipiqRTpH1gIH4LH0e3b7YE5y+lAztjeCJhj7bTwVc0qohjkaUnB1OOV/tsK5pDiU4hsqHO1 SqEOIyzXYcIzXLptBvEpiR5U= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id c14d578c93727d8e; Thu, 20 Aug 2026 12:42:26 +0000 X-Mizu-Trace-ID: c14d578c93727d8e X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 02/17] cgroup/cpuset: Preserve boot-isolated CPUs on partition release Date: Thu, 20 Aug 2026 20:41:47 +0800 Message-ID: <20260820124202.517160-3-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang isolated_cpus tracks CPUs isolated with isolcpus=3D as well as CPUs in isolated cpuset partitions. When an isolated partition is released, isolated_cpus_update() removes its whole CPU mask. This also clears CPUs which were already isolated at boot. Update isolated_cpus one CPU at a time and keep CPUs outside the boot-time domain housekeeping mask isolated. Fixes: c188f33c864e ("cgroup/cpuset: Account for boot time isolated CPUs") Signed-off-by: Guopeng Zhang --- kernel/cgroup/cpuset.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index d100634fa12b..2538faac9aba 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1259,6 +1259,28 @@ static void reset_partition_data(struct cpuset *cs) cpumask_copy(cs->effective_cpus, parent->effective_cpus); } =20 +/* Return true if isolated_cpus changes. */ +static bool isolated_cpu_update(int new_prs, int cpu) +{ + lockdep_assert_held(&callback_lock); + lockdep_assert_held(&cpuset_mutex); + + if (new_prs =3D=3D PRS_ISOLATED) { + if (cpumask_test_cpu(cpu, isolated_cpus)) + return false; + cpumask_set_cpu(cpu, isolated_cpus); + return true; + } + + /* CPUs isolated at boot must remain isolated. */ + if (!cpumask_test_cpu(cpu, + housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT)) || + !cpumask_test_cpu(cpu, isolated_cpus)) + return false; + cpumask_clear_cpu(cpu, isolated_cpus); + return true; +} + /* * isolated_cpus_update - Update the isolated_cpus mask * @old_prs: old partition_root_state @@ -1267,19 +1289,16 @@ static void reset_partition_data(struct cpuset *cs) */ static void isolated_cpus_update(int old_prs, int new_prs, struct cpumask = *xcpus) { + bool updated =3D false; + int cpu; + WARN_ON_ONCE(old_prs =3D=3D new_prs); lockdep_assert_held(&callback_lock); lockdep_assert_held(&cpuset_mutex); - if (new_prs =3D=3D PRS_ISOLATED) { - if (cpumask_subset(xcpus, isolated_cpus)) - return; - cpumask_or(isolated_cpus, isolated_cpus, xcpus); - } else { - if (!cpumask_intersects(xcpus, isolated_cpus)) - return; - cpumask_andnot(isolated_cpus, isolated_cpus, xcpus); - } - update_housekeeping =3D true; + for_each_cpu(cpu, xcpus) + updated |=3D isolated_cpu_update(new_prs, cpu); + if (updated) + update_housekeeping =3D true; } =20 /* --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta0.migadu.com (out-62.mta0.migadu.com [91.218.175.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ACA94457DA for ; Thu, 20 Aug 2026 12:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.62 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229754; cv=none; b=TouNazo5/HRrB1ClTYQJeSEZAPu/2K2wbKgBxW9WEqFluXUkAwhtRb7xB0ivMBHx9EbJgFzbaKg9q4Dcfbe1VefXt02O+Z64Ym/PJsMk6FHJV1HyYoksjzXO+exXn4DhJLKnJa7vviEjBCulzQpKDq8rHBHabxFJIjThigPh3iU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229754; c=relaxed/simple; bh=xzuiCyOQkUshOw/dQoqpJd4cRH9nvcLkQjfLEBLwDso=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZSUDJWxjakOrUOcoZ/TTCCPR8ogCu7sd4GQGFK3Xj9qyYcJqZ8tjSmA8ZZA8fo0q+wxPJUEDZ1kiXF2qB2ouvpizpmd7dc/D1QF6Xxt6Y5PK4VaAmXllRx4JadfBz1RRL/I+wJk3EpGCsrr3ZVdQypImApBBgBIloHaZM55iA20= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=pw4q/B8Y; arc=none smtp.client-ip=91.218.175.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="pw4q/B8Y" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=xzuiCyOQkUshOw/dQoqpJd4cRH9nvcLkQjfLEBLwDso=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229750; v=1; x=1787834550; b=pw4q/B8Yr/DahBGnAs2/z9A6qeFb9DTCnbFKVy0F69whTIjperD6LyewZUvInvoadYqi7c1H rvJyNWoFW7XgIfvIOGo+tGck7IdkRV4ZsAOFLthBdO2VOBydgrQrWlxbZUthgsvC01MvLp+Qjr7 mMhXOQZAziZ5oEp9/rLH7rlQ= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id e10e27d3da9d99c5; Thu, 20 Aug 2026 12:42:30 +0000 X-Mizu-Trace-ID: e10e27d3da9d99c5 X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 03/17] selftests/cgroup: Test boot-isolated CPU partition release Date: Thu, 20 Aug 2026 20:41:48 +0800 Message-ID: <20260820124202.517160-4-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang Put a CPU isolated at boot into an isolated partition, change the partition back to member and check that the CPU remains isolated. Signed-off-by: Guopeng Zhang --- .../selftests/cgroup/test_cpuset_prs.sh | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/test= ing/selftests/cgroup/test_cpuset_prs.sh index fdb3185570d4..131d8b4551ef 100755 --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh @@ -1155,6 +1155,63 @@ test_isolated() pause 0.05 } =20 +# +# Select an online CPU isolated from scheduler domains at boot. +# $1: test name used in the skip message +# +get_boot_isolated_cpu() +{ + TEST_NAME=3D$1 + BOOT_ISOLATED_FILE=3D/sys/devices/system/cpu/isolated + + [[ -r $BOOT_ISOLATED_FILE ]] || { + echo "$TEST_NAME test SKIPPED: boot isolation state unavailable" + return 1 + } + BOOT_CPUS=3D$(cat $BOOT_ISOLATED_FILE) + [[ -n "$BOOT_CPUS" ]] || { + echo "$TEST_NAME test SKIPPED: no boot-isolated CPU" + return 1 + } + + BOOT_CPU=3D$(echo "$BOOT_CPUS" | sed -e 's/[,-].*//') + CPU_ONLINE=3D/sys/devices/system/cpu/cpu${BOOT_CPU}/online + [[ ! -e $CPU_ONLINE || $(cat $CPU_ONLINE) -eq 1 ]] || { + echo "$TEST_NAME test SKIPPED: CPU $BOOT_CPU is offline" + return 1 + } +} + +# +# A CPU isolated at boot must stay isolated after it is released by a dyna= mic +# isolated partition. +# +test_boot_isolated() +{ + TEST_NAME=3D"Boot-isolated CPU partition release" + get_boot_isolated_cpu "$TEST_NAME" || return 0 + echo "Running $TEST_NAME test ..." + + cd $CGROUP2/test + echo member > cpuset.cpus.partition + echo $BOOT_CPU > cpuset.cpus + [[ $(cat cpuset.cpus.effective) =3D "$BOOT_CPU" ]] || { + echo "$TEST_NAME test SKIPPED: CPU $BOOT_CPU is unavailable" + echo "" > cpuset.cpus + cd $CGROUP2 + return 0 + } + test_partition isolated + test_partition member + check_isolcpus "." || { + echo "Boot-isolated CPU $BOOT_CPU was lost after partition release" + exit 1 + } + echo "" > cpuset.cpus + cd $CGROUP2 + echo "$TEST_NAME test PASSED." +} + # # Wait for inotify event for the given file and read it # $1: cgroup file to wait for @@ -1226,5 +1283,6 @@ trap cleanup 0 2 3 6 run_state_test TEST_MATRIX run_remote_state_test REMOTE_TEST_MATRIX test_isolated +test_boot_isolated test_inotify echo "All tests PASSED." --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta1.migadu.com (out-43.mta1.migadu.com [95.215.58.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9ADB84457B1 for ; Thu, 20 Aug 2026 12:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229762; cv=none; b=ZIQ68NX684NtpB5y8psNDWl6UP840VDxqqFuR+QdXUVrOS73AKbo0Tc/wgAXLSuM7npbC4KH/6siq/cldrRI7XZooP4gzZ6xaagacRP25IZp0m3wV9mTHCakP6O+bi98/JvRLAbZsqlOAOH7JAD1lP/twU5a4qt58LeoxqNQhcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229762; c=relaxed/simple; bh=oFZgfIMHevFj2+IBJHSs6dHXo5XbyNHl4nAKqNst6ug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OwgW794yEwmpg1lNJXcpV46PTouc8zInGcQsmEC9ENEBjlVFI+tfeg1TIUYSzcE1XXf/QLtSg1iQdLa2vTxkvMCdE0fklrNpSxANI8CzPv2+Smuyo63d6wwBIWJ8LBq7PlueCD68hRgdxkQalIn29Che3kJuGTjWK0IW9LZTBqo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Ie/9Qw2B; arc=none smtp.client-ip=95.215.58.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Ie/9Qw2B" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=oFZgfIMHevFj2+IBJHSs6dHXo5XbyNHl4nAKqNst6ug=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229754; v=1; x=1787834554; b=Ie/9Qw2Budo1m8OcowcXyg9PoqHauwxldP/Z384d61wMt767dIcUFQRiS5/AXgnCMVgTUf3r wn5wYqb7A2MYwZnRJMf77B9v4aQU8x1qsBWvlLk9SThJJJUA8g+PSDr4c9qYfUSjN6diwAevAUH j/B5nnwk0kHdL6WUW3RacIWg= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id 0f29dd2d16ed27f9; Thu, 20 Aug 2026 12:42:34 +0000 X-Mizu-Trace-ID: 0f29dd2d16ed27f9 X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 04/17] cgroup/cpuset: Limit type-change accounting to owned CPUs Date: Thu, 20 Aug 2026 20:41:49 +0800 Message-ID: <20260820124202.517160-5-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang effective_xcpus includes CPUs granted to valid child partitions. Passing the whole mask to isolated_cpus_update() during a root-to-isolated or isolated-to-root change applies the parent's new state to child-owned CPUs as well. Build a mask of CPUs owned by the partition by subtracting the effective_xcpus of valid children. Use this mask when updating isolated_cpus for a partition type change. Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partiti= ons") Signed-off-by: Guopeng Zhang --- kernel/cgroup/cpuset.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 2538faac9aba..468272baadb2 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -2155,6 +2155,30 @@ static void compute_partition_effective_cpumask(stru= ct cpuset *cs, rcu_read_unlock(); } =20 +/* + * Compute CPUs owned directly by a partition. + * + * effective_xcpus includes CPUs granted to valid child partitions. Exclude + * those CPUs when changing only this partition's type. + */ +static void compute_partition_owned_cpumask(struct cpuset *cs, + struct cpumask *owned_cpus) +{ + struct cgroup_subsys_state *css; + struct cpuset *child; + + lockdep_assert_held(&cpuset_mutex); + cpumask_copy(owned_cpus, cs->effective_xcpus); + + rcu_read_lock(); + cpuset_for_each_child(child, css, cs) { + if (is_partition_valid(child)) + cpumask_andnot(owned_cpus, owned_cpus, + child->effective_xcpus); + } + rcu_read_unlock(); +} + /* * update_cpumasks_hier - Update effective cpumasks and tasks in the subtr= ee * @cs: the cpuset to consider @@ -2990,8 +3014,10 @@ static int update_prstate(struct cpuset *cs, int new= _prs) } else if (old_prs && new_prs) { /* * A change in load balance state only, no change in cpumasks. - * Need to update isolated_cpus. + * Need to update isolated_cpus for CPUs owned by this partition, + * excluding CPUs distributed to valid child partitions. */ + compute_partition_owned_cpumask(cs, tmpmask.new_cpus); if (((new_prs =3D=3D PRS_ISOLATED) && !isolated_cpus_can_update(cs->effective_xcpus, NULL)) || prstate_housekeeping_conflict(new_prs, cs->effective_xcpus)) @@ -3030,7 +3056,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); =20 /* Force update if switching back to member & update effective_xcpus */ --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta1.migadu.com (out-47.mta1.migadu.com [95.215.58.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5607A443E39 for ; Thu, 20 Aug 2026 12:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229762; cv=none; b=cwuzFlEKdHdDR2zsUW4hd2O6O0yjdRD0CUnSkgORMH5JSxx6JQZ1KfYe0xpOhou1lh0gBGqFAi+YXTCixiNuUQk7UVqXWZaud4m6ONjENlJGBeICkVFLO2Ewv+020MJ/+eRNONqLYGGEFpnWjxOuPMZF+OnO/r81MTyeGH60oCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229762; c=relaxed/simple; bh=H6Kjnog+dQT7tN4C/3rC+dGe+xz2UZJm2VHn1zFbXB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jSm01e4vMzxu77nGBMqGKPNc3oISUamrTqrgYCX/Tnc0O8p2bVlIVAvjZrQBy/i3MNmHKJ13cgopTiG0mYN2WMbUpFs3b6YqCbTWHY9mioxdXD9lKbVtCQrKn5gV3zrbiDZcThMWSmib2KzQd+hOmzPzQ6vngU0gaPSlJGz9q0Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=O2ohWaeN; arc=none smtp.client-ip=95.215.58.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="O2ohWaeN" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=H6Kjnog+dQT7tN4C/3rC+dGe+xz2UZJm2VHn1zFbXB4=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229759; v=1; x=1787834559; b=O2ohWaeNEOCr1kGLYHQFXDRPjw9DiWgibmb1cp805Ngqxkuz9hD7jlUs5iMEA/zo8Xy/Je7/ GrRrI8tfPAG8Tabm4OqMxVTqUdzvJEYv6JFYIA6NQus1EnI+qNE3NQ1ZgN9NCuEcMf12ZFiohJR TiTpM1x3bWp99+bYTYIhspFM= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id 2f77a85c6204a7d8; Thu, 20 Aug 2026 12:42:39 +0000 X-Mizu-Trace-ID: 2f77a85c6204a7d8 X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 05/17] selftests/cgroup: Test isolated CPU accounting on type changes Date: Thu, 20 Aug 2026 20:41:50 +0800 Message-ID: <20260820124202.517160-6-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang Switch a parent between root and isolated while a child has the opposite type. Check that CPUs owned by the child keep their isolation state. Signed-off-by: Guopeng Zhang --- tools/testing/selftests/cgroup/test_cpuset_prs.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/test= ing/selftests/cgroup/test_cpuset_prs.sh index 131d8b4551ef..9a1cce4807b4 100755 --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh @@ -224,6 +224,8 @@ TEST_MATRIX=3D( " C0-1 . . C2-3:P1 . . . C2 0 " " C0-1 . . C2-3:P1 . . . C4-5 0 B1:4-5" " C0-3:P1 C2-3:P1 . . . . . . 0 A1:0-1|A2:= 2-3|XA2:2-3" + " C0-3:P1 C2-3:P1 . . P2 . . . 0 A1:0-1|A2:= 2-3 A1:P2|A2:P1 0-1" + " C0-3:P2 C2-3:P2 . . P1 . . . 0 A1:0-1|A2:= 2-3 A1:P1|A2:P2 2-3" " C0-3:P1 C2-3:P1 . . C1-3 . . . 0 A1:1|A2:2-= 3|XA2:2-3" " C2-3:P1 C3:P1 . . C3 . . . 0 A1:|A2:3|X= A2:3 A1:P1|A2:P1" " C2-3:P1 C3:P1 . . C3 P0 . . 0 A1:3|A2:3 = A1:P1|A2:P0" --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta0.migadu.com (out-75.mta0.migadu.com [91.218.175.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE486443E3A for ; Thu, 20 Aug 2026 12:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.75 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229770; cv=none; b=O65twIYmHKu9wxNEXUeiynRzimBKO5bAAyiAAf9M4oc17+P52SQ+ug76z1mMl3y41IpQ9Yp/FTbLlkPLdzS23Fs5KQR7CBLJnLHEOfDhVVf5HRkiQNLetLCcL5sfNoMuZVWgobIUHuDAhde/Ui8vuUmqx26WGf9wxJWLUPSFoPk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229770; c=relaxed/simple; bh=JzFB1pWcXYEwlsA2BzhquKrozcDcigu9uFLgNjOtxFk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q8YOiKIwH3SX/EGqWmePgeXnAAXwBPCSp2iBjlM81hBNB6H42MuHeuc90wiJALOYBQa06P7VuSc2bdHfSa8pbKF2Dv1v8Tp+k74n+VaZxYFelOzyQ/SBxatmc2cmVzmdvnq/fwWsltO320Cd3fhEZVNQ80npY2JSmPVkGaHX9MQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=BR/ap4z5; arc=none smtp.client-ip=91.218.175.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="BR/ap4z5" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=JzFB1pWcXYEwlsA2BzhquKrozcDcigu9uFLgNjOtxFk=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229763; v=1; x=1787834563; b=BR/ap4z5/ScQG4h5ZYDYmBWGwQdtFptV141MTB7wYakNtF8ovMcGqpMBzpevIug7jyIqyTFS wVFSB+Ku2SUW4OPb71hz3TnU1Dte/bEEEem6PHbEorcNIWLm6Fs+Stz97cbMmq1yXhyq9prOPcq HmvZrWL1I5vbFpzyqLrKrQXI= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id ca41ed51a2d43f94; Thu, 20 Aug 2026 12:42:43 +0000 X-Mizu-Trace-ID: ca41ed51a2d43f94 X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 06/17] cgroup/cpuset: Validate type changes against owned CPUs Date: Thu, 20 Aug 2026 20:41:51 +0800 Message-ID: <20260820124202.517160-7-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang update_prstate() checks effective_xcpus against the housekeeping masks before changing a partition between root and isolated. effective_xcpus also contains CPUs granted to valid child partitions, although those CPUs are not affected by the parent's type change. A child-owned CPU can therefore reject an otherwise valid change. Run the nohz_full and boot-domain housekeeping checks against the mask of CPUs owned by the partition instead. Fixes: 103b08709e8a ("cgroup/cpuset: Fail if isolated and nohz_full don't l= eave any housekeeping") Fixes: b1034a690129 ("cgroup/cpuset: Ensure domain isolated CPUs stay in ro= ot or isolated partition") Signed-off-by: Guopeng Zhang --- kernel/cgroup/cpuset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 468272baadb2..853942c1afeb 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3019,8 +3019,8 @@ static int update_prstate(struct cpuset *cs, int new_= prs) */ compute_partition_owned_cpumask(cs, tmpmask.new_cpus); if (((new_prs =3D=3D PRS_ISOLATED) && - !isolated_cpus_can_update(cs->effective_xcpus, NULL)) || - prstate_housekeeping_conflict(new_prs, cs->effective_xcpus)) + !isolated_cpus_can_update(tmpmask.new_cpus, NULL)) || + prstate_housekeeping_conflict(new_prs, tmpmask.new_cpus)) err =3D PERR_HKEEPING; else isolcpus_updated =3D true; --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta1.migadu.com (out-54.mta1.migadu.com [95.215.58.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3008F443E53 for ; Thu, 20 Aug 2026 12:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229771; cv=none; b=Pk1DPDvSBo+hm0dW5U80ZJpTivDW16znMi1lJwjrj9TWRlCeJK5lUX2IzHiJglh0v54KweqoCslyia6E5YxVXaGNFiezXDX+/KMqyK2RR3tkCpkgp96oNqQrR+c0rilRQi9DrDA0B/kHdDeuCX5htgVAuhl1QnKRBKsxJColQNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229771; c=relaxed/simple; bh=jxPbR2mK9lljfvgwT3kZM/oMOKqspdf8wCL3DVZsWO4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QFB6Fpxgisk0y0JejMtseEokwYa2TcYypBAf/mSn3C5zzJgDUyAnL8cQSqj5NkJWISyzO22ZVwpnKMGB1W0nLGJ7gR7i9dvTHwDuy5C2RB8APpquh/cZ6zBwyIy5/gGa+dQaIT2H3jCH3FFOH5qzpdrdXugpjuvPTCLMSK+gp7c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=RrFpfKWR; arc=none smtp.client-ip=95.215.58.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="RrFpfKWR" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=jxPbR2mK9lljfvgwT3kZM/oMOKqspdf8wCL3DVZsWO4=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229768; v=1; x=1787834568; b=RrFpfKWR36KFiTrmRSbXgUqiFjdZ4SsDmX0knnHR3DRR3LeloYfIaRAP9SOSXtw7cZyGty76 876Lv2yvih7X+UH5TKMX6dT4/mRULLIOAZeQBFG1hIu3lStGlrvitTIfLcDesu/IyTBpX/0V2LV TRX32mFUXPI0UxmkYRy61AH4= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id ba9e50599f008768; Thu, 20 Aug 2026 12:42:48 +0000 X-Mizu-Trace-ID: ba9e50599f008768 X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 07/17] selftests/cgroup: Test type-change validation with child-owned CPUs Date: Thu, 20 Aug 2026 20:41:52 +0800 Message-ID: <20260820124202.517160-8-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang Create an isolated child which owns a CPU isolated at boot, then change its parent from isolated to root. Check that the change succeeds without altering the child or its isolated CPU. Signed-off-by: Guopeng Zhang --- .../selftests/cgroup/test_cpuset_prs.sh | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/test= ing/selftests/cgroup/test_cpuset_prs.sh index 9a1cce4807b4..bc8dbb724d5c 100755 --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh @@ -1214,6 +1214,52 @@ test_boot_isolated() echo "$TEST_NAME test PASSED." } =20 +# +# A parent's type change must validate only CPUs owned directly by the par= ent, +# not a boot-isolated CPU owned by a valid isolated child partition. +# +test_owned_cpus_housekeeping() +{ + TEST_NAME=3D"Child-owned CPU type change" + get_boot_isolated_cpu "$TEST_NAME" || return 0 + echo "Running $TEST_NAME test ..." + + cd $CGROUP2/test + echo member > cpuset.cpus.partition + echo +cpuset > cgroup.subtree_control + echo 2,$BOOT_CPU > cpuset.cpus + [[ $(cat cpuset.cpus.effective) =3D "2,$BOOT_CPU" ]] || { + echo "$TEST_NAME test SKIPPED: CPUs 2,$BOOT_CPU are unavailable" + echo "" > cpuset.cpus + cd $CGROUP2 + return 0 + } + test_partition isolated + mkdir A1 + cd A1 + echo $BOOT_CPU > cpuset.cpus + test_partition isolated + cd .. + test_effective_cpus 2 + test_partition root + [[ $(cat A1/cpuset.cpus.partition) =3D isolated ]] || { + echo "Child partition changed during parent type change" + exit 1 + } + check_isolcpus "." || { + echo "Parent type change corrupted child isolation" + exit 1 + } + cd A1 + test_partition member + cd .. + rmdir A1 + test_partition member + echo "" > cpuset.cpus + cd $CGROUP2 + echo "$TEST_NAME test PASSED." +} + # # Wait for inotify event for the given file and read it # $1: cgroup file to wait for @@ -1286,5 +1332,6 @@ run_state_test TEST_MATRIX run_remote_state_test REMOTE_TEST_MATRIX test_isolated test_boot_isolated +test_owned_cpus_housekeeping test_inotify echo "All tests PASSED." --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta1.migadu.com (out-61.mta1.migadu.com [95.215.58.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BA4B443E4D for ; Thu, 20 Aug 2026 12:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.61 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229776; cv=none; b=YS1IZBLk7hJrovrg8dNL2FFmrlBJVfaucEAnC1+0KtDr5A73B2ZCuswh4idOEgnnUb17TN+wLm3iT+h23/e4YPBy/A/lolDDoKXO88ucwDOVvDoAPRZpukWRZNOpAFgiZNNkMrZYQ5/cEa6xt1YHotuG0ZlMRlgjuEAUR+bjsP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229776; c=relaxed/simple; bh=8NOSCQyZWZCO7r3LDcjs74rZ9SleA3lk8hhhzRFnsWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TEnKYnw1I5vaEtwyome8qw7+dF8mS3a0qOIblXDHuz5QHPLhfzittm8mN5FoCvrGAz7kZxcJ8B7/xpLY2QoLJEGQ3mxZgVwTvSLt8VvBmNd/ywGRuN/6r2gYSZv3Khfp63cZyKKNVyzN9e71bqyFT55TDLX7r125Ohnz8tsJadI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=u1eCZ3gC; arc=none smtp.client-ip=95.215.58.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="u1eCZ3gC" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=8NOSCQyZWZCO7r3LDcjs74rZ9SleA3lk8hhhzRFnsWI=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229772; v=1; x=1787834572; b=u1eCZ3gC5IFZ7MjbxfmiofXcLzAaJdQSnvP6KNt7cPoyksoOv0RV3iZ/8e3qp0Y2J8XH9Nqh HjfmAGGBaqAN5R9EkN07dVC+rgfQIFZjdiLeHhr2jud+3V+jgwWbyAsYoxCzs49fLPTGL3/sl1p kye+w4CkXF6+161SVxcWTqZM= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id 443e87af351c599e; Thu, 20 Aug 2026 12:42:52 +0000 X-Mizu-Trace-ID: 443e87af351c599e X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 08/17] cgroup/cpuset: Release CPUs when a type change is rejected Date: Thu, 20 Aug 2026 20:41:53 +0800 Message-ID: <20260820124202.517160-9-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang When a housekeeping check rejects a root-to-isolated or isolated-to-root change, update_prstate() marks the partition invalid but leaves its effective_xcpus allocated. Those CPUs remain missing from the partition which owns the invalidated subtree. Disable a rejected remote partition with remote_partition_disable(). For a local partition, return effective_xcpus to its parent before recording the invalid state. Use the complete mask because descendants are invalidated along with the parent and their CPUs return at the same time. Fixes: 103b08709e8a ("cgroup/cpuset: Fail if isolated and nohz_full don't l= eave any housekeeping") Signed-off-by: Guopeng Zhang --- kernel/cgroup/cpuset.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 853942c1afeb..a616012927be 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3020,10 +3020,21 @@ static int update_prstate(struct cpuset *cs, int ne= w_prs) compute_partition_owned_cpumask(cs, tmpmask.new_cpus); if (((new_prs =3D=3D PRS_ISOLATED) && !isolated_cpus_can_update(tmpmask.new_cpus, NULL)) || - prstate_housekeeping_conflict(new_prs, tmpmask.new_cpus)) + prstate_housekeeping_conflict(new_prs, tmpmask.new_cpus)) { err =3D PERR_HKEEPING; - else + if (is_remote_partition(cs)) { + WRITE_ONCE(cs->prs_err, err); + remote_partition_disable(cs, &tmpmask); + } else { + spin_lock_irq(&callback_lock); + partition_xcpus_del(old_prs, parent, cs->effective_xcpus); + spin_unlock_irq(&callback_lock); + cpuset_update_tasks_cpumask(parent, tmpmask.new_cpus); + update_sibling_cpumasks(parent, cs, &tmpmask); + } + } else { isolcpus_updated =3D true; + } } else { /* * Switching back to member is always allowed even if it --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta0.migadu.com (out-91.mta0.migadu.com [91.218.175.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B70804457CE for ; Thu, 20 Aug 2026 12:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229780; cv=none; b=PWhsPSkCzQyojiBtFn1Hdqben8reqKk5e7rEpPlyKvBxxzLAd/83gPnI+8NQ8HgM9GCZRB5nSF0u0HDmzRTXdr8W/QlOkIF1kL/CvytriUCqBvNV2SbplAcTZGWSMmnZ3DWd34bslgXeYYS1gdV7fAYkkj5ksvzPFj14h4HQt2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229780; c=relaxed/simple; bh=6JU0p/Mbmxgk7gewp7yNkURQEZbjwDYnQ6iCJMjybt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b/21oAuEV+ACpC24FfvR2CyoXXD7J3mFzgz4Ra1JpC71ic1W/2jfKBJkBvUt7fO2O69DEI5/7e/NWRrACK3a4oeDzqqSas6P3c2QADBEXYWwD9VvyU7kWF1vdCM6/s+roR6Q90Fm4UJziPbGHJfCcLGp9TuJfPNsn46qJp8Z2wQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=brlgC4g1; arc=none smtp.client-ip=91.218.175.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="brlgC4g1" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=6JU0p/Mbmxgk7gewp7yNkURQEZbjwDYnQ6iCJMjybt0=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229776; v=1; x=1787834576; b=brlgC4g1GR4ejqYtVLuGEs8dJzqMx5kOkE5rte3sUc8rUek2DlFbzowetUnY+EN1yam9Dw6c lpJDlZEWHb3WfuEqokRsaO1MnVivIOvCFqgEO/GlwvBUDb7hKeFlWqftCn1AeYLPHGK6gp2kNGQ U3WvHg5fN4KUuTRpdR+fYb5A= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id 0ba0aa442e9239da; Thu, 20 Aug 2026 12:42:56 +0000 X-Mizu-Trace-ID: 0ba0aa442e9239da X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 09/17] selftests/cgroup: Test rejected partition type changes Date: Thu, 20 Aug 2026 20:41:54 +0800 Message-ID: <20260820124202.517160-10-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang Exercise housekeeping rejection for local and remote partition type changes. Check the invalid state, the CPUs returned to the top cpuset and the boot-time isolation state of those CPUs. Signed-off-by: Guopeng Zhang --- .../selftests/cgroup/test_cpuset_prs.sh | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/test= ing/selftests/cgroup/test_cpuset_prs.sh index bc8dbb724d5c..35c19738aaa4 100755 --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh @@ -1260,6 +1260,97 @@ test_owned_cpus_housekeeping() echo "$TEST_NAME test PASSED." } =20 +# +# A local type change rejected by the boot housekeeping constraint must re= lease +# the partition CPUs and preserve their boot-isolated state. +# +test_partition_type_failure() +{ + TEST_NAME=3D"Rejected local partition type change" + get_boot_isolated_cpu "$TEST_NAME" || return 0 + echo "Running $TEST_NAME test ..." + + cd $CGROUP2/test + echo member > cpuset.cpus.partition + echo $BOOT_CPU > cpuset.cpus + [[ $(cat cpuset.cpus.effective) =3D "$BOOT_CPU" ]] || { + echo "$TEST_NAME test SKIPPED: CPU $BOOT_CPU is unavailable" + echo "" > cpuset.cpus + cd $CGROUP2 + return 0 + } + test_partition isolated + echo root > cpuset.cpus.partition + grep -q '^root invalid (partition config conflicts with housekeeping setu= p)$' \ + cpuset.cpus.partition || { + echo "Partition type failure did not produce the expected state" + exit 1 + } + [[ $(cat $CGROUP2/cpuset.cpus.effective) =3D "$CPULIST" ]] || { + echo "Partition type failure did not release CPU $BOOT_CPU" + exit 1 + } + check_isolcpus "." || { + echo "Partition type failure lost boot-isolated CPU $BOOT_CPU" + exit 1 + } + echo member > cpuset.cpus.partition + echo "" > cpuset.cpus + cd $CGROUP2 + echo "$TEST_NAME test PASSED." +} + +# +# Exercise the same rejected type change for a remote partition. +# +test_remote_partition_type_failure() +{ + TEST_NAME=3D"Rejected remote partition type change" + get_boot_isolated_cpu "$TEST_NAME" || return 0 + echo "Running $TEST_NAME test ..." + + cd $CGROUP2/test + echo member > cpuset.cpus.partition + echo +cpuset > cgroup.subtree_control + echo $BOOT_CPU > cpuset.cpus + echo $BOOT_CPU > cpuset.cpus.exclusive + [[ $(cat cpuset.cpus.effective) =3D "$BOOT_CPU" ]] || { + echo "$TEST_NAME test SKIPPED: CPU $BOOT_CPU is unavailable" + echo "" > cpuset.cpus.exclusive + echo "" > cpuset.cpus + cd $CGROUP2 + return 0 + } + mkdir A1 + cd A1 + echo $BOOT_CPU > cpuset.cpus + echo $BOOT_CPU > cpuset.cpus.exclusive + test_partition isolated + echo root > cpuset.cpus.partition + grep -q '^root invalid (partition config conflicts with housekeeping setu= p)$' \ + cpuset.cpus.partition || { + echo "Remote type failure did not produce the expected state" + exit 1 + } + [[ $(cat $CGROUP2/cpuset.cpus.effective) =3D "$CPULIST" ]] || { + echo "Remote type failure did not release CPU $BOOT_CPU" + exit 1 + } + check_isolcpus "." || { + echo "Remote type failure lost boot-isolated CPU $BOOT_CPU" + exit 1 + } + echo member > cpuset.cpus.partition + echo "" > cpuset.cpus.exclusive + echo "" > cpuset.cpus + cd .. + rmdir A1 + echo "" > cpuset.cpus.exclusive + echo "" > cpuset.cpus + cd $CGROUP2 + echo "$TEST_NAME test PASSED." +} + # # Wait for inotify event for the given file and read it # $1: cgroup file to wait for @@ -1333,5 +1424,7 @@ run_remote_state_test REMOTE_TEST_MATRIX test_isolated test_boot_isolated test_owned_cpus_housekeeping +test_partition_type_failure +test_remote_partition_type_failure test_inotify echo "All tests PASSED." --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta1.migadu.com (out-68.mta1.migadu.com [95.215.58.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 348FC443E43 for ; Thu, 20 Aug 2026 12:43:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229786; cv=none; b=NCsEMF1IVYoijuoLLLcs8uareJzXHvjpIttzY5WrUIrnCZaPBcHCJ36eB4U5ctD3gTbCnxxliGKpmrfsdSfqMjcBZcqyJFZrLQP3PWvG+wcU/Nxu41PJjAWLeaUiYPAPrgXcRfDbXWqKOT05qG+El3GGd6kHHmHQRiBQFhygPU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229786; c=relaxed/simple; bh=d9WDe4wXJmY5toV+OLSSo2p1bXJ84soOVNkR1vO/t9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tyob5z8rn91blqwpfwoFYPt2bNGMa3jm7jAbuN8e1pW951cLyVDuHKO4W70NNPNhl7+ourXN7QX3xkdMfXbD950KbWrTCRU1DM9KmOHcytHtttbS0ZEnSS5ksX+Jouli7xZiUtwW2JgzkTUTuts2TEYDGpUdHf53kOPjPRuFi94= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Xsw42pEz; arc=none smtp.client-ip=95.215.58.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Xsw42pEz" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=d9WDe4wXJmY5toV+OLSSo2p1bXJ84soOVNkR1vO/t9U=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229781; v=1; x=1787834581; b=Xsw42pEzERDXcJ+bJcfbuWQmZm69AVctj9x5S2C63qHvWeC0vtQRV2ykPOmEXBkLqYcdP6sJ v1cnMEnzOG3GWfOyhDkNRq9F6ycQfqK2/PCd8ooIU3KzkXQp7jmeFsivi3bSpDwWdWHaWmt0Yk9 Tya2OeBHgrhA6M0Tyfdd3F10= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id 8cf7982b83d23293; Thu, 20 Aug 2026 12:43:01 +0000 X-Mizu-Trace-ID: 8cf7982b83d23293 X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 10/17] cgroup/cpuset: Fix isolated accounting on direct child invalidation Date: Thu, 20 Aug 2026 20:41:55 +0800 Message-ID: <20260820124202.517160-11-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang compute_partition_effective_cpumask() can invalidate a child whose CPUs no longer fit in the parent or would leave a populated parent without an active CPU. make_partition_invalid() changes the child state without updating isolated_cpus for the CPUs returned by the child. Keep the unfiltered result of compute_excpus() so that offline CPUs are included in isolation accounting. For each CPU released by the child, use the parent's state when the parent remains valid and owns the CPU. Otherwise use the state of the nearest valid partition ancestor. Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partiti= ons") Signed-off-by: Guopeng Zhang --- kernel/cgroup/cpuset.c | 43 +++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index a616012927be..b9faadf4af6d 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1281,6 +1281,17 @@ static bool isolated_cpu_update(int new_prs, int cpu) return true; } =20 +/* Return the valid partition that owns CPUs released by @cs. */ +static struct cpuset *partition_owner(struct cpuset *cs) +{ + struct cpuset *owner =3D parent_cs(cs); + + lockdep_assert_held(&cpuset_mutex); + while (!is_partition_valid(owner)) + owner =3D parent_cs(owner); + return owner; +} + /* * isolated_cpus_update - Update the isolated_cpus mask * @old_prs: old partition_root_state @@ -2089,6 +2100,7 @@ static int update_parent_effective_cpumask(struct cpu= set *cs, int cmd, * compute_partition_effective_cpumask - compute effective_cpus for partit= ion * @cs: partition root cpuset * @new_ecpus: previously computed effective_cpus to be updated + * @new_xcpus: scratch mask for the new effective_xcpus * * Compute the effective_cpus of a partition root by scanning effective_xc= pus * of child partition roots and excluding their effective_xcpus. @@ -2102,7 +2114,8 @@ static int update_parent_effective_cpumask(struct cpu= set *cs, int cmd, * Note that rcu_read_lock() is assumed to be held. */ static void compute_partition_effective_cpumask(struct cpuset *cs, - struct cpumask *new_ecpus) + struct cpumask *new_ecpus, + struct cpumask *new_xcpus) { struct cgroup_subsys_state *css; struct cpuset *child; @@ -2116,8 +2129,8 @@ static void compute_partition_effective_cpumask(struc= t cpuset *cs, * 2) All the effective_cpus will be used up and cp * has tasks */ - compute_excpus(cs, new_ecpus); - cpumask_and(new_ecpus, new_ecpus, cpu_active_mask); + compute_excpus(cs, new_xcpus); + cpumask_and(new_ecpus, new_xcpus, cpu_active_mask); =20 rcu_read_lock(); cpuset_for_each_child(child, css, cs) { @@ -2139,11 +2152,27 @@ static void compute_partition_effective_cpumask(str= uct cpuset *cs, =20 if (child->prs_err) { int old_prs =3D child->partition_root_state; + int parent_prs =3D cs->partition_root_state; + int owner_prs =3D partition_owner(cs)->partition_root_state; + int cpu; =20 /* - * Invalidate child partition + * CPUs in the parent's new exclusive mask return to the + * parent. The other CPUs have already been released to the + * partition that owns the parent. Account both destinations + * before invalidating the child. */ spin_lock_irq(&callback_lock); + for_each_cpu(cpu, child->effective_xcpus) { + int new_prs =3D parent_prs > 0 && + cpumask_test_cpu(cpu, new_xcpus) + ? parent_prs : owner_prs; + + if (old_prs =3D=3D new_prs) + continue; + if (isolated_cpu_update(new_prs, cpu)) + update_housekeeping =3D true; + } make_partition_invalid(child); spin_unlock_irq(&callback_lock); notify_partition_change(child, old_prs); @@ -2231,7 +2260,7 @@ static void update_cpumasks_hier(struct cpuset *cs, s= truct tmpmasks *tmp, } =20 if (remote || (is_partition_valid(parent) && is_partition_valid(cp))) - compute_partition_effective_cpumask(cp, tmp->new_cpus); + compute_partition_effective_cpumask(cp, tmp->new_cpus, tmp->addmask); else compute_effective_cpumask(tmp->new_cpus, cp, parent); =20 @@ -3996,7 +4025,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset= *cs, struct tmpmasks *tmp) */ remote =3D is_remote_partition(cs); if (remote || (is_partition_valid(cs) && is_partition_valid(parent))) - compute_partition_effective_cpumask(cs, &new_cpus); + compute_partition_effective_cpumask(cs, &new_cpus, tmp->addmask); =20 if (remote && (cpumask_empty(subpartitions_cpus) || (cpumask_empty(&new_cpus) && @@ -4031,7 +4060,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset= *cs, struct tmpmasks *tmp) if (partcmd >=3D 0) { update_parent_effective_cpumask(cs, partcmd, NULL, tmp); if ((partcmd =3D=3D partcmd_invalidate) || is_partition_valid(cs)) { - compute_partition_effective_cpumask(cs, &new_cpus); + compute_partition_effective_cpumask(cs, &new_cpus, tmp->addmask); cpuset_force_rebuild(); } } --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta1.migadu.com (out-74.mta1.migadu.com [95.215.58.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B5E7445AD5 for ; Thu, 20 Aug 2026 12:43:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229789; cv=none; b=dGxahS8l5SWhhVarpBYhesQ/Kg8GVZ5/9iDblL8ScKyyyZswb9Afd1Eji6fVhee+Dns4QPfnj8cN8zWIYCw6V4ovS8QZL5S3Zr4ipN8m+h0XH+9PzOaIyoRbQd+98pTUZ9tu6C7NR5Uja0p7U24vqqwmdxJFz2gNdoPIjEYFI/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229789; c=relaxed/simple; bh=POg3Yxmb/KxT6reCXyqQSfUcrWvjnynhAKq3TgWmEdE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ohZbEKYHiBCw9KRLie2mD54L0jEY3NdEzOO/ZLtsiE9kUApbiHot/8VRpGvlKl8GRCJFf0xIfGiB8/p2kU/IzIAY9/xyVc6dqIYFZTYPYAQHnvJXDUN6Cwv9+3RAIDKICsNR3tEz2fOy93zxtmgoNQDWZM2/Z0qr6Y18hBCZnqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=xQu7jj2W; arc=none smtp.client-ip=95.215.58.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="xQu7jj2W" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=POg3Yxmb/KxT6reCXyqQSfUcrWvjnynhAKq3TgWmEdE=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229786; v=1; x=1787834586; b=xQu7jj2WAztPP9glmaZ4DsWmPGeQH49Mejek56fvnoTUQH5HbQ9DAGoM/jEH7zSsNHaseYOJ 3owUxgbDDfXXm6+7jTcLxIxTTa2/A0wgLBMMH4awp+DxdR1qgZEmiSIOxRf2mTevRlFofXkFbR1 fKuaTCePEUbf1Nzn83IwGdSo= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id a5daa1af638953d0; Thu, 20 Aug 2026 12:43:06 +0000 X-Mizu-Trace-ID: a5daa1af638953d0 X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 11/17] selftests/cgroup: Test isolation accounting on direct child invalidation Date: Thu, 20 Aug 2026 20:41:56 +0800 Message-ID: <20260820124202.517160-12-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang Offline all but one CPU in a root child below an isolated parent. Check the invalid child state, the effective CPU masks and isolated accounting for the released offline CPUs. Signed-off-by: Guopeng Zhang --- tools/testing/selftests/cgroup/test_cpuset_prs.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/test= ing/selftests/cgroup/test_cpuset_prs.sh index 35c19738aaa4..fb11a3ab0f35 100755 --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh @@ -330,6 +330,11 @@ TEST_MATRIX=3D( . . X4 . . 0 A1:1-3|A2:1-3|A3:2-3|XA2:|XA3: = A1:P2|A2:P-2|A3:P-2 1-3" " C0-3:X1-3:P2 C1-3:X2-3:P2 C2-3:X3:P2 \ . . C4:X . . 0 A1:1-3|A2:1-3|A3:2-3|XA2:|XA3: = A1:P2|A2:P-2|A3:P-2 1-3" + + # Direct invalidation returns child CPUs to the parent or its owner + " C1-4:P2 C3-4:P1 . . T:O1=3D0:O2=3D0:O4=3D0 . . . \ + 0 A1:3|A2:3 A1:P2|A2:P-1 1-4" + # Local partition CPU change tests " C0-5:P2 C4-5:P1 . . . C3-5 . . 0 A1:0-2|A2:= 3-5 A1:P2|A2:P1 0-2" " C0-5:P2 C4-5:P1 . . C1-5 . . . 0 A1:1-3|A2:= 4-5 A1:P2|A2:P1 1-3" --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta0.migadu.com (out-101.mta0.migadu.com [91.218.175.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B6A6445AD5 for ; Thu, 20 Aug 2026 12:43:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229793; cv=none; b=suWOGhiZfXFL68ikPLiUOdcqwxQ6a8pMt9qE1o/hs4rkZ75juUl0mj4klZNGOsWD2d7S1ilKgHDdVcLVwVQfBr1dOqbkfZ8KTCSw6qHHw68EvPDhI2LnSr7uwgS96jHNhpKKwdmcc2fzleT5FZ30u9rfbI9u35HCkA8oyo/Cu0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229793; c=relaxed/simple; bh=UIyRewsL6EM7FOwm547z0q306fVBn1MP8SPMo6etr5w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PJpupjvkmqxH3+hRSGO8peFtppPxs+sDgv4S48QopuAuVB7MNHmIxOH9bmf7vxylSgfjKEdPoeCTWCC8Rhd3Hf4b8+DlFoZJuJ/wlcrtxo1bkfl29SJ/rWIVvJiGteJcgAH6VX7R2QlkBuYEx5Fp/psxzS4JRd1RdyuRozf6BsU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=MsG4cgaO; arc=none smtp.client-ip=91.218.175.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="MsG4cgaO" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=UIyRewsL6EM7FOwm547z0q306fVBn1MP8SPMo6etr5w=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229790; v=1; x=1787834590; b=MsG4cgaO99iDKoRiUSXM1dONGMjy3ov40NmhF8XMJelP72QBm1EulBwP5xpYZiHDnh4/CQMk 8X1V+96JZffgjhHVFjgz/tdklw7JKlL+KtWvUa5dYeE+i47b0vjFJzsGDDGvDwMTtgJb5+yscf9 jwwplaWuXmNfiveD2aWhqyvk= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id 2522fcb16bdfe49b; Thu, 20 Aug 2026 12:43:10 +0000 X-Mizu-Trace-ID: 2522fcb16bdfe49b X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 12/17] cgroup/cpuset: Invalidate children outside the new CPU mask Date: Thu, 20 Aug 2026 20:41:57 +0800 Message-ID: <20260820124202.517160-13-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang When cpuset.cpus changes, compute_partition_effective_cpumask() builds a new exclusive mask but checks child partitions against cs->effective_xcpus. That field still contains the old mask, so a child that no longer fits can remain valid. Use new_xcpus for the check. A later partcmd_update() may revisit the newly invalid child. Report PERR_INVCPUS if the child CPUs are outside the parent effective exclusive mask so that this visit does not make the child valid again. Fixes: 0c7f293efc87 ("cgroup/cpuset: Add cpuset.cpus.exclusive.effective fo= r v2") Signed-off-by: Guopeng Zhang --- kernel/cgroup/cpuset.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index b9faadf4af6d..b3e749ede7d1 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1987,12 +1987,16 @@ static int update_parent_effective_cpumask(struct c= puset *cs, int cmd, adding =3D cpumask_and(tmp->addmask, cs->effective_xcpus, parent->effective_xcpus); - } else if (is_partition_invalid(cs) && !cpumask_empty(xcpus) && - cpumask_subset(xcpus, parent->effective_xcpus)) { + } else if (is_partition_invalid(cs) && !cpumask_empty(xcpus)) { struct cgroup_subsys_state *css; struct cpuset *child; bool exclusive =3D true; =20 + if (!cpumask_subset(xcpus, parent->effective_xcpus)) { + part_error =3D PERR_INVCPUS; + goto write_error; + } + /* * Convert invalid partition to valid has to * pass the cpu exclusivity test. @@ -2144,7 +2148,7 @@ static void compute_partition_effective_cpumask(struc= t cpuset *cs, WARN_ON_ONCE(is_remote_partition(child)); WRITE_ONCE(child->prs_err, 0); if (!cpumask_subset(child->effective_xcpus, - cs->effective_xcpus)) + new_xcpus)) WRITE_ONCE(child->prs_err, PERR_INVCPUS); else if (populated && cpumask_subset(new_ecpus, child->effective_xcpus)) --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta0.migadu.com (out-107.mta0.migadu.com [91.218.175.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 604444457BE for ; Thu, 20 Aug 2026 12:43:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229797; cv=none; b=nnduUqbmEmdTMzkLwIrSyU/oDz+BBs0sZ75VFScN8txv/cQBF76SBwVcFkYtNsIimAEUyBXJgaWEwfXSVaKuQUj2yo/O8zURz95RyEfWgP7k2Pn2thLCDShGCNQT/9y7YO4J6dbxETK527qUxy2wnYaw+gp3brrV5CEh1m7tQgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229797; c=relaxed/simple; bh=4Z9moWx34vFyk0X2XPUJ28g4vrAgCQXsNoQyMW+kKNQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H1N85tIumZw4iDN3AFusEQ+TKIcVdeKjWKGegkTersU3A+whJmCOClY+8TH8ucV50F7JJO7vLFVeCzI63fQ40kw92jl2xflYBT+YFrOoIb74XhCijljEvZAwN3WAjmcUcuBmG85CsZmdgO0aR5pLf2xlHSdK9soGNzvtaF5DCB4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=tDj1Eu8q; arc=none smtp.client-ip=91.218.175.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="tDj1Eu8q" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=4Z9moWx34vFyk0X2XPUJ28g4vrAgCQXsNoQyMW+kKNQ=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229794; v=1; x=1787834594; b=tDj1Eu8qYLFLH/K5hi8oD7Lb7UaqCby8NwOqvguVJ5ledEvT6G3hnEEWG0G8UunnupbAjGlU V2Ka1dBjLYGKGVWxzVfMwG4ORYd4DuQ3FzQURyQLyHGpl/qdeGNS1aTt/BZLoAcAFCgsKkG1nCC Jj+KFNI04MyYG3LaCLe6RapA= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id e1761e5fbda85615; Thu, 20 Aug 2026 12:43:14 +0000 X-Mizu-Trace-ID: e1761e5fbda85615 X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 13/17] selftests/cgroup: Test child invalidation after shrinking cpuset.cpus Date: Thu, 20 Aug 2026 20:41:58 +0800 Message-ID: <20260820124202.517160-14-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang Shrink a parent CPU mask in root/root, root/isolated and isolated/root configurations. Check that the child becomes invalid and that effective and isolated CPU masks reflect the new ownership. Signed-off-by: Guopeng Zhang --- tools/testing/selftests/cgroup/test_cpuset_prs.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/test= ing/selftests/cgroup/test_cpuset_prs.sh index fb11a3ab0f35..7345e89e22b7 100755 --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh @@ -331,6 +331,11 @@ TEST_MATRIX=3D( " C0-3:X1-3:P2 C1-3:X2-3:P2 C2-3:X3:P2 \ . . C4:X . . 0 A1:1-3|A2:1-3|A3:2-3|XA2:|XA3: = A1:P2|A2:P-2|A3:P-2 1-3" =20 + # A child outside its parent's new CPU mask becomes invalid + " C0-3:P1 C2-3:P1 . . C0-2 . . . 0 A1:0-2|A2:= 2 A1:P1|A2:P-1" + " C0-3:P1 C2-3:P2 . . C0-2 . . . 0 A1:0-2|A2:= 2 A1:P1|A2:P-2 ." + " C0-3:P2 C2-3:P1 . . C0-2 . . . 0 A1:0-2|A2:= 2 A1:P2|A2:P-1 0-2" + # Direct invalidation returns child CPUs to the parent or its owner " C1-4:P2 C3-4:P1 . . T:O1=3D0:O2=3D0:O4=3D0 . . . \ 0 A1:3|A2:3 A1:P2|A2:P-1 1-4" --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta1.migadu.com (out-90.mta1.migadu.com [95.215.58.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E434F445AFA for ; Thu, 20 Aug 2026 12:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229802; cv=none; b=hD41N9Tl5cD5SuojaekUQ4aV8p3Pcvo3Cat46YaKI0HVa2s/DRmvj4Pa9ufcYPGx1AEz8aUd+9J/0LRep32s6aM+OHTFC93lWu8juN0q/ZzxHtJNiTeW0180VQnyUZl4eVHtF30H8H6Fk822lmewNM0PB+j5w+pKUQ3dahEQEuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229802; c=relaxed/simple; bh=JuP+1kjQQwdTsfr92sjE4FlWTQ/bj9G+UnXL3bHY01k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TJ6jgdR6L37x1VsQV7BBR5OkQaLQx88uVACf2PhOtUilqEQn+VoskQa2jR/MGDw+9/LRZZ2X49ONxZTa0nl0+p5eBX/8ll2os+5Y4upb/TWS1UMo9N+q0z7iyM+9ReGY3sUJ/WzYer5ySrICyLsJZqk1IpdM1Edq7r1cUj/VGEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=RGo7EuTJ; arc=none smtp.client-ip=95.215.58.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="RGo7EuTJ" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=JuP+1kjQQwdTsfr92sjE4FlWTQ/bj9G+UnXL3bHY01k=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229799; v=1; x=1787834599; b=RGo7EuTJyO0esWjJgsitC86HD6LlGV6xz8pJANMJqWwJFMcjaso0Lgh1mK/4B868jEm8AD8I OLlOkwiqmkeppp2KzCSG+SI2dmJvKx8WQZEKcuiWvUO42++yci120uLzVaR5g33SGMuYH6sDlC4 5T4GtT55GwSPzTJhkjDFnr+I= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id 37dffba7958dff60; Thu, 20 Aug 2026 12:43:18 +0000 X-Mizu-Trace-ID: 37dffba7958dff60 X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 14/17] cgroup/cpuset: Publish cpus_allowed before partition updates Date: Thu, 20 Aug 2026 20:41:59 +0800 Message-ID: <20260820124202.517160-15-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang update_cpumask() calls partition_cpus_change() before copying the new cpus_allowed mask. A remote partition update can propagate through an ancestor and revisit the cpuset while the old mask is still visible. The second visit then adds back CPUs that the first visit released, leaving them allocated after the cpuset is removed. Copy cpus_allowed before partition_cpus_change(). All checks and allocations that can fail have completed by this point, and cpuset_mutex remains held for the rest of the update, so the early copy needs no rollback. Keep effective_xcpus unchanged until afterward so the partition code can still calculate the old-to-new difference. Fixes: f62a5d39368e ("cgroup/cpuset: Remove remote_partition_check() & make= update_cpumasks_hier() handle remote partition") Signed-off-by: Guopeng Zhang --- kernel/cgroup/cpuset.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index b3e749ede7d1..9e13fc962f41 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -2555,10 +2555,17 @@ static int update_cpumask(struct cpuset *cs, struct= cpuset *trialcs, */ force =3D !cpumask_equal(cs->effective_xcpus, trialcs->effective_xcpus); =20 + /* + * remote_cpus_update() can propagate through an ancestor and revisit + * this cpuset. Make sure that it sees the new configured CPU mask. + */ + spin_lock_irq(&callback_lock); + cpumask_copy(cs->cpus_allowed, trialcs->cpus_allowed); + spin_unlock_irq(&callback_lock); + partition_cpus_change(cs, trialcs, &tmp); =20 spin_lock_irq(&callback_lock); - cpumask_copy(cs->cpus_allowed, trialcs->cpus_allowed); cpumask_copy(cs->effective_xcpus, trialcs->effective_xcpus); if ((old_prs > 0) && !is_partition_valid(cs)) reset_partition_data(cs); --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta0.migadu.com (out-120.mta0.migadu.com [91.218.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ADD524457D7 for ; Thu, 20 Aug 2026 12:43:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.120 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229807; cv=none; b=EgSgsIMOIJfzdd3EG6F7vjg9D7yK4q6aN6SYU8q21FmgDtRDeMCMKofgFZ42ESWJGSPcgOnjZHat9+uMCiP8w2ASOodqpi0Qf9LBDgPNhXsfcmjbjhC+E2UkqtuJ18idyuk/wAnnmW3+EnpvH8k7oE/hyRDIQ6u8mHZug1Oo6DM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229807; c=relaxed/simple; bh=pu6refSfYxSkJMyw2ARvUY6sO8y8LnRIQ3GF4cCNz14=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cpZxED/GDHeQh/uHt4k/jt15aqtVSYUR1OWb63GDLUO3a0SuSoT9szsg5rXXVz4XNftSopKkxDOdnqj2zW63hgMAQsGrMXDKyuD8pDSlHJ4proFCxInbljJJXW/TBFprDuk9+y5BB+2J2MtRS3aRWdJd35RMwHcIdJwpooQzs2I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=QAcNK528; arc=none smtp.client-ip=91.218.175.120 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="QAcNK528" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=pu6refSfYxSkJMyw2ARvUY6sO8y8LnRIQ3GF4cCNz14=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229803; v=1; x=1787834603; b=QAcNK528VxlQcDkKhlyMaXonG28/2aXERseGGAMS+gdYAWIrbTxqRN4D66fjbA969fp1b1OC CoEWEZRP+XotnBgHe0Gl5pe5EdJq6N1PsMe+nvbvIyzejt2tbafWvmUVocaXbOdhbC8TaSqArOG D1O/p/9sSNC4viUd7U7thgpY= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id f9c3cf2986d85fb6; Thu, 20 Aug 2026 12:43:23 +0000 X-Mizu-Trace-ID: f9c3cf2986d85fb6 X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 15/17] selftests/cgroup: Test shrinking cpuset.cpus in a remote partition Date: Thu, 20 Aug 2026 20:42:00 +0800 Message-ID: <20260820124202.517160-16-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang Cover remote partition shrink with and without a local isolated child. Check that removed CPUs return to the top cpuset and that child invalidation preserves isolated CPU accounting. Signed-off-by: Guopeng Zhang --- tools/testing/selftests/cgroup/test_cpuset_prs.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/test= ing/selftests/cgroup/test_cpuset_prs.sh index 7345e89e22b7..ad01016ddc8d 100755 --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh @@ -520,6 +520,15 @@ REMOTE_TEST_MATRIX=3D( " C1-4:P1 . C1-2:P1 C2-4:P2 . . \ . . . C1-2 . . p1:3-4|c11:1-2|c12:3-4 \ p1:P1|c11:P1|c12:P-2" + # Shrinking a remote partition must return removed CPUs to the top + # partition even when it has no child partitions. + " C1-4:P1 . . . . . \ + C1-3 . . . . . p1:1-3 p1:P1 ." + # A local child invalidated by a remote parent's CPU change must return + # isolated accounting to the remote parent or the top partition. + " C1-4:P1 . C3-4:P2 . . . \ + C1-3 . . . . . p1:1-3|c11:3 \ + p1:P1|c11:P-2 ." # Cpusets with empty cpuset.cpus should inherit parent's effective_cpus " C1-4:P1 C5-6 C1-2 . C5 . \ . P1 P1 . . . p1:3-4|p2:5-6|c11:1-2|c1= 2:3-4|c21:5|c22:5-6 \ --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta0.migadu.com (out-124.mta0.migadu.com [91.218.175.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80874446839 for ; Thu, 20 Aug 2026 12:43:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229811; cv=none; b=TgcDnYZSo9nwikENunTSnyem8PujKLXHGKcNzdTNuNOoMVTn2OHbi+QC7DFeOGrtVPmEArfPJHguX42zmhdHOVMCJ+t01X36pnwVbliHGWGOs8zubk2S7c/yg79Z5Lbe/OLayjRMoT0Wak3KbJCjTRjV9KVh/kO2GRiMazqgEWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229811; c=relaxed/simple; bh=oa7CV0E1+lvtQEeDDICkorvhCO/flckvIj0EpmPl71A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZbEjdzb5dYn3NR+n5lPpCzGN608DZsxpLMeLdBqRLSPiVWqrRi0drS1ai0BrS9TZ6gLxlh5EeTbYW98hdQoeU5GQbhLsrrafXT1Uonq9B3/4AgGfOgNdtM/nyf7y8Y6nKbOsyceRpG4rqv5cORQeEn3g6Q3n7HKjJypToUp50Ps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=HBoaevG1; arc=none smtp.client-ip=91.218.175.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="HBoaevG1" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=oa7CV0E1+lvtQEeDDICkorvhCO/flckvIj0EpmPl71A=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229807; v=1; x=1787834607; b=HBoaevG10QE9Egvnj9FMzskMGtCBMLZzMGyHj+hYqfyeFqoHk5b2e1MZyARGQPu19cHWcst3 zcDIWO1Fpo8UA7JbTn7oDZBV30k4fYthg5hxwg4CR5XYuQF3fT7MtEmOL/A3ZCL2FO2maw2vswU 9X1iRCJH2VwP3ivu/LPbBNNY= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id 03774eb431ba53d2; Thu, 20 Aug 2026 12:43:27 +0000 X-Mizu-Trace-ID: 03774eb431ba53d2 X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 16/17] cgroup/cpuset: Fix isolated accounting on propagated invalidation Date: Thu, 20 Aug 2026 20:42:01 +0800 Message-ID: <20260820124202.517160-17-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang update_cpumasks_hier() invalidates a local partition when its parent becomes a member or an invalid partition. Its CPUs return to the nearest valid partition ancestor, but isolated_cpus still reflects the old partition type. Update isolated_cpus before resetting a local partition whose state changes from valid to invalid below an invalid parent. Remote partitions are excluded because remote_partition_disable() already updates their isolated CPU accounting. Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partiti= ons") Signed-off-by: Guopeng Zhang --- kernel/cgroup/cpuset.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 9e13fc962f41..4af8e348e838 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -2236,9 +2236,12 @@ static void update_cpumasks_hier(struct cpuset *cs, = struct tmpmasks *tmp, cpuset_for_each_descendant_pre(cp, pos_css, cs) { struct cpuset *parent =3D parent_cs(cp); bool remote =3D is_remote_partition(cp); + bool was_remote =3D remote; bool update_parent =3D false; + int owner_prs; =20 old_prs =3D new_prs =3D cp->partition_root_state; + owner_prs =3D old_prs; =20 /* * For child remote partition root (!=3D cs), we need to call @@ -2338,7 +2341,18 @@ static void update_cpumasks_hier(struct cpuset *cs, = struct tmpmasks *tmp, new_prs =3D cp->partition_root_state; } =20 + /* + * With no valid parent partition left, this partition's CPUs + * return to the nearest valid partition ancestor. + */ + if (!was_remote && old_prs > 0 && new_prs < 0 && + !is_partition_valid(parent)) + owner_prs =3D partition_owner(cp)->partition_root_state; + spin_lock_irq(&callback_lock); + if (old_prs !=3D owner_prs) + isolated_cpus_update(old_prs, owner_prs, + cp->effective_xcpus); cpumask_copy(cp->effective_cpus, tmp->new_cpus); cp->partition_root_state =3D new_prs; /* --=20 2.43.0 From nobody Mon Sep 28 16:20:25 2026 Received: from mta1.migadu.com (out-100.mta1.migadu.com [95.215.58.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAD52446845 for ; Thu, 20 Aug 2026 12:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229815; cv=none; b=F88cz68uTDpymxzI35EHYtfCwsKeqN9qI/Yv/cxHig8JxY30+F4y6AFTDDyUjCyU1IIPPhG6eKr85w9zvAsvPKE1dbPbbShii5iwp3O+mFVyFeUo+QsCDCTWZtS5Mc2gL9ZM6+OSqeqgaESP6bEgiT8AM1g+6Zzvjln11TQzPwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787229815; c=relaxed/simple; bh=pK2UsGJfwtec3f0LENGJa1zke896ry16GtXsQEokZvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OlvGJs3r73KB8KnJ0oMnYVEth5HVk/eVwqJa2UKjj4jWTdGoKRTFaD7qgxP6dwO+OlSs4QoHoYPFyC64Ln6BKMz+egwWJzjn1QJC87H9M9jEfeqXNuFglLA8CnilSltUT8RkMZKbDo6Kl+wl9nLucn5Ntx1wFaPqfrCqRztFEug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=iZzX0qaB; arc=none smtp.client-ip=95.215.58.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="iZzX0qaB" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=pK2UsGJfwtec3f0LENGJa1zke896ry16GtXsQEokZvU=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787229811; v=1; x=1787834611; b=iZzX0qaBEnwZb2E2tvM3ONBH0hN9bFw5oyct097jc6QxCUpYoYRnKpTd6/qbeyymxm0fjD39 5nxafAxWVdl5Mrd9rCa4MXv5oQEp6uZgXMeiKtawKdtq6WeQHb0xdagWe2QqNMrx6DladeKNgrF SfLgIpYNjq2gzE6ELkPWoYfA= X-Envelope-To: linux-kernel@vger.kernel.org Received: from zgp.. (223.70.159.239) by smtp.migadu.com with ESMTPS id 9ee3676ab93f26ed; Thu, 20 Aug 2026 12:43:31 +0000 X-Mizu-Trace-ID: 9ee3676ab93f26ed X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang To: longman@redhat.com, cgroups@vger.kernel.org Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH 17/17] selftests/cgroup: Test isolation accounting on propagated invalidation Date: Thu, 20 Aug 2026 20:42:02 +0800 Message-ID: <20260820124202.517160-18-guopeng.zhang@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev> References: <20260820124202.517160-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guopeng Zhang State-matrix cases exercise a child invalidated by its parent and a nested partition invalidated through an already invalid parent. Signed-off-by: Guopeng Zhang --- tools/testing/selftests/cgroup/test_cpuset_prs.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/test= ing/selftests/cgroup/test_cpuset_prs.sh index ad01016ddc8d..89f54c689336 100755 --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh @@ -340,6 +340,12 @@ TEST_MATRIX=3D( " C1-4:P2 C3-4:P1 . . T:O1=3D0:O2=3D0:O4=3D0 . . . \ 0 A1:3|A2:3 A1:P2|A2:P-1 1-4" =20 + # Invalidation propagated from a parent returns all descendant CPUs + " C0-3:P1 C2-3:P2 . . P0 . . . \ + 0 A1:0-3|A2:2-3 A1:P0|A2:P-2 ." + " C0-5:P2 C2-5:P2 C4-5:P1 . . P0 . . \ + 0 A1:0-5|A2:2-5|A3:4-5 A1:P2|A2:P0|A3:P-1 0-5" + # Local partition CPU change tests " C0-5:P2 C4-5:P1 . . . C3-5 . . 0 A1:0-2|A2:= 3-5 A1:P2|A2:P1 0-2" " C0-5:P2 C4-5:P1 . . C1-5 . . . 0 A1:1-3|A2:= 4-5 A1:P2|A2:P1 1-3" --=20 2.43.0