Commit 39af1765 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds
Browse files

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: default avatarOleg Nesterov <>
Reviewed-by: default avatarMichal Hocko <>
Cc: Balbir Singh <>
Cc: Johannes Weiner <>
Cc: KAMEZAWA Hiroyuki <>
Cc: Michal Hocko <>
Cc: Peter Chiang <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent f87fb599
......@@ -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)
for_each_thread(g, c) {
if (c->mm == mm)
goto assign_new_owner;
if (c->mm)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment