From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 9F21626ED3E for ; Sun, 4 Jan 2026 21:25:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767561927; cv=none; b=mRnqyEW+hs2RzS/yzHYCnHnr0XiQrXZrwBwLb1ROHqo764jLoftyjTdjHjUr3rnFz5zqg5Najv8ijyVTHJx7ykKs0mEMBjMjNNtnzioN6SO/pKcDkCSMO/r+lLH8fcZ1KYDx7/aZg3vjdTaV1AqbjbOZWez9QdUwCV7YW9EzuiA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767561927; c=relaxed/simple; bh=ZsoC2tMVlEa/V20wtG1BE1AXcEXGl7jC4ulSuj+rZGw=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=p/agXd5snFkM3H3qnd97QlWNEanrGve1rB50lHIFfeR74/3yJ6imONg4mvxLYHnXG2muOmJDtwLMuvA7OGMTc0EQpEB4aANGzcZQ7qu80N8SMitQqL55wMs9k5XUbntFRY286iCbtwAbujKdSRq3cTFEpMbLcx4u6P94hhJeyAQ= 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=HkAjPYRs; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Oof5REzp; arc=none smtp.client-ip=170.10.129.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="HkAjPYRs"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Oof5REzp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767561924; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aOqQ/3LsDQyPGmsZ/qMD/HHwJen4ANQ7/h6zgU7Vmbg=; b=HkAjPYRsH8KlQT8BWYwpQLWMpMkLRq0Gt0OVNGoIgQTG0gk02GZSA6iCgZ29rzXR5v3n+j G7r6W4YKs771P/XfSiHN01FU0JXfZDQmAyd6dJYr8nAf6Dy8ZsCmf5uyIfNWZ01Cec30WA Ft8RkmJZBzBpUGWHBR95elaNuJbjzdk= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-391--bDm03BgM_iaaaOIeAeJLQ-1; Sun, 04 Jan 2026 16:25:23 -0500 X-MC-Unique: -bDm03BgM_iaaaOIeAeJLQ-1 X-Mimecast-MFC-AGG-ID: -bDm03BgM_iaaaOIeAeJLQ_1767561923 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-88a360b8096so372236946d6.0 for ; Sun, 04 Jan 2026 13:25:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1767561923; x=1768166723; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:from:to :cc:subject:date:message-id:reply-to; bh=aOqQ/3LsDQyPGmsZ/qMD/HHwJen4ANQ7/h6zgU7Vmbg=; b=Oof5REzpqhZ1UbHUIYRBSShC5Ib+bM/NY7sb9TlDleNYvREuuiCXQPIWPmpGRi3sjL 2Yzsvm/jDpnP6ymlCmxsKRoCW86QiqWU7pn+asJ1hXT1VDLRpyWjqZ9jYQFDvK1jCIvc ml7YYrjv/zlePFGGbukjMgkQLNYP0rSXroTgA8Dp+geqkDeJPE/QV1hEjzqPM3tDrpFC S/oFYt7cDbpHGa+r6M2NbsZA2gr5GM5P3CpCXWz118tmOna9QTqvaP30IaUPZ2PXFijE P6WmXIAl4YAweZQb35p8SlrqNRvhHhn0AZQWnQu5Rj/WuADKG/NscoDwsvwEAfpTqHui U3oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767561923; x=1768166723; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aOqQ/3LsDQyPGmsZ/qMD/HHwJen4ANQ7/h6zgU7Vmbg=; b=b3kOdnnJFQmclKfDIleKqtMHh6njMufQmc4Rg7Oir32cYzV9JPTHovDzSvJ/n7IjU0 cOQuqiY2NsBNrCM4Ufc/jDPs+TBJ3CV/IOa1OPYHQojMUuM9wlPy9y/x/EsYZabcIyZz e5C6OZuLluQFZP7UVeqaImJ1b9Z3Q3dI0tMtxBSWxYX41aDdBXGkvioYP+uP8yAmf/Cu RmUUYccfYpCuzFgjPHcTH43vyxpAZ3NipoV7LJPWUWvpPA5D1An9+S1U+2XhO7Q7s85N CyZWr4brBEpVBAhmQmarq5b8MhUdouJUcYHxWttVmVgvMw9hT9zIMEQGaA8Qykw7FAmo rkDA== X-Gm-Message-State: AOJu0YzPvAZNPDUeLdN1phC1RWo7subydm+eQUAtzzr95sssnzJZ7fkQ H98qEnNvJFx8cKM+aW9Q7I8v39WoNAxPcZVk+HPhlBGX92YVV2+HByu5HSA4jFcSGYoHJmKNuJr AGRh0EvwYRvIqyhq6KbXB+YjPA722i5rpR5880O2pfdoW/NG4/52tjOewt0xAWcI+lA== X-Gm-Gg: AY/fxX5X1Dv5qJGkip/syPXb4ICH9E/fGjiym4kzJm4uf1EMxvX9LLgGGGFv/xU9H7Q iqn+Ql/nsONDtXi9DWyqxcPCw3er6VjL/G+FJz5HbuLbn1Ps/tXrRTFoORGvht5ScXHAO7T9P6Q k+2xlEsTUtDsiIqBlLxF8zQHL4HMlyp/ZEJOmqdMyQtxt6cIxazN5xZn2VGVPAXdFGebuDZCMEh pFRewGdQ66YPuOtmVzmgOVrjD950sZV07UEByTYSq+uDoWHNiZvr6BwtU8EbfEVYls8D2Cs4JqL fp+IYNYxCkBcwAdjmz7NTdeZFCrvotnYuL4/m1rljqvThuxrEkDCB/OydDnEaY15r7OUgdn3f7e ASfAcMlHqvbiH5S6N1ekVVE7tcBKbXtNeyrVlM4VnyJ2OTPE5QLEaiv9c X-Received: by 2002:a05:6214:1256:b0:890:5096:5135 with SMTP id 6a1803df08f44-8905096517dmr136138686d6.68.1767561922723; Sun, 04 Jan 2026 13:25:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGjEWzmCELS1IKWJk+NFIRBxSBEzNKCkY4OMkGpVYZP90YAaap30Vzj2VWFlb3eK91+sSj6ZQ== X-Received: by 2002:a05:6214:1256:b0:890:5096:5135 with SMTP id 6a1803df08f44-8905096517dmr136138446d6.68.1767561922268; Sun, 04 Jan 2026 13:25:22 -0800 (PST) Received: from ?IPV6:2601:188:c102:b180:1f8b:71d0:77b1:1f6e? ([2601:188:c102:b180:1f8b:71d0:77b1:1f6e]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-88d99d7dbdcsm336419506d6.43.2026.01.04.13.25.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 04 Jan 2026 13:25:21 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: Date: Sun, 4 Jan 2026 16:25:20 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [cgroup/for-6.20 PATCH v2 2/4] cgroup/cpuset: Consistently compute effective_xcpus in update_cpumasks_hier() To: Chen Ridong , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, Sun Shaojie References: <20260101191558.434446-1-longman@redhat.com> <20260101191558.434446-3-longman@redhat.com> <758f42df-52c2-4660-8ef7-1cbacb9323d2@huaweicloud.com> Content-Language: en-US In-Reply-To: <758f42df-52c2-4660-8ef7-1cbacb9323d2@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/3/26 9:48 PM, Chen Ridong wrote: > > On 2026/1/2 3:15, Waiman Long wrote: >> 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 | 14 +++++--------- >> 1 file changed, 5 insertions(+), 9 deletions(-) >> >> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c >> index da2b3b51630e..37d118a9ad4d 100644 >> --- a/kernel/cgroup/cpuset.c >> +++ b/kernel/cgroup/cpuset.c >> @@ -2168,17 +2168,13 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp, >> spin_lock_irq(&callback_lock); >> cpumask_copy(cp->effective_cpus, tmp->new_cpus); >> cp->partition_root_state = new_prs; >> - if (!cpumask_empty(cp->exclusive_cpus) && (cp != cs)) >> - compute_excpus(cp, cp->effective_xcpus); >> - >> /* >> - * Make sure effective_xcpus is properly set for a valid >> - * partition root. >> + * Need to compute effective_xcpus if either exclusive_cpus >> + * is non-empty or it is 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) || !cpumask_empty(cp->exclusive_cpus)) >> + compute_excpus(cp, cp->effective_xcpus); >> + if (new_prs < 0) >> reset_partition_data(cp); >> spin_unlock_irq(&callback_lock); >> > The code resets partition data only for new_prs < 0. My understanding is that a partition is invalid > when new_prs <= 0. Shouldn't reset_partition_data() also be called when new_prs = 0? Is there a > specific reason to skip the reset in that case? update_cpumasks_hier() is called when changes in a cpuset or hotplug affects other cpusets in the hierarchy. With respect to changes in partition state, it is either from valid to invalid or vice versa. It will not change from a valid partition to member. The only way new_prs = 0 is when old_prs = 0. Even if the affected cpuset is processed again in update_cpumask_hier(), any state change from valid partition to member (update_prstate()), reset_partition_data() should have been called there. That is why we only care about when new_prs != 0. The code isn't wrong here. However I can change the condition to (new_prs <= 0) if it makes it easier to understand. Cheers, Longman