From: David Rientjes Date: Tue, 31 Jul 2012 23:42:37 +0000 (-0700) Subject: mm, oom: do not schedule if current has been killed X-Git-Tag: firefly_0821_release~3680^2~2280^2~89 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=4f774b912dd1d5752cd33b696509531b0321c3e0;p=firefly-linux-kernel-4.4.55.git 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 Cc: Oleg Nesterov Acked-by: KOSAKI Motohiro Acked-by: KAMEZAWA Hiroyuki Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- 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: read_unlock(&tasklist_lock); /* - * Give "p" a good chance of killing itself before we - * retry to allocate memory unless "p" is current + * Give the killed threads a good chance of exiting before trying to + * allocate memory again. */ - if (killed && !test_thread_flag(TIF_MEMDIE)) - schedule_timeout_uninterruptible(1); + if (killed) + schedule_timeout_killable(1); } /* @@ -764,6 +764,5 @@ void pagefault_out_of_memory(void) out_of_memory(NULL, 0, 0, NULL, false); clear_system_oom(); } - if (!test_thread_flag(TIF_MEMDIE)) - schedule_timeout_uninterruptible(1); + schedule_timeout_killable(1); }