aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2014-06-04 16:07:52 -0700
committerMoyster <oysterized@gmail.com>2019-05-02 18:04:38 +0200
commit6fb3b4a8d203a48a4ab88b99b6513e0ff37c52ac (patch)
tree4864e417e9c5a18a02facf408c7b281e89a16014 /kernel
parent408f2af16199a3a5dc233ce16afb7dacea3f675d (diff)
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. Change-Id: I1f3740bb5be19deb35bfeec0f958d5ed5ba3c7ed Signed-off-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: Michal 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/exit.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index fb5f11134..9146bbe17 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -411,14 +411,12 @@ retry:
}
/*
- * 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