From: Ming Liu <ming.liu@windriver.com>
To: akpm@linux-foundation.org, rientjes@google.com, mhocko@suse.cz,
rusty@rustcorp.com.au, hannes@cmpxchg.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH] oom: avoid killing init if it assume the oom killed thread's mm
Date: Mon, 23 Sep 2013 17:45:28 +0800 [thread overview]
Message-ID: <1379929528-19179-1-git-send-email-ming.liu@windriver.com> (raw)
After selecting a task to kill, the oom killer iterates all processes and
kills all other user threads that share the same mm_struct in different
thread groups.
But in some extreme cases, the selected task happens to be a vfork child
of init process sharing the same mm_struct with it, which causes kernel
panic on init getting killed. This panic is observed in a busybox shell
that busybox itself is init, with a kthread keeps consuming memories.
Signed-off-by: Ming Liu <ming.liu@windriver.com>
---
mm/oom_kill.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 314e9d2..7db4881 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -479,17 +479,17 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
task_unlock(victim);
/*
- * Kill all user processes sharing victim->mm in other thread groups, if
- * any. They don't get access to memory reserves, though, to avoid
- * depletion of all memory. This prevents mm->mmap_sem livelock when an
- * oom killed thread cannot exit because it requires the semaphore and
- * its contended by another thread trying to allocate memory itself.
- * That thread will now get access to memory reserves since it has a
- * pending fatal signal.
+ * Kill all user processes except init sharing victim->mm in other
+ * thread groups, if any. They don't get access to memory reserves,
+ * though, to avoid depletion of all memory. This prevents mm->mmap_sem
+ * livelock when an oom killed thread cannot exit because it requires
+ * the semaphore and its contended by another thread trying to allocate
+ * memory itself. That thread will now get access to memory reserves
+ * since it has a pending fatal signal.
*/
for_each_process(p)
if (p->mm == mm && !same_thread_group(p, victim) &&
- !(p->flags & PF_KTHREAD)) {
+ !(p->flags & PF_KTHREAD) && !is_global_init(p)) {
if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
continue;
--
1.7.0.4
--
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>
next reply other threads:[~2013-09-23 9:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-23 9:45 Ming Liu [this message]
2013-09-25 2:34 ` [PATCH] oom: avoid killing init if it assume the oom killed thread's mm David Rientjes
2013-09-25 5:49 ` Ming Liu
2013-09-25 17:56 ` David Rientjes
2013-09-26 1:38 ` Ming Liu
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=1379929528-19179-1-git-send-email-ming.liu@windriver.com \
--to=ming.liu@windriver.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--cc=rientjes@google.com \
--cc=rusty@rustcorp.com.au \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).