Skip to content

Commit 54dbb83

Browse files
lizf-osgregkh
authored andcommitted
cpuset: fix a locking issue in cpuset_migrate_mm()
commit 4729583 upstream. I can trigger a lockdep warning: # mount -t cgroup -o cpuset xxx /cgroup # mkdir /cgroup/cpuset # mkdir /cgroup/tmp # echo 0 > /cgroup/tmp/cpuset.cpus # echo 0 > /cgroup/tmp/cpuset.mems # echo 1 > /cgroup/tmp/cpuset.memory_migrate # echo $$ > /cgroup/tmp/tasks # echo 1 > /cgruop/tmp/cpuset.mems =============================== [ INFO: suspicious RCU usage. ] 3.14.0-rc1-0.1-default+ #32 Not tainted ------------------------------- include/linux/cgroup.h:682 suspicious rcu_dereference_check() usage! ... [<ffffffff81582174>] dump_stack+0x72/0x86 [<ffffffff810b8f01>] lockdep_rcu_suspicious+0x101/0x140 [<ffffffff81105ba1>] cpuset_migrate_mm+0xb1/0xe0 ... We used to hold cgroup_mutex when calling cpuset_migrate_mm(), but now we hold cpuset_mutex, which causes task_css() to complain. This is not a false-positive but a real issue. Holding cpuset_mutex won't prevent a task from migrating to another cpuset, and it won't prevent the original task->cgroup from destroying during this change. Fixes: 5d21cc2 (cpuset: replace cgroup_mutex locking with cpuset internal locking) Signed-off-by: Li Zefan <[email protected]> Sigend-off-by: Tejun Heo <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 23e7b2a commit 54dbb83

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

kernel/cpuset.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -974,12 +974,6 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
974974
* Temporarilly set tasks mems_allowed to target nodes of migration,
975975
* so that the migration code can allocate pages on these nodes.
976976
*
977-
* Call holding cpuset_mutex, so current's cpuset won't change
978-
* during this call, as manage_mutex holds off any cpuset_attach()
979-
* calls. Therefore we don't need to take task_lock around the
980-
* call to guarantee_online_mems(), as we know no one is changing
981-
* our task's cpuset.
982-
*
983977
* While the mm_struct we are migrating is typically from some
984978
* other task, the task_struct mems_allowed that we are hacking
985979
* is for our current task, which must allocate new pages for that
@@ -996,8 +990,10 @@ static void cpuset_migrate_mm(struct mm_struct *mm, const nodemask_t *from,
996990

997991
do_migrate_pages(mm, from, to, MPOL_MF_MOVE_ALL);
998992

993+
rcu_read_lock();
999994
mems_cs = effective_nodemask_cpuset(task_cs(tsk));
1000995
guarantee_online_mems(mems_cs, &tsk->mems_allowed);
996+
rcu_read_unlock();
1001997
}
1002998

1003999
/*

0 commit comments

Comments
 (0)