From nobody Wed Oct 1 22:18:13 2025 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 80F7F2BE635 for ; Sun, 28 Sep 2025 07:29:02 +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=1759044545; cv=none; b=p1cb0S1y1nGbghdwkHx4QUtxNtN3iclZaoww+8Kr5i75pkIu/EPwC83DkNNYSFwodjthUuJtjPKlE+nq26YnveLtN33OqvmKb8rL9XXmCk+UX5sb11LZXhE43eNd87eCRcOIEtukkXC3b2ukM8KD4JnrQia4X3x9x66JcF7n6tI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759044545; c=relaxed/simple; bh=L/Z4MPj9KNffXczu0mrMhkxO7Cy5of6BEJ7dMlLNlN8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y8cvrVO49ZGPQDizUFI8y7IV9m1uLrXFaxBO9hOQLx0UujXhrw4TQul2dk+QcMxfp6anezNslJxHkG0ouOD51ZTKF8pGa0+nlqx7c0kLg1sdaX/B9IKRN45C/qfjQ/ymbFaPpJwm8grKz08tJQdTxtCDy9vTWJqcFvuim+FxMQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass 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=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4cZGCD64N6zYQvfF; Sun, 28 Sep 2025 15:28:40 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id BB5DC1A14B8; Sun, 28 Sep 2025 15:28:54 +0800 (CST) Received: from hulk-vt.huawei.com (unknown [10.67.174.121]) by APP2 (Coremail) with SMTP id Syh0CgAHUhaY49hoiDJLBA--.29596S6; Sun, 28 Sep 2025 15:28:54 +0800 (CST) From: Chen Ridong To: longman@redhat.com, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com Cc: cgups@vger.kernel.org, linux-kernel@vger.kernel.org, lujialin4@huawei.com, chenridong@huawei.com Subject: [PATCH -next RFC 04/16] cpuset: factor out partition_disable() function Date: Sun, 28 Sep 2025 07:12:54 +0000 Message-Id: <20250928071306.3797436-5-chenridong@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250928071306.3797436-1-chenridong@huaweicloud.com> References: <20250928071306.3797436-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: Syh0CgAHUhaY49hoiDJLBA--.29596S6 X-Coremail-Antispam: 1UD129KBjvJXoWxZr4DZr4kZryrCw1rtr1UWrg_yoWrJF1UpF 15CrWfKFWUXr13ua9rJFs29w1rKw4kXF17t347WryrXFy3J3Wqya4jk39Yv3WUXryDG3y5 Za1qgr48XF12y3JanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUB0b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxVAaw2AFwI0_JF0_Jw1l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUwuWlUUUUU X-CM-SenderInfo: hfkh02xlgr0w46kxt4xhlfz01xgou0bp/ Content-Type: text/plain; charset="utf-8" From: Chen Ridong Extract the core partition disablement logic into a dedicated partition_disable() function. This refactoring centralizes updates to key cpuset data structures including remote_sibling, effective_xcpus, partition_root_state, and prs_err. The function handles the complete partition disablement workflow: - Removing exclusive CPUs via partition_xcpus_del() - Cleaning up remote sibling relationships - Recomputing effective exclusive CPUs mask - Updating partition state and error status - Triggering required scheduler domain rebuilds This creates a symmetric interface with partition_enable() and establishes a foundation for future local partition support while maintaining existing remote partition behavior. Signed-off-by: Chen Ridong --- kernel/cgroup/cpuset.c | 49 +++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 43ce62f4959c..1944410ae872 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1558,6 +1558,35 @@ static void partition_enable(struct cpuset *cs, stru= ct cpuset *parent, cpuset_force_rebuild(); } =20 +/** + * partition_disable - Disable partition root state for a cpuset + * @cs: The cpuset to disable partition for + * @parent: Parent cpuset of @cs, NULL for remote parent + * @new_prs: New partition root state (should be non-positive) + * @prs_err: Error code to set if disabling due to validation failure + */ +static void partition_disable(struct cpuset *cs, struct cpuset *parent, + int new_prs, enum prs_errcode prs_err) +{ + bool isolcpus_updated; + + lockdep_assert_held(&cpuset_mutex); + WARN_ON_ONCE(new_prs > 0); + WARN_ON_ONCE(!cpuset_v2()); + + spin_lock_irq(&callback_lock); + list_del_init(&cs->remote_sibling); + /* disable a partition should only delete exclusive cpus */ + isolcpus_updated =3D partition_xcpus_del(cs->partition_root_state, + parent, cs->effective_xcpus); + /* effective_xcpus may need to be changed */ + compute_excpus(cs, cs->effective_xcpus); + partition_state_update(cs, new_prs, prs_err); + spin_unlock_irq(&callback_lock); + update_unbound_workqueue_cpumask(isolcpus_updated); + cpuset_force_rebuild(); +} + /* * remote_partition_enable - Enable current cpuset as a remote partition r= oot * @cs: the cpuset to update @@ -1613,27 +1642,13 @@ static int remote_partition_enable(struct cpuset *c= s, int new_prs, */ static void remote_partition_disable(struct cpuset *cs, struct tmpmasks *t= mp) { - bool isolcpus_updated; + int new_prs; =20 WARN_ON_ONCE(!is_remote_partition(cs)); WARN_ON_ONCE(!cpumask_subset(cs->effective_xcpus, subpartitions_cpus)); =20 - spin_lock_irq(&callback_lock); - list_del_init(&cs->remote_sibling); - isolcpus_updated =3D partition_xcpus_del(cs->partition_root_state, - NULL, cs->effective_xcpus); - if (cs->prs_err) - cs->partition_root_state =3D -cs->partition_root_state; - else - cs->partition_root_state =3D PRS_MEMBER; - - /* effective_xcpus may need to be changed */ - compute_excpus(cs, cs->effective_xcpus); - reset_partition_data(cs); - spin_unlock_irq(&callback_lock); - update_unbound_workqueue_cpumask(isolcpus_updated); - cpuset_force_rebuild(); - + new_prs =3D cs->prs_err ? -cs->partition_root_state : PRS_MEMBER; + partition_disable(cs, NULL, new_prs, cs->prs_err); /* * Propagate changes in top_cpuset's effective_cpus down the hierarchy. */ --=20 2.34.1