From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795920303; b=gUsVuvEpdkX/vywDBgyn8cWPjzW/ntuvy/pb5i6rVm3pWq4qgLvBd1nq+5+xaOoL4dQ2 8eUzcoXGlFvc9kpUaseiomcMPSGtbL7YOCaDv8soZICdT1jXqP/vwM/oreRTiF4R+1sGP KJGPHZqrqIq/5/ZrYyTHwmQEmsrD5K2GToE0WkgeYuKeK6poiwtH+H12vG7DRw6B9eh2i S3UGHyc+AF9GP7KBxAw6Dal5HgjIUw9JTGuFU1sSrk6Udvrtsu8cI31jWDMiuNGGOaUhu pxPG7OhTwqfG8MTCyur2OePHECBhh89YvLWuR7JXfycrc/OPXbb0qEL6yt90CoZ8gag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795920303; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-Id: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=wd2248h4tmbADwvPMHvx1uZmuHiVW29i7krYpK0WMAQ=; b=geHT2rEdYP4I7hONh3OGEe27WnJuH18fdlH18CCVOuLvl8MzWobzEjJO+Wy9BKngtrgy eKpwj1EFBt3oiqXgM1wbtM/Z+cJ2Yr24BfhyksP2jz2uDxM7OrPj32Jt+ytVSfi2D/ycB 9ZcYRVeE9Q/JbPHvhWjM1x3SJERJD8t12g1HpS+3aAGIy81WcHB76N7DeDSFfBnxVnrpj JLlgVH+AZCo14LFKh8S6mWo2U8Xx4e54pDkVx6SMp3ZBLb1X1HzNDZ907UF+dx1gZ19K+ bI2RiOFEW6KEVgeGCN08Kg+VPfX3FljXzodAPsPAEJNNrAt6UzyFU2QeSmNM2dNtXOg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Lfy4OGS9; arc=none smtp.remote-ip=95.215.58.199 Received: from mta1.migadu.com (out-199.mta1.migadu.com [95.215.58.199]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A0BA606A685 for ; Sun, 29 Nov 2026 02:45:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4A0BA606A685 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Lfy4OGS9 X-Envelope-To: cgroups@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=zZlgdBtPPagQ8GKiHckHNSBL7AR0awpOyoP0Q7iyKOM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1795920301; v=1; x=1796525101; b=Lfy4OGS9pNWteB1PAkZKVwAYbfhmmKLvUfpNvoUraDE5r4DuOf9Wc6MsmUCuSvPyX8LhyBfs s8uwMAPJ/TtYKwkJePC0sP8Y87t5DPTOSLFLm6az4UnK3N/03eF6E71JqSwHqJLCnabTqHKINbC /Iux+dlZ+PqjN/9pRGdaSJq0= X-Envelope-To: cgroups@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 29e756e523112bea; Sun, 29 Nov 2026 02:45:00 +0000 X-Mizu-Trace-ID: 29e756e523112bea X-Migadu-Flow: FLOW_OUT From: Ridong Chen To: Waiman Long , Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= Cc: Ridong Chen , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Ridong Chen Subject: [PATCH v6 05/12] cpuset: use partition_disable() for remote partition disablement Date: Sun, 29 Nov 2026 10:44:24 +0800 Message-Id: <20261129024431.2485721-6-ridong.chen@linux.dev> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261129024431.2485721-1-ridong.chen@linux.dev> References: <20261129024431.2485721-1-ridong.chen@linux.dev> X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Ridong Chen Now that the partition_disable() helper is available, replace the existing implementation for remote partition disablement with this centralized function to unify the disablement logic. remote_partition_disable() is removed and its callers call partition_disable() directly. The new partition root state is passed in by the caller instead of being derived from cs->prs_err, as only the caller knows which state the partition is going to. Signed-off-by: Ridong Chen --- kernel/cgroup/cpuset.c | 58 ++++++------------------------------------ 1 file changed, 8 insertions(+), 50 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 895e8aa455c1..f31512de9667 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1774,9 +1774,8 @@ static void partition_enable(struct cpuset *cs, struct cpuset *parent, * A valid partition gives its CPUs back to its parent (top_cpuset for a * remote partition), and the change is propagated down the hierarchy. */ -static void __maybe_unused partition_disable(struct cpuset *cs, int new_prs, - enum prs_errcode prs_err, - struct tmpmasks *tmp) +static void partition_disable(struct cpuset *cs, int new_prs, + enum prs_errcode prs_err, struct tmpmasks *tmp) { struct cpuset *parent = is_remote_partition(cs) ? NULL : parent_cs(cs); int old_prs = cs->partition_root_state; @@ -1928,48 +1927,6 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs, return 0; } -/* - * remote_partition_disable - Remove current cpuset from remote partition list - * @cs: the cpuset to update - * @tmp: temporary masks - * - * The effective_cpus is also updated. - * - * cpuset_mutex must be held by the caller. - */ -static void remote_partition_disable(struct cpuset *cs, struct tmpmasks *tmp) -{ - WARN_ON_ONCE(!is_remote_partition(cs)); - /* - * When a CPU is offlined, top_cpuset may end up with no available CPUs, - * which should clear subpartitions_cpus. We should not emit a warning for this - * scenario: the hierarchy is updated from top to bottom, so subpartitions_cpus - * may already be cleared when disabling the partition. - */ - WARN_ON_ONCE(!cpumask_subset(cs->effective_xcpus, subpartitions_cpus) && - !cpumask_empty(subpartitions_cpus)); - - spin_lock_irq(&callback_lock); - cs->remote_partition = false; - partition_xcpus_del(cs->partition_root_state, NULL, cs->effective_xcpus); - if (cs->prs_err) - cs->partition_root_state = -cs->partition_root_state; - else - cs->partition_root_state = PRS_MEMBER; - - /* effective_xcpus may need to be changed */ - compute_excpus(cs, cs->effective_xcpus); - reset_partition_data(cs); - spin_unlock_irq(&callback_lock); - cpuset_force_rebuild(); - - /* - * Propagate changes in top_cpuset's effective_cpus down the hierarchy. - */ - cpuset_update_tasks_cpumask(&top_cpuset, tmp->new_cpus); - update_sibling_cpumasks(&top_cpuset, NULL, tmp); -} - /* * remote_cpus_update - cpus_exclusive change of remote partition * @cs: the cpuset to be updated @@ -2045,7 +2002,7 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus, return; invalidate: - remote_partition_disable(cs, tmp); + partition_disable(cs, -prs, cs->prs_err, tmp); } /** @@ -2663,7 +2620,8 @@ static void partition_cpus_change(struct cpuset *cs, struct cpuset *trialcs, if (is_remote_partition(cs)) { if (trialcs->prs_err) - remote_partition_disable(cs, tmp); + partition_disable(cs, -cs->partition_root_state, + cs->prs_err, tmp); else remote_cpus_update(cs, trialcs->exclusive_cpus, trialcs->effective_xcpus, tmp); @@ -3210,7 +3168,7 @@ static int update_prstate(struct cpuset *cs, int new_prs) if (disable_partition) { if (is_remote_partition(cs)) - remote_partition_disable(cs, &tmpmask); + partition_disable(cs, PRS_MEMBER, PERR_NONE, &tmpmask); else update_parent_effective_cpumask(cs, partcmd_disable, NULL, &tmpmask); @@ -4158,8 +4116,8 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) if (is_remote_partition(cs) && (cpumask_empty(subpartitions_cpus) || (cpumask_empty(&new_cpus) && partition_is_populated(cs, NULL)))) { - WRITE_ONCE(cs->prs_err, PERR_HOTPLUG); - remote_partition_disable(cs, tmp); + partition_disable(cs, -cs->partition_root_state, PERR_HOTPLUG, + tmp); compute_effective_cpumask(&new_cpus, cs, parent); } -- 2.34.1