]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
memcg: mm_update_next_owner() should skip kthreads
authorOleg Nesterov <oleg@redhat.com>
Wed, 4 Jun 2014 23:07:52 +0000 (16:07 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 4 Jun 2014 23:54:03 +0000 (16:54 -0700)
"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: 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>
kernel/exit.c

index da1b838de8a65844f0b2b0bde91a0361e76809d3..5ac3c19c245c855cb195c20843c76bdef4e74014 100644 (file)
@@ -395,14 +395,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