aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2016-03-17 14:20:45 -0700
committerMoyster <oysterized@gmail.com>2019-07-08 14:08:56 +0200
commite42592f4fa5a643b81e6163243adf70fe45bd645 (patch)
tree9ccb1d28f715761d3ae99709e7b1db4bfff4d845
parent51b11d9d1b816c8b6fd0a3195b07c287b06d9d31 (diff)
mm,oom: make oom_killer_disable() killable
While oom_killer_disable() is called by freeze_processes() after all user threads except the current thread are frozen, it is possible that kernel threads invoke the OOM killer and sends SIGKILL to the current thread due to sharing the thawed victim's memory. Therefore, checking for SIGKILL is preferable than TIF_MEMDIE. Change-Id: I0ff3858a7ed4a808b8b21bd3382847d3150735e3 Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: David Rientjes <rientjes@google.com> Cc: Michal Hocko <mhocko@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/oom_kill.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 50e1a3f00..a2c010a40 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -471,15 +471,11 @@ void exit_oom_victim(void)
bool oom_killer_disable(void)
{
/*
- * Make sure to not race with an ongoing OOM killer
- * and that the current is not the victim.
+ * Make sure to not race with an ongoing OOM killer. Check that the
+ * current is not killed (possibly due to sharing the victim's memory).
*/
- mutex_lock(&oom_lock);
- if (test_thread_flag(TIF_MEMDIE)) {
- mutex_unlock(&oom_lock);
+ if (mutex_lock_killable(&oom_lock))
return false;
- }
-
oom_killer_disabled = true;
mutex_unlock(&oom_lock);