From nobody Sun Feb 8 20:00:14 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EF1957C9F for ; Thu, 25 Dec 2025 07:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766647935; cv=none; b=pQvxn+/4EIg+PrxxO56Rdk9e1A48TdNWED1nw89HMHbn2bFrtuDcow8l0GrfCf9Oc9ZuPRFl+NV2UsxTjuHKMNVSCZ4GTBqFiP+ccX+R6cK1ctM6Opo60+7LfwJ9x3tErZaWew0ysIcKq+DZ3xnZLnuSHeWcwYHuqbDeA6EB/c4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766647935; c=relaxed/simple; bh=sH+5miPshqDkdtfq9E6/zLk+kBgJe09PnQWL091CP4Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dibw2/z0vLDxrnlBSEKFgn6X6jgQzowfUUX79Ldp3+5dUwA9RhMk8ZzgROm0lLM9LCx/bWMwBBCKXUmXHA7BKlw/D821HhJw0S9E6JrdhGFHLdMeA4d/TfLhuOuj1wKG6QqmBvFYDeJ8E5ZMHHq7RKN4dF+vQQrnSK5l4U6kvKU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LExu5Nm2; arc=none smtp.client-ip=170.10.133.124 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) header.d=redhat.com header.i=@redhat.com header.b="LExu5Nm2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766647932; 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=uKn3Wb9FBU24/WkZZGdo+7ZlhH/dyKA25oZV0rC9FuM=; b=LExu5Nm24dOm9mtarYYeps3LTIC+Ol2xzRm92cju8d1f8GEyofJvKp8V6z4oni6EHECtLt T7sTbKO6JEZ0R6ijOFPjhkTZ3QZjRHLhWxoF2ekKvVasBxIsEwo++Q9L2mavItcp8ztdJw Vq+nFqFurqp18uU+zdvCqsaqTAuon4U= Received: from mx-prod-mc-01.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-688-Gj_sz55TMdqK0WjLH4yoQw-1; Thu, 25 Dec 2025 02:32:10 -0500 X-MC-Unique: Gj_sz55TMdqK0WjLH4yoQw-1 X-Mimecast-MFC-AGG-ID: Gj_sz55TMdqK0WjLH4yoQw_1766647928 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9E80119560B2; Thu, 25 Dec 2025 07:32:08 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.2.16.7]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0F9E419560AB; Thu, 25 Dec 2025 07:32:05 +0000 (UTC) From: Waiman Long To: Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Shuah Khan Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, Sun Shaojie , Chen Ridong , Waiman Long Subject: [cgroup/for-6.20 PATCH 2/4] cgroup/cpuset: Consistently compute effective_xcpus in update_cpumasks_hier() Date: Thu, 25 Dec 2025 02:30:54 -0500 Message-ID: <20251225073056.30789-3-longman@redhat.com> In-Reply-To: <20251225073056.30789-1-longman@redhat.com> References: <20251225073056.30789-1-longman@redhat.com> 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 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Since commit f62a5d39368e ("cgroup/cpuset: Remove remote_partition_check() & make update_cpumasks_hier() handle remote partition"), the compute_effective_exclusive_cpumask() helper was extended to strip exclusive CPUs from siblings when computing effective_xcpus (cpuset.cpus.exclusive.effective). This helper was later renamed to compute_excpus() in commit 86bbbd1f33ab ("cpuset: Refactor exclusive CPU mask computation logic"). This helper is supposed to be used consistently to compute effective_xcpus. However, there is an exception within the callback critical section in update_cpumasks_hier() when exclusive_cpus of a valid partition root is empty. This can cause effective_xcpus value to differ depending on where exactly it is last computed. Fix this by using compute_excpus() in this case to give a consistent result. Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 3d2d28f0fd03..850334dbc36a 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -2050,6 +2050,7 @@ static void update_cpumasks_hier(struct cpuset *cs, s= truct tmpmasks *tmp, struct cpuset *parent =3D parent_cs(cp); bool remote =3D is_remote_partition(cp); bool update_parent =3D false; + bool empty_xcpus; =20 old_prs =3D new_prs =3D cp->partition_root_state; =20 @@ -2160,20 +2161,14 @@ static void update_cpumasks_hier(struct cpuset *cs,= struct tmpmasks *tmp, new_prs =3D cp->partition_root_state; } =20 + empty_xcpus =3D cpumask_empty(cp->exclusive_cpus); spin_lock_irq(&callback_lock); cpumask_copy(cp->effective_cpus, tmp->new_cpus); cp->partition_root_state =3D new_prs; - if (!cpumask_empty(cp->exclusive_cpus) && (cp !=3D cs)) + if (((new_prs > 0) && empty_xcpus) || + ((cp !=3D cs) && !empty_xcpus)) compute_excpus(cp, cp->effective_xcpus); - - /* - * Make sure effective_xcpus is properly set for a valid - * partition root. - */ - if ((new_prs > 0) && cpumask_empty(cp->exclusive_cpus)) - cpumask_and(cp->effective_xcpus, - cp->cpus_allowed, parent->effective_xcpus); - else if (new_prs < 0) + if (new_prs < 0) reset_partition_data(cp); spin_unlock_irq(&callback_lock); =20 --=20 2.52.0