From nobody Tue Feb 10 04:15:54 2026 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 BD6743233E3; Thu, 25 Dec 2025 12:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766666761; cv=none; b=gtYFeEMldY9uPGvZYGnChAsTiEDFtBove2ZDGBksywPuUSfihppmJpwLblzPpzOzLfSRJf5jxgqHoKJfcJrr7oDSuaBT6+UvPr9buTQrVXfn9ragrLneoYa0iDYnGTyUJBvk1rWk90uaIkt5Md1OeegIwLk/bURm7v1I6glogeg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766666761; c=relaxed/simple; bh=WHo8jbu0LlfxQ9CsK0AZuLDHg1O6GxeIvrF+IS7trcs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gkj9QldNzlvPabEHHbLL1lxeW5Hv3pgUlubxLVx7JTCLdnTuXgz2gJaAiXRtMPNHjYgeVH8hUTxY0Q4qYudr6EijM+EzxahR9du10T7G1BmjJtDfifzNsTM3xNNIaOA6caYeqS9kEB9lzIFfrUnSxyO2CpmW0cqKRi6xMeguiVI= 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.56 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.177]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4dcT4B2f4vzKHMjw; Thu, 25 Dec 2025 20:45:30 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id B4A174058C; 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--.27441S15; 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 13/21] cpuset: remove update_parent_effective_cpumask Date: Thu, 25 Dec 2025 12:30:50 +0000 Message-Id: <20251225123058.231765-14-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--.27441S15 X-Coremail-Antispam: 1UD129KBjvJXoW3GryxJr15Jr48AFy5ury5CFg_yoWfKrW8pr yUGrZrXFWDtr18C39Fqan7uw1rKwsFqa4qy3s8W3WfAFy7A3WvyryjyanYqFW5W3yDX34U Za90gr4fXF17AFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAV WUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUvYLPU UUUU= X-CM-SenderInfo: hfkh02xlgr0w46kxt4xhlfz01xgou0bp/ Content-Type: text/plain; charset="utf-8" From: Chen Ridong Clean up by removing the update_parent_effective_cpumask() function. Its logic has now been fully replaced and centralized by the new helper functions. Signed-off-by: Chen Ridong --- kernel/cgroup/cpuset.c | 282 ----------------------------------------- 1 file changed, 282 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index b16b15befca7..d4489079bff9 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1949,288 +1949,6 @@ static int local_partition_update(struct cpuset *cs= , struct tmpmasks *tmp) return __local_partition_update(cs, NULL, tmp->new_cpus, tmp, true); } =20 -/** - * update_parent_effective_cpumask - update effective_cpus mask of parent = cpuset - * @cs: The cpuset that requests change in partition root state - * @cmd: Partition root state change command - * @newmask: Optional new cpumask for partcmd_update - * @tmp: Temporary addmask and delmask - * Return: 0 or a partition root state error code - * - * For partcmd_enable*, the cpuset is being transformed from a non-partiti= on - * root to a partition root. The effective_xcpus (cpus_allowed if - * effective_xcpus not set) mask of the given cpuset will be taken away fr= om - * parent's effective_cpus. The function will return 0 if all the CPUs lis= ted - * in effective_xcpus can be granted or an error code will be returned. - * - * For partcmd_disable, the cpuset is being transformed from a partition - * root back to a non-partition root. Any CPUs in effective_xcpus will be - * given back to parent's effective_cpus. 0 will always be returned. - * - * For partcmd_update, if the optional newmask is specified, the cpu list = is - * to be changed from effective_xcpus to newmask. Otherwise, effective_xcp= us is - * assumed to remain the same. The cpuset should either be a valid or inva= lid - * partition root. The partition root state may change from valid to inval= id - * or vice versa. An error code will be returned if transitioning from - * invalid to valid violates the exclusivity rule. - * - * For partcmd_invalidate, the current partition will be made invalid. - * - * The partcmd_enable* and partcmd_disable commands are used by - * update_prstate(). An error code may be returned and the caller will che= ck - * for error. - * - * The partcmd_update command is used by update_cpumasks_hier() with newma= sk - * NULL and update_cpumask() with newmask set. The partcmd_invalidate is u= sed - * by update_cpumask() with NULL newmask. In both cases, the callers won't - * check for error and so partition_root_state and prs_err will be updated - * directly. - */ -static int update_parent_effective_cpumask(struct cpuset *cs, int cmd, - struct cpumask *newmask, - struct tmpmasks *tmp) -{ - struct cpuset *parent =3D parent_cs(cs); - int adding; /* Adding cpus to parent's effective_cpus */ - int deleting; /* Deleting cpus from parent's effective_cpus */ - int old_prs, new_prs; - int part_error =3D PERR_NONE; /* Partition error? */ - struct cpumask *xcpus =3D user_xcpus(cs); - int parent_prs =3D parent->partition_root_state; - bool nocpu; - - lockdep_assert_held(&cpuset_mutex); - WARN_ON_ONCE(is_remote_partition(cs)); /* For local partition only */ - - /* - * new_prs will only be changed for the partcmd_update and - * partcmd_invalidate commands. - */ - adding =3D deleting =3D false; - old_prs =3D new_prs =3D cs->partition_root_state; - - /* - * The parent must be a partition root. - * The new cpumask, if present, or the current cpus_allowed must - * not be empty. - */ - if (!is_partition_valid(parent)) { - return is_partition_invalid(parent) - ? PERR_INVPARENT : PERR_NOTPART; - } - if (!newmask && xcpus_empty(cs)) - return PERR_CPUSEMPTY; - - nocpu =3D tasks_nocpu_error(parent, cs, xcpus); - - if (newmask) { - /* - * Empty cpumask is not allowed - */ - if (cpumask_empty(newmask)) { - part_error =3D PERR_CPUSEMPTY; - goto write_error; - } - - /* Check newmask again, whether cpus are available for parent/cs */ - nocpu |=3D tasks_nocpu_error(parent, cs, newmask); - - /* - * partcmd_update with newmask: - * - * Compute add/delete mask to/from effective_cpus - * - * For valid partition: - * addmask =3D exclusive_cpus & ~newmask - * & parent->effective_xcpus - * delmask =3D newmask & ~exclusive_cpus - * & parent->effective_xcpus - * - * For invalid partition: - * delmask =3D newmask & parent->effective_xcpus - * The partition may become valid soon. - */ - if (is_partition_invalid(cs)) { - adding =3D false; - deleting =3D cpumask_and(tmp->delmask, - newmask, parent->effective_xcpus); - } else { - cpumask_andnot(tmp->addmask, xcpus, newmask); - adding =3D cpumask_and(tmp->addmask, tmp->addmask, - parent->effective_xcpus); - - cpumask_andnot(tmp->delmask, newmask, xcpus); - deleting =3D cpumask_and(tmp->delmask, tmp->delmask, - parent->effective_xcpus); - } - - /* - * TBD: Invalidate a currently valid child root partition may - * still break isolated_cpus_can_update() rule if parent is an - * isolated partition. - */ - if (is_partition_valid(cs) && (old_prs !=3D parent_prs)) { - if ((parent_prs =3D=3D PRS_ROOT) && - /* Adding to parent means removing isolated CPUs */ - !isolated_cpus_can_update(tmp->delmask, tmp->addmask)) - part_error =3D PERR_HKEEPING; - if ((parent_prs =3D=3D PRS_ISOLATED) && - /* Adding to parent means adding isolated CPUs */ - !isolated_cpus_can_update(tmp->addmask, tmp->delmask)) - part_error =3D PERR_HKEEPING; - } - - /* - * The new CPUs to be removed from parent's effective CPUs - * must be present. - */ - if (deleting) { - cpumask_and(tmp->new_cpus, tmp->delmask, cpu_active_mask); - WARN_ON_ONCE(!cpumask_subset(tmp->new_cpus, parent->effective_cpus)); - } - - /* - * Make partition invalid if parent's effective_cpus could - * become empty and there are tasks in the parent. - */ - if (nocpu && (!adding || - !cpumask_intersects(tmp->addmask, cpu_active_mask))) { - part_error =3D PERR_NOCPUS; - deleting =3D false; - adding =3D cpumask_and(tmp->addmask, - xcpus, parent->effective_xcpus); - } - } else { - /* - * partcmd_update w/o newmask - * - * delmask =3D effective_xcpus & parent->effective_cpus - * - * This can be called from: - * 1) update_cpumasks_hier() - * 2) cpuset_hotplug_update_tasks() - * - * Check to see if it can be transitioned from valid to - * invalid partition or vice versa. - * - * A partition error happens when parent has tasks and all - * its effective CPUs will have to be distributed out. - */ - if (nocpu) { - part_error =3D PERR_NOCPUS; - if (is_partition_valid(cs)) - adding =3D cpumask_and(tmp->addmask, - xcpus, parent->effective_xcpus); - } else if (is_partition_invalid(cs) && !cpumask_empty(xcpus) && - cpumask_subset(xcpus, parent->effective_xcpus)) { - struct cgroup_subsys_state *css; - struct cpuset *child; - bool exclusive =3D true; - - /* - * Convert invalid partition to valid has to - * pass the cpu exclusivity test. - */ - rcu_read_lock(); - cpuset_for_each_child(child, css, parent) { - if (child =3D=3D cs) - continue; - if (!cpusets_are_exclusive(cs, child)) { - exclusive =3D false; - break; - } - } - rcu_read_unlock(); - if (exclusive) - deleting =3D cpumask_and(tmp->delmask, - xcpus, parent->effective_cpus); - else - part_error =3D PERR_NOTEXCL; - } - } - -write_error: - if (part_error) - WRITE_ONCE(cs->prs_err, part_error); - - if (cmd =3D=3D partcmd_update) { - /* - * Check for possible transition between valid and invalid - * partition root. - */ - switch (cs->partition_root_state) { - case PRS_ROOT: - case PRS_ISOLATED: - if (part_error) - new_prs =3D -old_prs; - break; - case PRS_INVALID_ROOT: - case PRS_INVALID_ISOLATED: - if (!part_error) - new_prs =3D -old_prs; - break; - } - } - - if (!adding && !deleting && (new_prs =3D=3D old_prs)) - return 0; - - /* - * Transitioning between invalid to valid or vice versa may require - * changing CS_CPU_EXCLUSIVE. In the case of partcmd_update, - * validate_change() has already been successfully called and - * CPU lists in cs haven't been updated yet. So defer it to later. - */ - if ((old_prs !=3D new_prs) && (cmd !=3D partcmd_update)) { - int err =3D update_partition_exclusive_flag(cs, new_prs); - - if (err) - return err; - } - - /* - * Change the parent's effective_cpus & effective_xcpus (top cpuset - * only). - * - * Newly added CPUs will be removed from effective_cpus and - * newly deleted ones will be added back to effective_cpus. - */ - spin_lock_irq(&callback_lock); - if (old_prs !=3D new_prs) - cs->partition_root_state =3D new_prs; - - /* - * Adding to parent's effective_cpus means deletion CPUs from cs - * and vice versa. - */ - if (adding) - partition_xcpus_del(old_prs, parent, tmp->addmask); - if (deleting) - partition_xcpus_add(new_prs, parent, tmp->delmask); - - spin_unlock_irq(&callback_lock); - update_isolation_cpumasks(); - - if ((old_prs !=3D new_prs) && (cmd =3D=3D partcmd_update)) - update_partition_exclusive_flag(cs, new_prs); - - if (adding || deleting) { - cpuset_update_tasks_cpumask(parent, tmp->addmask); - update_sibling_cpumasks(parent, cs, tmp); - } - - /* - * For partcmd_update without newmask, it is being called from - * cpuset_handle_hotplug(). Update the load balance flag and - * scheduling domain accordingly. - */ - if ((cmd =3D=3D partcmd_update) && !newmask) - update_partition_sd_lb(cs, old_prs); - - notify_partition_change(cs, old_prs); - return 0; -} - /** * compute_partition_effective_cpumask - compute effective_cpus for partit= ion * @cs: partition root cpuset --=20 2.34.1