From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792785661; b=4RUr1q47lvZH3ZBwmxHswZ6C2QYwKsfihu3uu6GeCpf9mrHHJOvSv9U9cE+g/Es/MxX3 KVvTO8Y50rNxQsdbfQdjDggAFsBA2DblgXWZ/1FTHz0olsHISJzbRCXxaP+Ooe5NOuxRJ HyHHHY13VWFusQQow9gUafeyv6nlQhB8LpIGoEuhIWB08cBQehT9HfkD/xxCgtg9rOeZ7 ggY9jq8LcPtgZ76naBkj+BYv4jeEuLRWvYf9jrNLZZjPOpm6IrSgCqLgxsD8gm2zTx/KW u5LQI7pSLmVvnGFBhuBDc4hsBVttcWpcSK8WRvi2N2zGYf81LanfkQUX8xJ+ywIBMpA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792785661; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=41akheXLDiu5sa/hLvnKGPpvOk6X/oqZPDwHABeQ4+A=; b=OV7tRNLr5mzdMEOzHVsxKW9PyUGg8Ot6PEJf525nueY6/GRgwQtjAbPd6qaWctXgENH7 kbQHKPe5WY8OLY/ff3GEOrOhZw6Q7uNqdnsLmOu17qmCR/Px19yomaGVoof6kuHLMM+nc vSdJNuo+m1u/4QQXnQscvg7j4Z7lO2K6snWjWB9usF2JKibn9Ai6Ut7n3VfcvUbXAaTJ+ uGr/sCYeEtSRvArgylrNBqqjC4pAaesPhN74Mi6YL5jqZ5HHEj9gXz8NEMd2TNqMnpqsu BQNVNrQKgaZIKsOCEfux48iWsnTMgcP5OFFuVVD83Y06rDO6Rhxl//jFZiKP4ui+spg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BGIZqWwq; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19824606A32E for ; Fri, 23 Oct 2026 20:01:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 19824606A32E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BGIZqWwq DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792785660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=41akheXLDiu5sa/hLvnKGPpvOk6X/oqZPDwHABeQ4+A=; b=BGIZqWwq0+BDYz3ssMEZO+5Sj1/RMF4xNl7Ty0RHH87TlxJQbSO2AFtO/K350qIK/9+pLh QpMTUBwP9wOKdyicXBHW8U39rU+tWCbOiEMCw6jnmvniO5d9hN5P+yPyIMGV9qg3TkJc0H hjNFuiS7tfk21nB/R0iuRqZzPdTkD9k= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-167-_pcV6CCsOoak6Q-1Wj-fKw-1; Fri, 23 Oct 2026 16:00:52 -0400 X-MC-Unique: _pcV6CCsOoak6Q-1Wj-fKw-1 X-Mimecast-MFC-AGG-ID: _pcV6CCsOoak6Q-1Wj-fKw_1792785650 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 49BF41944B38; Fri, 23 Oct 2026 20:00:49 +0000 (UTC) Received: from llong-thinkpadp16vgen1.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4C8611955F25; Fri, 23 Oct 2026 20:00:46 +0000 (UTC) From: Waiman Long To: Ridong Chen , Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Shuah Khan Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Guopeng Zhang , Waiman Long , Guopeng Zhang Subject: [PATCH-next v2 01/10] cgroup/cpuset: Find furthest isolated ancestor for invalidated isolated partition Date: Fri, 23 Oct 2026 16:00:27 -0400 Message-ID: <20261023200036.60560-2-longman@redhat.com> In-Reply-To: <20261023200036.60560-1-longman@redhat.com> References: <20261023200036.60560-1-longman@redhat.com> 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Commit 46b885416c27 ("cgroup/cpuset: Fix a missing isolated_cpus update in update_cpumasks_hier()") searches for the closet partition root ancestor to determine if the isolated CPUs in a to be invalidated isolation partition should be removed from isolated_cpus or not. As reported by sashiko, this method may not work when there is a deeply nested isolated partition hierarchy. For instance, Consider a nested hierarchy A0 -> A1 -> A2 -> A3 where all four are PRS_ISOLATED: A0: effective_xcpus = 0-4 A1: effective_xcpus = 1-4 A2: effective_xcpus = 2-4 A3: effective_xcpus = 3-4 When A1 shrinks its exclusive_cpus from 1-4 to 1-2, A2 will update it effective_xcpus to 2. A3 will find its closet partition root ancestor A2 and decides that its effective_xcpus 3-4 should be removed from isolated_cpus which is incorrect. Address this corner case by searching for the furthest isolated partition root ancestor instead to decide if its isolated CPUs should be returned to isolated_cpus. There are other pre-existing problems that will still prevent the above test case to work correctly. These problems will be addressed in subsequent patches. Reviewed-by: Guopeng Zhang Tested-by: Guopeng Zhang Reviewed-by: Ridong Chen Fixes: 46b885416c27 ("cgroup/cpuset: Fix a missing isolated_cpus update in update_cpumasks_hier()") Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 585a982249ad..1ca548cd50fd 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -2156,22 +2156,20 @@ static void compute_partition_effective_cpumask(struct cpuset *cs, } /* - * ancestor_partition - Find and return the closest valid partition root ancestor + * furthest isolated_ancestor - Return furthest isolated partition root ancestor available * @cs: the current cpuset - * - * Return: The closet partition root ancestor cpuset + * Return: The furthest isolated partition root ancestor available or NULL if + * not found. */ -static struct cpuset *ancestor_partition(struct cpuset *cs) +static struct cpuset *furthest_isolated_ancestor(struct cpuset *cs) { struct cpuset *ancestor = parent_cs(cs); + struct cpuset *iancestor = NULL; - /* - * The top_cpuset is always a valid partition root which will stop - * the loop if it is reached. - */ - while (!is_partition_valid(ancestor)) - ancestor = parent_cs(ancestor); - return ancestor; + for (; ancestor; ancestor = parent_cs(ancestor)) + if (ancestor->partition_root_state == PRS_ISOLATED) + iancestor = ancestor; + return iancestor; } /* @@ -2283,23 +2281,23 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp, * For a to be invalidated isolated partition, * its isolated CPUs may or may not need to be * removed from isolated_cpus depending on if - * its closest partition root ancestor is a root - * or isolated partition. With a PRS_ISOLATED - * ancestor, the CPUs are checked against its - * effective xcpus to see if any of them needed - * to be removed. + * there is a furthest isolated partition root + * ancestor available. When such a PRS_ISOLATED + * ancestor is available, the CPUs are checked + * against its effective xcpus to see if any of + * them needed to be removed. */ if (is_partition_valid(cp)) new_prs = -old_prs; if (old_prs == PRS_ISOLATED) { - struct cpuset *ancestor = ancestor_partition(cp); + struct cpuset *iancestor = furthest_isolated_ancestor(cp); - if (ancestor->partition_root_state == PRS_ROOT) + if (!iancestor) del_cpus = cp->effective_xcpus; else if (cpumask_andnot(tmp->delmask, cp->effective_xcpus, - ancestor->effective_xcpus)) + iancestor->effective_xcpus)) del_cpus = tmp->delmask; if (del_cpus) { -- 2.56.0