From nobody Tue Feb 10 05:10:22 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 60C8A3398A; Thu, 25 Dec 2025 12:45:53 +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=1766666755; cv=none; b=PQQma5CQRY4+PqjhBWifnzEjsxb82ftd1kEJRtiFjOlR8OWAjFD9+RcKHQEoqdOr1WZv3WZO6zVe59tPbQdbEkyahsLyO2U8ICFKpDcPZRoA9sZpRtjrOinV/2Fvmc4Z1GM/lk73TnyPsxejpyrrIIQ7MY8/NJOF/GPt2qJ9DvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766666755; c=relaxed/simple; bh=noJjTz8hMt2aO/yE9IMhRT1Jb6U14CD/n5WEzxKrX+g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H54n7Smh2AN3ANz+QRBTQ+Ju+MdKIzJxkOUeolCJISau8V0jZqD7GcGykeRfKI+YakmeIY8JgPZnTgwUmcJkfhzGS+NwfSj67cdq/VtWGNgQtaUqJ+2+4k5yd0tJNXL/znzIPc28qcDXvdaAsH3pUiVv5zvNnIislXqb5xsGP6o= 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.177]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4dcT3p6FjszYQv52; Thu, 25 Dec 2025 20:45:10 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 393684058C; 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--.27441S7; 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 05/21] cpuset: introduce partition_update() Date: Thu, 25 Dec 2025 12:30:42 +0000 Message-Id: <20251225123058.231765-6-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--.27441S7 X-Coremail-Antispam: 1UD129KBjvJXoWxuF45Xw43ur1kCFWxWr4rKrg_yoW5Wr4UpF ykCr43XayUKr13u3sxJFs7uw4rKa1vqF17twnrXr1rJFy2y3Wvv34qy398Jr1UX39rGry5 XFnIqr4SgF17AwUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPj14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjfUYcTQUUUU U X-CM-SenderInfo: hfkh02xlgr0w46kxt4xhlfz01xgou0bp/ Content-Type: text/plain; charset="utf-8" From: Chen Ridong Introduce partition_update() to centralize updates to key cpuset structures during a partition update, including: 1. effective_xcpus 2. exclusive_cpus Key operations performed: 1. Adding and removing exclusive CPUs via partition_xcpus_add()/del() 2. Synchronizing the effective exclusive CPUs mask 3. Updating the exclusive CPUs mask when modification is required 4. Triggering necessary system updates and workqueue synchronization 5. Updating the partition's exclusive flag 6. Sending partition change notifications Signed-off-by: Chen Ridong --- kernel/cgroup/cpuset.c | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index d1bf1a2f6acd..b0744a1074ad 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1558,6 +1558,51 @@ static void partition_disable(struct cpuset *cs, str= uct cpuset *parent, notify_partition_change(cs, old_prs); } =20 +/** + * partition_update - Update an existing partition configuration + * @cs: The cpuset to update + * @prs: Partition root state (must be positive) + * @xcpus: New exclusive CPUs mask for the partition (NULL to keep current) + * @excpus: New effective exclusive CPUs mask + * @tmp: Temporary masks + * + * Updates partition-related fields. The tmp->addmask is the CPU mask that + * will be added to the subpartitions_cpus and removed from parent's + * effective_cpus, and the tmp->delmask vice versa. + */ +static void partition_update(struct cpuset *cs, int prs, struct cpumask *x= cpus, + struct cpumask *excpus, struct tmpmasks *tmp) +{ + struct cpuset *parent; + int old_prs; + + lockdep_assert_held(&cpuset_mutex); + WARN_ON_ONCE(!cpuset_v2()); + WARN_ON_ONCE(prs <=3D 0); + + if (cpumask_empty(tmp->addmask) && + cpumask_empty(tmp->delmask)) + return; + + parent =3D is_remote_partition(cs) ? NULL : parent_cs(cs); + old_prs =3D cs->partition_root_state; + spin_lock_irq(&callback_lock); + partition_xcpus_add(prs, parent, tmp->addmask); + partition_xcpus_del(prs, parent, tmp->delmask); + /* + * Need to update effective_xcpus and exclusive_cpus now as + * update_sibling_cpumasks() below may iterate back to the same cs. + */ + cpumask_copy(cs->effective_xcpus, excpus); + if (xcpus) + cpumask_copy(cs->exclusive_cpus, xcpus); + spin_unlock_irq(&callback_lock); + update_isolation_cpumasks(); + cpuset_force_rebuild(); + update_partition_exclusive_flag(cs, prs); + notify_partition_change(cs, old_prs); +} + /* * remote_partition_enable - Enable current cpuset as a remote partition r= oot * @cs: the cpuset to update --=20 2.34.1