[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251025064844.495525-3-chenridong@huaweicloud.com>
Date: Sat, 25 Oct 2025 06:48:24 +0000
From: Chen Ridong <chenridong@...weicloud.com>
To: longman@...hat.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: [PATCH RFC v2 02/22] cpuset: add early empty cpumask check in partition_xcpus_add/del
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;
--
2.34.1
Powered by blists - more mailing lists