From: Waiman Long <llong@redhat.com>
To: Chen Ridong <chenridong@huaweicloud.com>,
Waiman Long <llong@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@huawei.com
Subject: Re: [PATCH -next RFC 09/11] cpuset: refactor partition_cpus_change
Date: Tue, 2 Sep 2025 09:30:17 -0400 [thread overview]
Message-ID: <2a6759fa-841a-4185-ae94-b8215c93daf5@redhat.com> (raw)
In-Reply-To: <031d83b6-bc67-4941-8c49-e1d12df74062@huaweicloud.com>
On 8/29/25 10:01 PM, Chen Ridong wrote:
>
> On 2025/8/30 4:32, Waiman Long wrote:
>> On 8/28/25 8:56 AM, Chen Ridong wrote:
>>> From: Chen Ridong <chenridong@huawei.com>
>>>
>>> Refactor the partition_cpus_change function to handle both regular CPU
>>> set updates and exclusive CPU modifications, either of which may trigger
>>> partition state changes. This generalized function will also be utilized
>>> for exclusive CPU updates in subsequent patches.
>>>
>>> Signed-off-by: Chen Ridong <chenridong@huawei.com>
>>> ---
>>> kernel/cgroup/cpuset.c | 59 ++++++++++++++++++++++++++----------------
>>> 1 file changed, 36 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>>> index 75ad18ab40ae..e3eb87a33b12 100644
>>> --- a/kernel/cgroup/cpuset.c
>>> +++ b/kernel/cgroup/cpuset.c
>>> @@ -2447,6 +2447,41 @@ static int acpus_validate_change(struct cpuset *cs, struct cpuset *trialcs,
>>> return retval;
>>> }
>>> +/**
>>> + * partition_cpus_change - Handle partition state changes due to CPU mask updates
>>> + * @cs: The target cpuset being modified
>>> + * @trialcs: The trial cpuset containing proposed configuration changes
>>> + * @tmp: Temporary masks for intermediate calculations
>>> + *
>>> + * This function handles partition state transitions triggered by CPU mask changes.
>>> + * CPU modifications may cause a partition to be disabled or require state updates.
>>> + */
>>> +static void partition_cpus_change(struct cpuset *cs, struct cpuset *trialcs,
>>> + struct tmpmasks *tmp)
>>> +{
>>> + if (cs_is_member(cs))
>>> + return;
>>> +
>>> + invalidate_cs_partition(trialcs);
>>> + if (trialcs->prs_err)
>>> + cs->prs_err = trialcs->prs_err;
>>> +
>>> + if (is_remote_partition(cs)) {
>>> + if (trialcs->prs_err)
>>> + remote_partition_disable(cs, tmp);
>>> + else
>>> + remote_cpus_update(cs, trialcs->exclusive_cpus,
>>> + trialcs->effective_xcpus, tmp);
>>> + } else {
>>> + if (trialcs->prs_err)
>>> + update_parent_effective_cpumask(cs, partcmd_invalidate,
>>> + NULL, tmp);
>>> + else
>>> + update_parent_effective_cpumask(cs, partcmd_update,
>>> + trialcs->effective_xcpus, tmp);
>>> + }
>>> +}
>>> +
>>> /**
>>> * update_cpumask - update the cpus_allowed mask of a cpuset and all tasks in it
>>> * @cs: the cpuset to consider
>>> @@ -2483,29 +2518,7 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
>>> */
>>> force = !cpumask_equal(cs->effective_xcpus, trialcs->effective_xcpus);
>>> - invalidate_cs_partition(trialcs);
>>> - if (trialcs->prs_err)
>>> - cs->prs_err = trialcs->prs_err;
>>> -
>>> - if (is_partition_valid(cs) ||
>>> - (is_partition_invalid(cs) && !trialcs->prs_err)) {
>>> - struct cpumask *xcpus = trialcs->effective_xcpus;
>>> -
>>> - if (cpumask_empty(xcpus) && is_partition_invalid(cs))
>>> - xcpus = trialcs->cpus_allowed;
>> This if statement was added in commit 46c521bac592 ("cgroup/cpuset: Enable invalid to valid local
>> partition transition") that is missing in your new partition_cpus_change() function. Have you run
>> the test_cpuset_prs.sh selftest with a patched kernel to make sure that there is no test failure?
>>
>> Cheers,
>> Longman
> Thank you Longman,
>
> I did run the self-test for every patch, and I appreciate the test script test_cpuset_prs.sh you
> provided.
>
> The trialcs->effective_xcpus will be updated using compute_trialcs_excpus, which was introduced in
> Patch 4. The corresponding logic was then added in Patch 5:
>
> - cpumask_and(excpus, user_xcpus(trialcs), parent->effective_xcpus);
> + /* trialcs is member, cpuset.cpus has no impact to excpus */
> + if (cs_is_member(cs))
> + cpumask_and(excpus, trialcs->exclusive_cpus,
> + parent->effective_xcpus);
> + else
> + cpumask_and(excpus, user_xcpus(trialcs), parent->effective_xcpus);
> +
>
> Therefore, as long as excpus is computed correctly, I believe this implementation can handle the
> scenario appropriately.
It will be helpful to put down a note in the commit log that the missing
logic will be re-introduced in a subsequent patch.
Thanks,
Longman
next prev parent reply other threads:[~2025-09-02 13:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-28 12:56 [PATCH -next RFC 00/11] Refactor cpus mask setting Chen Ridong
2025-08-28 12:56 ` [PATCH -next RFC 01/11] cpuset: move the root cpuset write check earlier Chen Ridong
2025-08-29 19:21 ` Waiman Long
2025-08-30 1:11 ` Chen Ridong
2025-08-28 12:56 ` [PATCH -next RFC 02/11] cpuset: remove unused assignment to trialcs->partition_root_state Chen Ridong
2025-08-28 12:56 ` [PATCH -next RFC 03/11] cpuset: change return type of is_partition_[in]valid to bool Chen Ridong
2025-08-28 12:56 ` [PATCH -next RFC 04/11] cpuset: Refactor exclusive CPU mask computation logic Chen Ridong
2025-08-28 12:56 ` [PATCH -next RFC 05/11] cpuset: refactor CPU mask buffer parsing logic Chen Ridong
2025-08-28 12:56 ` [PATCH -next RFC 06/11] cpuset: introduce cpus_excl_conflict and mems_excl_conflict helpers Chen Ridong
2025-08-29 19:29 ` Waiman Long
2025-08-30 1:27 ` Chen Ridong
2025-08-28 12:56 ` [PATCH -next RFC 07/11] cpuset: refactor out invalidate_cs_partition Chen Ridong
2025-08-29 19:56 ` Waiman Long
2025-08-30 1:33 ` Chen Ridong
2025-08-28 12:56 ` [PATCH -next RFC 08/11] cpuset: refactor acpus_validate_change Chen Ridong
2025-08-29 20:12 ` Waiman Long
2025-08-30 1:42 ` Chen Ridong
2025-08-28 12:56 ` [PATCH -next RFC 09/11] cpuset: refactor partition_cpus_change Chen Ridong
2025-08-29 20:32 ` Waiman Long
2025-08-30 2:01 ` Chen Ridong
2025-09-02 13:30 ` Waiman Long [this message]
2025-09-03 0:51 ` Chen Ridong
2025-08-28 12:56 ` [PATCH -next RFC 10/11] cpuset: use parse_cpulist for setting cpus.exclusive Chen Ridong
2025-08-28 12:56 ` [PATCH -next RFC 11/11] cpuset: use partition_cpus_change for setting exclusive cpus 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=2a6759fa-841a-4185-ae94-b8215c93daf5@redhat.com \
--to=llong@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huawei.com \
--cc=chenridong@huaweicloud.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--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®