From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792785668; b=iKFoZknOmb4pP+rAjkgr9leaR2LMRG5KV92eiIH8/2HUW8uN8QxwNKRQUSBA5Irt6i5a jn/aBEKscKZJolIaWdXgq31IWumksS38Zw9dyJj0Nw/hM/XpT+1dwkDw+k1C9yJYtnb3l fFqx9hsDhRlC42bkxjbxRl1kWY2XhUv/qvhgspKp10xR77DkNdivRwNPhcDBhPwhr8Ulw zTCQN73DSqTfhmkgJ/TBfaRB8EmX/yL5TEyr4slQVmm3Zh8AlAVQvcJ3kChB1Gs2PIzR1 7WLumVRV2BovBYycO+Q7wXHVtOMo0EOoJZGJYlrb1IJauD5gcTQsbahHjVE6A9IQbZg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792785668; 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=t6K//W4VcL1SC5nLhi5TUGX6yNi2HIfAu/bUBgDdyxM=; b=Gp4ZWxk/AOO+y3EAlPSJQ8ZZC+HeXABnD2s36OS6mmDyKWptRU0J2FiWOeTdCSTa43x/ 6OFzzeGGqXVTFykeYW6vPn64L1lkq1apOw7YGuORw2J0xmRsU517IcvfJUtSAFpos/JsT yyZ/nW03NJMIzYGWNRGTsYPEq+yRtfYNFm4UrgxKeYvG6ZsedaxRxuh7ERzmvAFlNdbah 6vJxXsjrOVwptbNEBFgaa46g3xzXNuJSw9FtR14IDMbBGNVZ+q8axsI72etdUuXlQWpC5 ydsA9hRN0rE8fDZviFQr8YgMy7SGR7Fq7A8brRU7aAukOnOzAEDA5hfxxkBO7p6vAxA== 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=J42X8K5w; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 5B66560A3806 for ; Fri, 23 Oct 2026 20:01:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5B66560A3806 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=J42X8K5w DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792785667; 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=t6K//W4VcL1SC5nLhi5TUGX6yNi2HIfAu/bUBgDdyxM=; b=J42X8K5wy9U/++nrZzn6/72IbQELjK2KTRWJFE+skBBHcsjRhf+Gg9fRTFNMQyqh6NIYfv ieIple0Lo9u53AVPZVKtDC2v+aKLNUwmKOSPvyTcAej3AimVvAGnRllN8mVu/AbRNm6nUR H3Igtt5qu34aJ5t7pYnOBHERJitoe08= Received: from mx-prod-mc-05.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-320-Z00jYS-VPn675JvEsUBb4g-1; Fri, 23 Oct 2026 16:01:02 -0400 X-MC-Unique: Z00jYS-VPn675JvEsUBb4g-1 X-Mimecast-MFC-AGG-ID: Z00jYS-VPn675JvEsUBb4g_1792785661 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 246321956043; Fri, 23 Oct 2026 20:01:01 +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 5CDAB1956088; Fri, 23 Oct 2026 20:00:59 +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 Subject: [PATCH-next v2 07/10] cgroup/cpuset: Make sure compute_partition_effective_cpumask() is only called for valid partition Date: Fri, 23 Oct 2026 16:00:33 -0400 Message-ID: <20261023200036.60560-8-longman@redhat.com> In-Reply-To: <20261023200036.60560-1-longman@redhat.com> References: <20261023200036.60560-1-longman@redhat.com> X-Mailing-List: cgroups@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 With visual inspection to make sure that compute_partition_effective_cpumask() is only called for valid partition root, it was found that the function can be called for an invalidated partition near the end of cpuset_hotplug_update_tasks(). When partcmd is set, update_parent_effective_cpumask() is called to either invalidate a valid partition or with partcmd_update to check if an invalid partition can be switched back to valid. In both cases, cpuset_force_rebuild() should be invoked. However, compute_partition_effective_cpumask() should only be called when an invalid partition is switched back to valid. When a partition is invalidated, compute_effective_cpumask() should be called instead. Also add a WARN_ON_ONCE() in compute_partition_effective_cpumask() to ensure that a valid partition root is passed in. Fixes: 72c6303acfa1 ("cgroup/cpuset: Take isolated CPUs out of workqueue unbound cpumask") Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index d995f1ec5259..2c3a148fa40b 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -2116,6 +2116,8 @@ static void compute_partition_effective_cpumask(struct cpuset *cs, struct cpuset *child; bool populated = partition_is_populated(cs, NULL); + WARN_ON_ONCE(!is_partition_valid(cs)); + /* * Check child partition roots to see if they should be * invalidated when @@ -4023,9 +4025,12 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) if (partcmd >= 0) { update_parent_effective_cpumask(cs, partcmd, NULL, tmp); - if ((partcmd == partcmd_invalidate) || is_partition_valid(cs)) { + if (is_partition_valid(cs)) { compute_partition_effective_cpumask(cs, &new_cpus); cpuset_force_rebuild(); + } else if (partcmd == partcmd_invalidate) { + compute_effective_cpumask(&new_cpus, cs, parent); + cpuset_force_rebuild(); } } -- 2.56.0