aboutsummaryrefslogtreecommitdiffstats
path: root/mm/oom_kill.c
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2012-07-31 19:42:37 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-31 21:42:41 -0400
commit4f774b912dd1d5752cd33b696509531b0321c3e0 (patch)
tree12d30b642d655c3cf75893f9619afe815c0a7932 /mm/oom_kill.c
parent75754681fe79b84dde1048470a44eeb64192fad6 (diff)
mm, oom: do not schedule if current has been killed
The oom killer currently schedules away from current in an uninterruptible sleep if it does not have access to memory reserves. It's possible that current was killed because it shares memory with the oom killed thread or because it was killed by the user in the interim, however. This patch only schedules away from current if it does not have a pending kill, i.e. if it does not share memory with the oom killed thread. It's possible that it will immediately retry its memory allocation and fail, but it will immediately be given access to memory reserves if it calls the oom killer again. This prevents the delay of memory freeing when threads that share memory with the oom killed thread get unnecessarily scheduled. Signed-off-by: David Rientjes <rientjes@google.com> Cc: Oleg Nesterov <oleg@redhat.com> Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/oom_kill.c')
-rw-r--r--mm/oom_kill.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index ac300c99baf6..e8ab3dfbc74b 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -745,11 +745,11 @@ out:
745 read_unlock(&tasklist_lock); 745 read_unlock(&tasklist_lock);
746 746
747 /* 747 /*
748 * Give "p" a good chance of killing itself before we 748 * Give the killed threads a good chance of exiting before trying to
749 * retry to allocate memory unless "p" is current 749 * allocate memory again.
750 */ 750 */
751 if (killed && !test_thread_flag(TIF_MEMDIE)) 751 if (killed)
752 schedule_timeout_uninterruptible(1); 752 schedule_timeout_killable(1);
753} 753}
754 754
755/* 755/*
@@ -764,6 +764,5 @@ void pagefault_out_of_memory(void)
764 out_of_memory(NULL, 0, 0, NULL, false); 764 out_of_memory(NULL, 0, 0, NULL, false);
765 clear_system_oom(); 765 clear_system_oom();
766 } 766 }
767 if (!test_thread_flag(TIF_MEMDIE)) 767 schedule_timeout_killable(1);
768 schedule_timeout_uninterruptible(1);
769} 768}