Skip to content

Commit 6667439

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Include offline CPUs when tasks' cpumasks in top_cpuset are updated
Similar to commit 3fb906e ("group/cpuset: Don't filter offline CPUs in cpuset_cpus_allowed() for top cpuset tasks"), the whole set of possible CPUs including offline ones should be used for setting cpumasks for tasks in the top cpuset when a cpuset partition is modified as the hotplug code won't update cpumasks for tasks in the top cpuset when CPUs become online or offline. Signed-off-by: Waiman Long <longman@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent df59b72 commit 6667439

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

kernel/cgroup/cpuset.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,9 @@ void rebuild_sched_domains(void)
12091209
*
12101210
* Iterate through each task of @cs updating its cpus_allowed to the
12111211
* effective cpuset's. As this function is called with cpuset_rwsem held,
1212-
* cpuset membership stays stable.
1212+
* cpuset membership stays stable. For top_cpuset, task_cpu_possible_mask()
1213+
* is used instead of effective_cpus to make sure all offline CPUs are also
1214+
* included as hotplug code won't update cpumasks for tasks in top_cpuset.
12131215
*/
12141216
static void update_tasks_cpumask(struct cpuset *cs, struct cpumask *new_cpus)
12151217
{
@@ -1219,15 +1221,18 @@ static void update_tasks_cpumask(struct cpuset *cs, struct cpumask *new_cpus)
12191221

12201222
css_task_iter_start(&cs->css, 0, &it);
12211223
while ((task = css_task_iter_next(&it))) {
1222-
/*
1223-
* Percpu kthreads in top_cpuset are ignored
1224-
*/
1225-
if (top_cs && (task->flags & PF_KTHREAD) &&
1226-
kthread_is_per_cpu(task))
1227-
continue;
1224+
const struct cpumask *possible_mask = task_cpu_possible_mask(task);
12281225

1229-
cpumask_and(new_cpus, cs->effective_cpus,
1230-
task_cpu_possible_mask(task));
1226+
if (top_cs) {
1227+
/*
1228+
* Percpu kthreads in top_cpuset are ignored
1229+
*/
1230+
if ((task->flags & PF_KTHREAD) && kthread_is_per_cpu(task))
1231+
continue;
1232+
cpumask_andnot(new_cpus, possible_mask, cs->subparts_cpus);
1233+
} else {
1234+
cpumask_and(new_cpus, possible_mask, cs->effective_cpus);
1235+
}
12311236
set_cpus_allowed_ptr(task, new_cpus);
12321237
}
12331238
css_task_iter_end(&it);

0 commit comments

Comments
 (0)