From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.140 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793004709; b=v8xiWtxLc+r5pH9qcysz4uahtQs9j+2uQRJmmszdwOTiU1IvxbxxKdpC/EsNMWD83tLL IgyAfvukMx1uxO90+d6bpUYYObzzvtWrMtO5gPkDfEzz+pX7c9SONVdqp4wKwiHQauZ9S T/odcOU7IGFafTzuT3qckzgpSJRkbqw1/5DQjt1A9VwUsuHnvFPUg/0XqwShNA6eWkGF7 JSpPQYXiEECSLRnFVE4xP68/ctGSRByZuUoEQvK7LeE36Az+KRsixjdLCKnT43H17cDrR /o/bAHqz6y1KKNy25rrwQiivl7V/DCVEPYb6nRuzYOL/biVOsceCybOjwzknJvpvjSA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793004709; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=ZinQ6VNv4xBXZl4N4C9ER6UekGAVyBfk45WZEBqx6kM=; b=QxpOyj5HO/CoViMSfBbAtEAr2Tm1A/jXylujodNIQ54rLq7cp4q/pDFb3k42SZ+ZMJU+ vhLWzc9k017GFS03UYBanYpylHbddnD0EjCJa+eoRsvaCUzKOWMTGJtjmTnGtlKJ0dJE/ iaovZRwhQfjYK1rMFBDgIpkQ8E6xt+7vC08k8dWt1/f0OanuhVFp+CRiFdxOzrE+m+OeN SjrH0vgYh6ezz3kOwxiCpSNnH2AxqVXgI2vbti3wD3khMDW24xZG4bH1xMRsYkpETCTX1 wxNOBMkoLkUg963zaYdfD8+sCV3olLTLs4cyNewfzxN7ND+gsdosl8p1Zpycj8EUiqg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=u3v+FL4y; arc=none smtp.remote-ip=95.215.58.140 Received: from mta1.migadu.com (out-140.mta1.migadu.com [95.215.58.140]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C34C3606A31D for ; Mon, 26 Oct 2026 08:51:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C34C3606A31D 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, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=u3v+FL4y X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=OApuNekQXX8U7HnevQle7FcTjvOpTGZzG9MKgoTNv5w=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793004706; v=1; x=1793609506; b=u3v+FL4yfxuhQ9RYtNgsEWRw0oUkbZVa8JgcWbUJ0obK6A6FKr+NIQ9F+JbkRyrOBx9fI+PT 5V6kt3xH7oy4R7Z59JkIv8cyXhWiV/6gfFob5pW1erSrccMwtzAoVE3g/xfuHJwAWnom9F4wg1i xAZM8xuWakz+s6pXxnB6ogrU= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 76da52be332fa9e2; Mon, 26 Oct 2026 08:51:45 +0000 X-Mizu-Trace-ID: 76da52be332fa9e2 X-Migadu-Flow: FLOW_OUT Message-ID: <29f2442d-60c5-44ce-814e-7ad2d7391a5e@linux.dev> Date: Mon, 26 Oct 2026 16:51:37 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH-next v3.1 09/11] cgroup/cpuset: Release invalid isolated CPUs with a shrunk root partition parent To: Waiman Long , Ridong Chen , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Shuah Khan Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org References: <20261025214449.310715-10-longman@redhat.com> <20261025235359.320155-1-longman@redhat.com> Content-Language: en-US From: Guopeng Zhang In-Reply-To: <20261025235359.320155-1-longman@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 2026/10/26 07:53, Waiman Long 写道: > It is also reported by sashiko that there may be leakages of isolated > CPUs when a root partition parent shrinks its effective_xcpus with > isolated partition children. Leakage here means that isolated_cpus may > contain extra CPUs that are not in any isolated partitions and not boot > time isolated. Those CPUs cannot be used in any isolated partitions > anymore. > > There are 2 different cases here. The effective_xcpus becomes empty and > the isolated partition should be invalidated in this case. Alternatively > some of its effective_xcpus are not in parent's effective xcpus but > still have some valid effective_xcpus left. The isolated partition can > remain valid. In both cases, the invalid isolated CPUs will have to be > released from isolated_cpus if appropriate. > > Fix that by calling isolated_cpus_release() to release those isolated > CPUs from isolated_cpus. > > New test cases are added to test_cpuset_prs.sh to test this. > > Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions") > Signed-off-by: Waiman Long > --- > kernel/cgroup/cpuset.c | 16 +++++++++++++++- > .../testing/selftests/cgroup/test_cpuset_prs.sh | 6 ++++++ > 2 files changed, 21 insertions(+), 1 deletion(-) > > [v3.1] Fix the typo "cs->effective_cpus" => "cs->effective_xcpus". > > diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c > index 6d224e614e74..9a2a6f727929 100644 > --- a/kernel/cgroup/cpuset.c > +++ b/kernel/cgroup/cpuset.c > @@ -2012,8 +2012,22 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd, > * > * A partition error happens when parent has tasks and all > * its effective CPUs will have to be distributed out. > + * > + * For an isolated partition with a shrunk root partition parent > + * we may need to return some or all of its isolated CPUs. > */ > - if (nocpu || cpumask_empty(tmp->delmask)) { > + nocpu |= cpumask_empty(tmp->delmask); > + if ((parent_prs == PRS_ROOT) && (old_prs == PRS_ISOLATED)) { > + cpumask_clear(tmp->addmask); > + if (nocpu) > + cpumask_copy(tmp->addmask, cs->effective_xcpus); > + else if (!cpumask_subset(cs->effective_xcpus, parent->effective_xcpus)) > + cpumask_andnot(tmp->addmask, cs->effective_xcpus, > + parent->effective_xcpus); > + if (!cpumask_empty(tmp->addmask)) > + isolated_cpus_release(cs, tmp->addmask); > + } > + if (nocpu) { > part_error = PERR_NOCPUS; > if (is_partition_valid(cs)) > adding = cpumask_and(tmp->addmask, > diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh > index d7d0bef0a17a..ceb1a3b4f94e 100755 > --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh > +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh > @@ -522,6 +522,12 @@ TEST_MATRIX=( > # its effective xcpus will be removed from isolated_cpus. > " C1-4:P1 C3-4:P2 . . T:C3-4 . . . 0 A1:3-4|A2:3-4 A1:P1|A2:P-2 ." > > + # When a root partition parent with an isolated partition child is shrunk > + # so that its effective xcpus is no longer a superset of its child effective > + # xcpus, the invalid isolated CPUs should be removed from cpuset.cpus.isolated. > + " C1-4:P1 C3-4:P2 . . T:C4-6 . . . 0 A1:5-6|A2:4 A1:P1|A2:P2 4" > + " C1-4:P1 C1-2:P2 . . T:C4-6 . . . 0 A1:4-6|A2:4-6 A1:P1|A2:P-2 ." > + > # > # old-A1 old-A2 old-A3 old-B1 new-A1 new-A2 new-A3 new-B1 fail ECPUs Pstate ISOLCPUS > # ------ ------ ------ ------ ------ ------ ------ ------ ---- ----- ------ -------- Reviewed-by: Guopeng Zhang Tested-by: Guopeng Zhang Thanks, Guopeng