From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.205 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796444460; b=U1xexsvg7MlzM3MH2NYq8QB2tV59D5jw5EIbO47BliMv63zH726hvXhg2SwXSGx518fg pp3MnmksRx92UT9jO0IIEYS3x4KaNx+za7Z+MQuFo1HQLRA6e+nsLYGhPuXYEbZCVinX0 TUpCcOeLpHjfrdidbjKEy41bdX5hJcmRCXDrMhkur0vC88995Go2r6VlvDvc2SiBCZrgx RhYPLV0LWkPlCK6PKlXEGl39sMulJTujuHwR4htjyHi8uKAYAs90E24MdrsvPL8MnL13G fFmrOrYu0KnL3/+hHmR+Zc6XyT/phLfMz4i9e6DiZjDoPaOZJokZh7jAOnh8IzhSw7g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796444460; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=6v8A7tsMa6mKCgcbl2AGNCqrgjkB2EEOXsobeMqFFuI=; b=2xf4YBS33bFGKYfeioKuVF7ezS9FoZ11qpQeXaMRI58KJkLpP8DK8fcK5EaMo40G0BrN 2OXl4TUKOUCVSPytE3eXM0CzrIXhIu2SeEtW+tMIulQhvDN2YgJnIhWVHsXiZvdhxx8Hc WtKgtrUF5JbdRHniuByuAV1erkkBdtGfRkypHlaLcNdUV1x6cwZgurMAoxMjRF3GcqWJ8 G4kQPU5bTfjxPLK23SIw8BzJE2FPsnuZ3X/phmBotQ+c/jRChieaxthDVG5gWpZdR/7k4 W0PH+USzYqmz6/52mY9NhtMch7tgvQRstepn+G8QwHblyBSvgQ76O1PMPYqEqNhXTag== 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=obWLHmDQ; arc=none smtp.remote-ip=95.215.58.205 Received: from mta1.migadu.com (out-205.mta1.migadu.com [95.215.58.205]) (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 E0B18606A334 for ; Sat, 5 Dec 2026 04:20:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E0B18606A334 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=obWLHmDQ X-Envelope-To: cgroups@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=lukWA4QA/A8/mC32DeFolfNKimRoM0Y9OR1XVpzvODU=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796444457; v=1; x=1797049257; b=obWLHmDQv1w+rVRufoxGvBCQAKHcq2Ukd+VJNSIU8EBS1fR1aZzaW3l3XP1+g0T0PfVe0RT5 Ks2wUMIa6cbbKVtF4LSRf2+L6gPQ7/ZYE59M5zIoBPehp8gEov+Fmu56VEyXpCjSaDwSfv+owFw 1WseAMAnMU6m3YgdvY4MhPF4= X-Envelope-To: cgroups@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 137ccebe1fdd33ea; Sat, 05 Dec 2026 04:20:56 +0000 X-Mizu-Trace-ID: 137ccebe1fdd33ea X-Migadu-Flow: FLOW_OUT Message-ID: Date: Sat, 5 Dec 2026 12:20:52 +0800 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 03/12] cpuset: introduce partition_update() To: Ridong Chen , Waiman Long , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Ridong Chen References: <20261129024431.2485721-1-ridong.chen@linux.dev> <20261129024431.2485721-4-ridong.chen@linux.dev> Content-Language: en-US From: Guopeng Zhang In-Reply-To: <20261129024431.2485721-4-ridong.chen@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 2026/11/29 10:44, Ridong Chen 写道: > From: Ridong Chen > > 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 scheduler domain rebuilds > > For a local partition, the CPUs to be added or deleted are restricted to > those in the parent's effective_xcpus, as the parent may have shrunk. > The function returns early if nothing is to be changed. > > The partition root state is unchanged by this function, so no partition > change notification is sent. > > Signed-off-by: Ridong Chen > --- > kernel/cgroup/cpuset.c | 53 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 53 insertions(+) > > diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c > index cfad92cf89d6..7efec768f212 100644 > --- a/kernel/cgroup/cpuset.c > +++ b/kernel/cgroup/cpuset.c > @@ -1825,6 +1825,59 @@ static void __maybe_unused partition_disable(struct cpuset *cs, int new_prs, > update_sibling_cpumasks(parent, cs, tmp); > } > > +/** > + * 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 CPUs in tmp->addmask are taken > + * from the effective_cpus of the parent, or of top_cpuset for a remote > + * partition, and the CPUs in tmp->delmask are given back to it. If that > + * parent is top_cpuset, subpartitions_cpus is updated accordingly. > + */ > +static void __maybe_unused partition_update(struct cpuset *cs, int prs, struct cpumask *xcpus, > + struct cpumask *excpus, struct tmpmasks *tmp) > +{ > + struct cpuset *parent; > + > + lockdep_assert_cpuset_lock_held(); > + WARN_ON_ONCE(!cpuset_v2()); > + WARN_ON_ONCE(prs <= 0); > + > + parent = is_remote_partition(cs) ? NULL : parent_cs(cs); > + > + /* > + * Only CPUs owned by the parent can be taken from or given back to > + * it, the parent may have shrunk. A remote partition gets its CPUs > + * from top_cpuset which owns all the CPUs. > + */ > + if (parent) { > + cpumask_and(tmp->addmask, tmp->addmask, parent->effective_xcpus); > + cpumask_and(tmp->delmask, tmp->delmask, parent->effective_xcpus); > + } > + if (cpumask_empty(tmp->addmask) && > + cpumask_empty(tmp->delmask) && > + cpumask_equal(cs->effective_xcpus, excpus)) > + return; > + > + 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() called by the callers afterwards 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); > + cpuset_force_rebuild(); > +} > + > /* > * remote_partition_enable - Enable current cpuset as a remote partition root > * @cs: the cpuset to update Reviewed-by: Guopeng Zhang Thanks, Guopeng