From: Waiman Long <longman@redhat.com>
To: "Chen Ridong" <chenridong@huawei.com>,
"Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
Waiman Long <longman@redhat.com>
Subject: [PATCH v2 3/3] cgroup/cpuset: Improve check for v1 task migration out of empty cpuset
Date: Sun, 29 Mar 2026 13:39:58 -0400 [thread overview]
Message-ID: <20260329173958.2634925-4-longman@redhat.com> (raw)
In-Reply-To: <20260329173958.2634925-1-longman@redhat.com>
With the "cpuset_v2_mode" mount option, cpuset v1 will emulate v2 in
how it handles the management of CPUs. As a result, the effective_cpus
can differ from cpus_allowed and an empty cpus_allowed will cause
effective_cpus to inherit the value from its parent. Therefore task
migration out of a cpuset with empty "cpuset.cpus" should no longer
be needed in this case.
The current code doesn't handle this particular case. Update the code to
correctly detect that the cpuset has really no CPUs left by checking
effective_cpus instead of cpus_allowed.
Signed-off-by: Waiman Long <longman@redhat.com>
---
kernel/cgroup/cpuset-v1.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/kernel/cgroup/cpuset-v1.c b/kernel/cgroup/cpuset-v1.c
index 0c818edd0a1d..9855de37d011 100644
--- a/kernel/cgroup/cpuset-v1.c
+++ b/kernel/cgroup/cpuset-v1.c
@@ -261,7 +261,7 @@ static void remove_tasks_in_empty_cpuset(struct cpuset *cs)
* has online cpus, so can't be empty).
*/
parent = parent_cs(cs);
- while (cpumask_empty(parent->cpus_allowed) ||
+ while (cpumask_empty(parent->effective_cpus) ||
nodes_empty(parent->mems_allowed))
parent = parent_cs(parent);
@@ -297,14 +297,16 @@ void cpuset1_hotplug_update_tasks(struct cpuset *cs,
/*
* Don't call cpuset_update_tasks_cpumask() if the cpuset becomes empty,
- * as the tasks will be migrated to an ancestor.
+ * as the tasks will be migrated to an ancestor. If cpuset_v2_mode mount
+ * option is used, effective_cpus can differ from cpus_allowed. So
+ * checking effective_cpus is more accurate for determining emptiness.
*/
- if (cpus_updated && !cpumask_empty(cs->cpus_allowed))
+ if (cpus_updated && !cpumask_empty(cs->effective_cpus))
cpuset_update_tasks_cpumask(cs, new_cpus);
if (mems_updated && !nodes_empty(cs->mems_allowed))
cpuset_update_tasks_nodemask(cs);
- is_empty = cpumask_empty(cs->cpus_allowed) ||
+ is_empty = cpumask_empty(cs->effective_cpus) ||
nodes_empty(cs->mems_allowed);
/*
--
2.53.0
next prev parent reply other threads:[~2026-03-29 17:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-29 17:39 [PATCH v2 0/3] cgroup/cpuset: Fix v1 task migration failure from empty cpuset Waiman Long
2026-03-29 17:39 ` [PATCH v2 1/3] cgroup/cpuset: Simplify setsched decision check in task iteration loop of cpuset_can_attach() Waiman Long
2026-03-29 17:39 ` [PATCH v2 2/3] cgroup/cpuset: Skip security check for hotplug induced v1 task migration Waiman Long
2026-03-30 1:48 ` Chen Ridong
2026-03-30 16:15 ` Waiman Long
2026-03-30 18:21 ` Tejun Heo
2026-03-31 3:15 ` Waiman Long
2026-03-29 17:39 ` Waiman Long [this message]
2026-03-30 18:25 ` [PATCH v2 3/3] cgroup/cpuset: Improve check for v1 task migration out of empty cpuset Tejun Heo
2026-03-31 1:05 ` Waiman Long
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=20260329173958.2634925-4-longman@redhat.com \
--to=longman@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huawei.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--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