Skip to content

Commit ec5fbdf

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Enable update_tasks_cpumask() on top_cpuset
Previously, update_tasks_cpumask() is not supposed to be called with top cpuset. With cpuset partition that takes CPUs away from the top cpuset, adjusting the cpus_mask of the tasks in the top cpuset is necessary. Percpu kthreads, however, are ignored. Fixes: ee8dde0 ("cpuset: Add new v2 cpuset.sched.partition flag") Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 5251c6c commit ec5fbdf

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

kernel/cgroup/cpuset.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/interrupt.h>
3434
#include <linux/kernel.h>
3535
#include <linux/kmod.h>
36+
#include <linux/kthread.h>
3637
#include <linux/list.h>
3738
#include <linux/mempolicy.h>
3839
#include <linux/mm.h>
@@ -1127,10 +1128,18 @@ static void update_tasks_cpumask(struct cpuset *cs)
11271128
{
11281129
struct css_task_iter it;
11291130
struct task_struct *task;
1131+
bool top_cs = cs == &top_cpuset;
11301132

11311133
css_task_iter_start(&cs->css, 0, &it);
1132-
while ((task = css_task_iter_next(&it)))
1134+
while ((task = css_task_iter_next(&it))) {
1135+
/*
1136+
* Percpu kthreads in top_cpuset are ignored
1137+
*/
1138+
if (top_cs && (task->flags & PF_KTHREAD) &&
1139+
kthread_is_per_cpu(task))
1140+
continue;
11331141
set_cpus_allowed_ptr(task, cs->effective_cpus);
1142+
}
11341143
css_task_iter_end(&it);
11351144
}
11361145

@@ -2092,12 +2101,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
20922101
update_flag(CS_CPU_EXCLUSIVE, cs, 0);
20932102
}
20942103

2095-
/*
2096-
* Update cpumask of parent's tasks except when it is the top
2097-
* cpuset as some system daemons cannot be mapped to other CPUs.
2098-
*/
2099-
if (parent != &top_cpuset)
2100-
update_tasks_cpumask(parent);
2104+
update_tasks_cpumask(parent);
21012105

21022106
if (parent->child_ecpus_count)
21032107
update_sibling_cpumasks(parent, cs, &tmpmask);

0 commit comments

Comments
 (0)