* [PATCH] cgroup/cpuset: Extend kthread_is_per_cpu() check to all PF_NO_SETAFFINITY tasks
@ 2025-05-07 18:30 Waiman Long
2025-05-07 18:41 ` Michal Koutný
0 siblings, 1 reply; 2+ messages in thread
From: Waiman Long @ 2025-05-07 18:30 UTC (permalink / raw)
To: Tejun Heo, Johannes Weiner, Michal Koutný
Cc: cgroups, linux-kernel, Waiman Long
Commit ec5fbdfb99d1 ("cgroup/cpuset: Enable update_tasks_cpumask()
on top_cpuset") enabled us to pull CPUs dedicated to child partitions
from tasks in top_cpuset by ignoring per cpu kthreads. However, there
can be other kthreads that are not per cpu but have PF_NO_SETAFFINITY
flag set to indicate that we shouldn't mess with their CPU affinity.
As all the per cpu kthreads have PF_NO_SETAFFINITY set, fix this
issue by dropping the kthread_is_per_cpu() check and checking the
PF_NO_SETAFFINITY flag instead.
Fixes: ec5fbdfb99d1 ("cgroup/cpuset: Enable update_tasks_cpumask() on top_cpuset")
Signed-off-by: Waiman Long <longman@redhat.com>
---
kernel/cgroup/cpuset.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index d0143b3dce47..581032d73e4b 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1130,9 +1130,9 @@ void cpuset_update_tasks_cpumask(struct cpuset *cs, struct cpumask *new_cpus)
if (top_cs) {
/*
- * Percpu kthreads in top_cpuset are ignored
+ * PF_NO_SETAFFINITY tasks are ignored
*/
- if (kthread_is_per_cpu(task))
+ if (task->flags & PF_NO_SETAFFINITY)
continue;
cpumask_andnot(new_cpus, possible_mask, subpartitions_cpus);
} else {
--
2.49.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cgroup/cpuset: Extend kthread_is_per_cpu() check to all PF_NO_SETAFFINITY tasks
2025-05-07 18:30 [PATCH] cgroup/cpuset: Extend kthread_is_per_cpu() check to all PF_NO_SETAFFINITY tasks Waiman Long
@ 2025-05-07 18:41 ` Michal Koutný
0 siblings, 0 replies; 2+ messages in thread
From: Michal Koutný @ 2025-05-07 18:41 UTC (permalink / raw)
To: Waiman Long; +Cc: Tejun Heo, Johannes Weiner, cgroups, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 955 bytes --]
Hello.
On Wed, May 07, 2025 at 02:30:11PM -0400, Waiman Long <longman@redhat.com> wrote:
> Commit ec5fbdfb99d1 ("cgroup/cpuset: Enable update_tasks_cpumask()
> on top_cpuset") enabled us to pull CPUs dedicated to child partitions
> from tasks in top_cpuset by ignoring per cpu kthreads. However, there
> can be other kthreads that are not per cpu but have PF_NO_SETAFFINITY
> flag set to indicate that we shouldn't mess with their CPU affinity.
>
> As all the per cpu kthreads have PF_NO_SETAFFINITY set, fix this
> issue by dropping the kthread_is_per_cpu() check and checking the
> PF_NO_SETAFFINITY flag instead.
I think there's a reason for existence of kthread_is_per_cpu(), so I'd
stick with more robust
- if (kthread_is_per_cpu(task))
+ if (kthread_is_per_cpu(task) || task->flags & PF_NO_SETAFFINITY)
Perhaps with a comment that illuminates the kthread_is_per_cpu vs
PF_NO_SETAFFINITY difference.
0.02€,
Michal
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-07 18:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07 18:30 [PATCH] cgroup/cpuset: Extend kthread_is_per_cpu() check to all PF_NO_SETAFFINITY tasks Waiman Long
2025-05-07 18:41 ` Michal Koutný
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox