All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: akpm@linux-foundation.org, mhocko@suse.com
Cc: linux-mm@kvack.org,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	David Rientjes <rientjes@google.com>
Subject: [PATCH] mm,oom: Allow SysRq-f to always select !TIF_MEMDIE thread group.
Date: Sat, 28 May 2016 19:53:04 +0900	[thread overview]
Message-ID: <1464432784-6058-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> (raw)

There has been two problems about SysRq-f (manual invocation of the OOM
killer). One is that moom_callback() is not called by moom_work under OOM
livelock situation because it does not have a dedicated WQ like vmstat_wq.
The other is that select_bad_process() selects a thread group which
already has a TIF_MEMDIE thread because oom_scan_process_thread() was
scanning all threads of all thread groups and find_lock_task_mm() can
return a TIF_MEMDIE thread.

Since commit f44666b04605d1c7 ("mm,oom: speed up select_bad_process()
loop") changed oom_scan_process_group() to use task->signal->oom_victims,
the OOM killer will no longer select a thread group which already has a
TIF_MEMDIE thread. But SysRq-f will select such thread group due to
returning OOM_SCAN_OK.

Although we will change oom_badness() to return 0 after the OOM reaper
gave up reaping the OOM victim's mm, currently there is possibility that
the OOM reaper is not called (due to "the OOM victim's mm is shared by
unkillable threads" or "the OOM reaper thread is not available due to
kthread_run() failure or CONFIG_MMU=n"). Therefore, we need to make sure
that SysRq-f will skip oom_badness() if such thread group has a TIF_MEMDIE
thread.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Michal Hocko <mhocko@suse.com>
Cc: David Rientjes <rientjes@google.com>
---
 mm/oom_kill.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 1685890..c16331c 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -283,8 +283,8 @@ enum oom_scan_t oom_scan_process_thread(struct oom_control *oc,
 	 * This task already has access to memory reserves and is being killed.
 	 * Don't allow any other task to have access to the reserves.
 	 */
-	if (!is_sysrq_oom(oc) && atomic_read(&task->signal->oom_victims))
-		return OOM_SCAN_ABORT;
+	if (atomic_read(&task->signal->oom_victims))
+		return !is_sysrq_oom(oc) ? OOM_SCAN_ABORT : OOM_SCAN_CONTINUE;
 
 	/*
 	 * If task is allocating a lot of memory and has been marked to be
-- 
1.8.3.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2016-05-28 11:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-28 10:53 Tetsuo Handa [this message]
2016-05-28 16:25 ` [PATCH v2] mm,oom: Allow SysRq-f to always select !TIF_MEMDIE thread group Tetsuo Handa
2016-05-31 13:11   ` Michal Hocko
2016-05-31 21:35     ` Tetsuo Handa
2016-06-01  7:34       ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464432784-6058-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.