提交 f87fb599 编写于 作者: O Oleg Nesterov 提交者: Linus Torvalds

memcg: mm_update_next_owner() should skip kthreads

"Search through everything else" in mm_update_next_owner() can hit a
kthread which adopted this "mm" via use_mm(), it should not be used as
mm->owner.  Add the PF_KTHREAD check.

While at it, change this code to use for_each_process_thread() instead
of deprecated do_each_thread/while_each_thread.
Signed-off-by: NOleg Nesterov <oleg@redhat.com>
Reviewed-by: NMichal Hocko <mhocko@suse.cz>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Peter Chiang <pchiang@nvidia.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 f7e2f7e8
......@@ -395,14 +395,12 @@ void mm_update_next_owner(struct mm_struct *mm)
}
/*
* Search through everything else. We should not get
* here often
* Search through everything else, we should not get here often.
*/
do_each_thread(g, c) {
if (c->mm == mm)
for_each_process_thread(g, c) {
if (!(c->flags & PF_KTHREAD) && c->mm == mm)
goto assign_new_owner;
} while_each_thread(g, c);
}
read_unlock(&tasklist_lock);
/*
* We found no owner yet mm_users > 1: this implies that we are
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册