[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3c449d75-2a44-4acc-b3f6-0b2c261db1bd@redhat.com>
Date: Wed, 12 Nov 2025 15:18:16 -0500
From: Waiman Long <llong@...hat.com>
To: Chen Ridong <chenridong@...weicloud.com>, tj@...nel.org,
hannes@...xchg.org, mkoutny@...e.com
Cc: cgroups@...r.kernel.org, linux-kernel@...r.kernel.org,
lujialin4@...wei.com, chenridong@...wei.com
Subject: Re: [PATCH RFC v2 02/22] cpuset: add early empty cpumask check in
partition_xcpus_add/del
On 10/25/25 2:48 AM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@...wei.com>
>
> Add a check for an empty cpumask at the start of partition_xcpus_add()
> and partition_xcpus_del(). This allows the functions to return early,
> avoiding unnecessary computation when there is no work to be done.
>
> Signed-off-by: Chen Ridong <chenridong@...wei.com>
> ---
> kernel/cgroup/cpuset.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 6af4d80b53c4..3ba9ca4e8f5e 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -1345,6 +1345,9 @@ static bool partition_xcpus_add(int new_prs, struct cpuset *parent,
>
> WARN_ON_ONCE(new_prs < 0);
> lockdep_assert_held(&callback_lock);
> + if (cpumask_empty(xcpus))
> + return false;
> +
> if (!parent)
> parent = &top_cpuset;
>
> @@ -1377,6 +1380,9 @@ static bool partition_xcpus_del(int old_prs, struct cpuset *parent,
>
> WARN_ON_ONCE(old_prs < 0);
> lockdep_assert_held(&callback_lock);
> + if (cpumask_empty(xcpus))
> + return false;
> +
> if (!parent)
> parent = &top_cpuset;
>
partition_xcpus_add() and partition_xcpus_del() are supposed to be
called only when action is really needed. The empty xcpus check should
be done earlier to avoid calling them in the firstĀ place. So unless you
are planning to change the logic that they will always be called even if
action is not really needed. If so, you have to state in the commit log.
Cheers,
Longman
Powered by blists - more mailing lists