cgroup/cpuset: Extend kthread_is_per_cpu() check to all PF_NO_SETAFFINITY tasks
Subsystems (2)
Waiman Long
maintainerPATCH 1/1 cgroup/cpuset: Extend kthread_is_per_cpu() check to all PF_NO_SETAFFINITY tasks
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.
--- kernel/cgroup/cpuset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cgroup/cpuset.c +2 -2
@@ -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 {
Signature · 1 line
2.49.0
Michal Koutný
maintainerHello.
Quoted 9 lines · Waiman Long
Commit
ec5fbdfb99d1("cgroup/cpuset: Enableupdate_tasks_cpumask()ontop_cpuset") enabled us to pull CPUs dedicated to child partitions from tasks intop_cpusetby ignoring per cpu kthreads. However, there can be other kthreads that are not per cpu but havePF_NO_SETAFFINITYflag set to indicate that we shouldn't mess with their CPU affinity.As all the per cpu kthreads have
PF_NO_SETAFFINITYset, fix this issue by dropping thekthread_is_per_cpu()check and checking thePF_NO_SETAFFINITYflag 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