mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 21:33:00 +00:00
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>
This commit is contained in:
parent
f87fb599ae
commit
39af1765f1
@ -397,9 +397,15 @@ retry:
|
||||
/*
|
||||
* Search through everything else, we should not get here often.
|
||||
*/
|
||||
for_each_process_thread(g, c) {
|
||||
if (!(c->flags & PF_KTHREAD) && c->mm == mm)
|
||||
goto assign_new_owner;
|
||||
for_each_process(g) {
|
||||
if (g->flags & PF_KTHREAD)
|
||||
continue;
|
||||
for_each_thread(g, c) {
|
||||
if (c->mm == mm)
|
||||
goto assign_new_owner;
|
||||
if (c->mm)
|
||||
break;
|
||||
}
|
||||
}
|
||||
read_unlock(&tasklist_lock);
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user