diff options
author | Oleg Nesterov <oleg@redhat.com> | 2014-06-04 19:07:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-04 19:54:03 -0400 |
commit | 39af1765f1255b2bbadc3064e16270781abf24a1 (patch) | |
tree | 55d8a858a7ab136314a397bebbd5bd72f0b0ee2b /kernel/exit.c | |
parent | f87fb599ae4d2a152a93f9821b94f3158146d097 (diff) |
memcg: optimize the "Search everything else" loop in mm_update_next_owner()
for_each_process_thread() is sub-optimal. All threads share the same
->mm, we can swicth to the next process once we found a thread with
->mm != NULL and ->mm != mm.
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/exit.c')
-rw-r--r-- | kernel/exit.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 5ac3c19c245c..750c2e594617 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -397,9 +397,15 @@ retry: | |||
397 | /* | 397 | /* |
398 | * Search through everything else, we should not get here often. | 398 | * Search through everything else, we should not get here often. |
399 | */ | 399 | */ |
400 | for_each_process_thread(g, c) { | 400 | for_each_process(g) { |
401 | if (!(c->flags & PF_KTHREAD) && c->mm == mm) | 401 | if (g->flags & PF_KTHREAD) |
402 | goto assign_new_owner; | 402 | continue; |
403 | for_each_thread(g, c) { | ||
404 | if (c->mm == mm) | ||
405 | goto assign_new_owner; | ||
406 | if (c->mm) | ||
407 | break; | ||
408 | } | ||
403 | } | 409 | } |
404 | read_unlock(&tasklist_lock); | 410 | read_unlock(&tasklist_lock); |
405 | /* | 411 | /* |