From: Chen Ridong <chenridong@huaweicloud.com>
To: Waiman Long <llong@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: Re: [PATCH -next RFC 05/16] cpuset: factor out partition_update() function
Date: Mon, 20 Oct 2025 16:05:15 +0800 [thread overview]
Message-ID: <155a2703-e43e-41f7-bb91-2936f89c29e2@huaweicloud.com> (raw)
In-Reply-To: <6122ac29-3984-4364-ab37-4987b65b5450@redhat.com>
On 2025/10/20 10:43, Waiman Long wrote:
> On 9/28/25 3:12 AM, Chen Ridong wrote:
>> From: Chen Ridong <chenridong@huawei.com>
>>
>> Extract the core partition update logic into a dedicated partition_update()
>> 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 update workflow:
>> - Adding and removing exclusive CPUs via partition_xcpus_add()/del()
>> - Managing remote sibling relationships
>> - Synchronizing effective exclusive CPUs mask
>> - Updating partition state and error status
>> - Triggering required system updates and workqueue synchronization
>>
>> This creates a coherent interface for partition operations and establishes
>> a foundation for enhanced partition management while maintaining existing
>> remote partition behavior.
>>
>> Signed-off-by: Chen Ridong <chenridong@huawei.com>
>> ---
>> kernel/cgroup/cpuset.c | 71 ++++++++++++++++++++++++++++--------------
>> 1 file changed, 47 insertions(+), 24 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index 1944410ae872..0e2f95daf459 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -1587,6 +1587,49 @@ static void partition_disable(struct cpuset *cs, struct cpuset *parent,
>> cpuset_force_rebuild();
>> }
>> +/**
>> + * 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 *xcpus,
>> + struct cpumask *excpus, struct tmpmasks *tmp)
>> +{
>> + bool isolcpus_updated;
>> + bool excl_updated;
>> + struct cpuset *parent;
>> +
>> + lockdep_assert_held(&cpuset_mutex);
>> + WARN_ON_ONCE(!cpuset_v2());
>> + WARN_ON_ONCE(prs <= 0);
>> +
>> + parent = is_remote_partition(cs) ? NULL : parent_cs(cs);
>> + excl_updated = !cpumask_empty(tmp->addmask) ||
>> + !cpumask_empty(tmp->delmask);
>> +
>> + spin_lock_irq(&callback_lock);
>> + isolcpus_updated = partition_xcpus_add(prs, parent, tmp->addmask);
>> + isolcpus_updated |= partition_xcpus_del(prs, parent, tmp->delmask);
>
> The current partition_xcpus_add/del() functions assume the given cpumas is non-empty. In the new
> partition_update() helper, you can pass an empty cpumask to them. This will cause useless work to be
> done. Also isolcpus_update may not be correct because of that causing unneeded work to be done in
> the workqueue code.
>
> -Longman
Thank you, Longman.
I think we can add a check for empty cpumask inputs in partition_xcpus_add() and
partition_xcpus_del() to avoid unnecessary operations.
To clarify, do you mean that passing an empty cpumask to these functions might lead to incorrect
isolcpus_updated value? or are you referring to other potential logic issues?
--
Best regards,
Ridong
next prev parent reply other threads:[~2025-10-20 8:05 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-28 7:12 [PATCH -next RFC 00/16] cpuset: rework local partition logic Chen Ridong
2025-09-28 7:12 ` [PATCH -next RFC 01/16] cpuset: use update_partition_sd_lb in update_cpumasks_hier Chen Ridong
2025-10-20 2:37 ` Waiman Long
2025-10-20 7:30 ` Chen Ridong
2025-09-28 7:12 ` [PATCH -next RFC 02/16] cpuset: generalize validate_partition() interface Chen Ridong
2025-09-28 7:12 ` [PATCH -next RFC 03/16] cpuset: factor out partition_enable() function Chen Ridong
2025-10-20 2:39 ` Waiman Long
2025-10-20 7:48 ` Chen Ridong
2025-10-20 19:42 ` Waiman Long
2025-10-21 0:52 ` Chen Ridong
2025-09-28 7:12 ` [PATCH -next RFC 04/16] cpuset: factor out partition_disable() function Chen Ridong
2025-09-28 7:12 ` [PATCH -next RFC 05/16] cpuset: factor out partition_update() function Chen Ridong
2025-10-20 2:43 ` Waiman Long
2025-10-20 8:05 ` Chen Ridong [this message]
2025-10-20 19:45 ` Waiman Long
2025-09-28 7:12 ` [PATCH -next RFC 06/16] cpuset: introduce local_partition_enable() Chen Ridong
2025-10-20 2:44 ` Waiman Long
2025-10-20 8:06 ` Chen Ridong
2025-09-28 7:12 ` [PATCH -next RFC 07/16] cpuset: introduce local_partition_disable() Chen Ridong
2025-10-20 2:46 ` Waiman Long
2025-10-20 8:06 ` Chen Ridong
2025-09-28 7:12 ` [PATCH -next RFC 08/16] cpuset: introduce local_partition_invalidate() Chen Ridong
2025-10-20 2:48 ` Waiman Long
2025-10-20 8:28 ` Chen Ridong
2025-09-28 7:12 ` [PATCH -next RFC 09/16] cpuset: introduce local_partition_update() Chen Ridong
2025-10-20 2:57 ` Waiman Long
2025-10-20 9:24 ` Chen Ridong
2025-09-28 7:13 ` [PATCH -next RFC 10/16] cpuset: remove redundant partition field updates Chen Ridong
2025-09-28 7:13 ` [PATCH -next RFC 11/16] cpuset: simplify partition update logic for hotplug tasks Chen Ridong
2025-10-20 3:00 ` Waiman Long
2025-10-20 8:44 ` Chen Ridong
2025-09-28 7:13 ` [PATCH -next RFC 12/16] cpuset: unify local partition disable and invalidate Chen Ridong
2025-09-28 7:13 ` [PATCH -next RFC 13/16] cpuset: use partition_disable for compute_partition_effective_cpumask Chen Ridong
2025-10-20 3:02 ` Waiman Long
2025-10-20 8:47 ` Chen Ridong
2025-09-28 7:13 ` [PATCH -next RFC 14/16] cpuset: fix isolcpus stay in root when isolated partition changes to root Chen Ridong
2025-10-20 3:06 ` Waiman Long
2025-10-20 9:13 ` Chen Ridong
2025-10-22 10:49 ` Chen Ridong
2025-09-28 7:13 ` [PATCH -next RFC 15/16] cpuset: use partition_disable for update_prstate Chen Ridong
2025-09-28 7:13 ` [PATCH -next RFC 16/16] cpuset: remove prs_err clear when notify_partition_change Chen Ridong
2025-09-28 9:57 ` [PATCH -next RFC 00/16] cpuset: rework local partition logic Chen Ridong
2025-09-28 16:00 ` Waiman Long
2025-09-29 1:17 ` Chen Ridong
2025-10-17 1:05 ` Chen Ridong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=155a2703-e43e-41f7-bb91-2936f89c29e2@huaweicloud.com \
--to=chenridong@huaweicloud.com \
--cc=cgups@vger.kernel.org \
--cc=chenridong@huawei.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llong@redhat.com \
--cc=lujialin4@huawei.com \
--cc=mkoutny@suse.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®