From nobody Tue Feb 10 04:16:05 2026 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (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 BCC05322DD0; Thu, 25 Dec 2025 12:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766666761; cv=none; b=bsqzgQE+fABVjSRcPI/6wCMy3HBYGHG0NkjNm6zW+C1sB2cYs4QaREei33Bj/05JiK+QzaEU5vx6ZUh+MM1+aj8Ob3bildNOMczK67KeELVO5fzT9qAU06LRSHU4RJPAqkYxAoPj/34m3/2xaQB69OaXIU6+3JbgynJ/TkATRVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766666761; c=relaxed/simple; bh=ZY9ySRKh0PSc/UDYu+NzAUS+LMgLq1DFfOJEhXxVRvc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pbKhH/mrSWrizkyV8yC6Oq0L3NjxbdMpwxpTlJw6/O8Xx6axLPKINRUS+zdmXR/lXHJQMUqSE/Wkjt3/se8kzRfegir88AdN4mBr3jRWB+yFvjB5y6t4m0bbdYtRkzUv/JNfM70Rhk3IzBYGYRvKtsNBCfsRR8S/VxzG6wB8HNM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=none smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.198]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4dcT3q1FRwzYQv5y; Thu, 25 Dec 2025 20:45:11 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 7F3A540576; Thu, 25 Dec 2025 20:45:51 +0800 (CST) Received: from hulk-vt.huawei.com (unknown [10.67.174.121]) by APP4 (Coremail) with SMTP id gCh0CgDHdfb1MU1pT76_BQ--.27441S12; Thu, 25 Dec 2025 20:45:51 +0800 (CST) From: Chen Ridong To: longman@redhat.com, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, lujialin4@huawei.com, chenridong@huaweicloud.com Subject: [PATCH RESEND -next 10/21] cpuset: introduce local_partition_disable() Date: Thu, 25 Dec 2025 12:30:47 +0000 Message-Id: <20251225123058.231765-11-chenridong@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251225123058.231765-1-chenridong@huaweicloud.com> References: <20251225123058.231765-1-chenridong@huaweicloud.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-CM-TRANSID: gCh0CgDHdfb1MU1pT76_BQ--.27441S12 X-Coremail-Antispam: 1UD129KBjvJXoWxGF1xXw47CryxXFy8Kr43GFg_yoW5Aw4DpF y7GrW3K3yUXFy7uasrXan7Aw1Fgws7JayxtwnrWayfJF17A3Wv9Fy0v3yvv3WjgFyDG347 ZFn0qr4UWF1xArUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUP014x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJw CI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7VUbx9NDUU UUU== X-CM-SenderInfo: hfkh02xlgr0w46kxt4xhlfz01xgou0bp/ Content-Type: text/plain; charset="utf-8" From: Chen Ridong The partition_disable() function introduced earlier can be extended to handle local partition disablement. The local_partition_disable() functions is introduced, which extracts the local partition disable logic from update_parent_effective_cpumask(). It calls partition_disable() to complete the disablement process. This refactoring establishes a clear separation between local and remote partition operations while promoting code reuse through the shared partition_disable() infrastructure. Signed-off-by: Chen Ridong --- kernel/cgroup/cpuset.c | 43 ++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 4146e9e7d104..27179db4cd22 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1789,6 +1789,31 @@ static int local_partition_enable(struct cpuset *cs, return 0; } =20 +/** + * local_partition_disable - Disable a local partition + * @cs: Target cpuset (local partition root) to disable + * @part_error: partition error when @cs is disabled + * @tmp: Temporary masks for CPU calculations + */ +static void local_partition_disable(struct cpuset *cs, enum prs_errcode pa= rt_error, + struct tmpmasks *tmp) +{ + struct cpuset *parent =3D parent_cs(cs); + int new_prs; + + lockdep_assert_held(&cpuset_mutex); + WARN_ON_ONCE(is_remote_partition(cs)); /* For local partition only */ + + if (!is_partition_valid(cs)) + return; + + new_prs =3D part_error ? -cs->partition_root_state : 0; + partition_disable(cs, parent, new_prs, part_error); + + cpuset_update_tasks_cpumask(parent, tmp->addmask); + update_sibling_cpumasks(parent, cs, tmp); +} + /** * update_parent_effective_cpumask - update effective_cpus mask of parent = cpuset * @cs: The cpuset that requests change in partition root state @@ -1879,19 +1904,7 @@ static int update_parent_effective_cpumask(struct cp= uset *cs, int cmd, =20 nocpu =3D tasks_nocpu_error(parent, cs, xcpus); =20 - if (cmd =3D=3D partcmd_disable) { - /* - * May need to add cpus back to parent's effective_cpus - * (and maybe removed from subpartitions_cpus/isolated_cpus) - * for valid partition root. xcpus may contain CPUs that - * shouldn't be removed from the two global cpumasks. - */ - if (is_partition_valid(cs)) { - cpumask_copy(tmp->addmask, cs->effective_xcpus); - adding =3D true; - } - new_prs =3D PRS_MEMBER; - } else if (newmask) { + if (newmask) { /* * Empty cpumask is not allowed */ @@ -3034,9 +3047,7 @@ static int update_prstate(struct cpuset *cs, int new_= prs) if (is_remote_partition(cs)) remote_partition_disable(cs, &tmpmask); else - update_parent_effective_cpumask(cs, partcmd_disable, - NULL, &tmpmask); - + local_partition_disable(cs, PERR_NONE, &tmpmask); /* * Invalidation of child partitions will be done in * update_cpumasks_hier(). --=20 2.34.1