From: Sergey Dyasly <dserrg@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
David Rientjes <rientjes@google.com>,
Michal Hocko <mhocko@suse.cz>,
Rusty Russell <rusty@rustcorp.com.au>,
Sha Zhengju <handai.szj@taobao.com>,
Oleg Nesterov <oleg@redhat.com>, Sergey Dyasly <dserrg@gmail.com>
Subject: [PATCH] OOM killer: wait for tasks with pending SIGKILL to exit
Date: Mon, 9 Sep 2013 19:30:24 +0400 [thread overview]
Message-ID: <1378740624-2456-1-git-send-email-dserrg@gmail.com> (raw)
If OOM killer finds a task which is about to exit or is already doing so,
there is no need to kill anyone. It should just wait until task dies.
Add missing fatal_signal_pending() check and allow selected task to use memory
reserves in order to exit quickly.
Also remove redundant PF_EXITING check after victim has been selected.
Signed-off-by: Sergey Dyasly <dserrg@gmail.com>
---
mm/oom_kill.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 98e75f2..ef83b81 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -275,13 +275,16 @@ enum oom_scan_t oom_scan_process_thread(struct task_struct *task,
if (oom_task_origin(task))
return OOM_SCAN_SELECT;
- if (task->flags & PF_EXITING && !force_kill) {
+ if ((task->flags & PF_EXITING || fatal_signal_pending(task)) &&
+ !force_kill) {
/*
* If this task is not being ptraced on exit, then wait for it
* to finish before killing some other task unnecessarily.
*/
- if (!(task->group_leader->ptrace & PT_TRACE_EXIT))
+ if (!(task->group_leader->ptrace & PT_TRACE_EXIT)) {
+ set_tsk_thread_flag(task, TIF_MEMDIE);
return OOM_SCAN_ABORT;
+ }
}
return OOM_SCAN_OK;
}
@@ -412,16 +415,6 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL,
DEFAULT_RATELIMIT_BURST);
- /*
- * If the task is already exiting, don't alarm the sysadmin or kill
- * its children or threads, just set TIF_MEMDIE so it can die quickly
- */
- if (p->flags & PF_EXITING) {
- set_tsk_thread_flag(p, TIF_MEMDIE);
- put_task_struct(p);
- return;
- }
-
if (__ratelimit(&oom_rs))
dump_header(p, gfp_mask, order, memcg, nodemask);
--
1.8.1.2
--
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>
WARNING: multiple messages have this Message-ID (diff)
From: Sergey Dyasly <dserrg@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
David Rientjes <rientjes@google.com>,
Michal Hocko <mhocko@suse.cz>,
Rusty Russell <rusty@rustcorp.com.au>,
Sha Zhengju <handai.szj@taobao.com>,
Oleg Nesterov <oleg@redhat.com>, Sergey Dyasly <dserrg@gmail.com>
Subject: [PATCH] OOM killer: wait for tasks with pending SIGKILL to exit
Date: Mon, 9 Sep 2013 19:30:24 +0400 [thread overview]
Message-ID: <1378740624-2456-1-git-send-email-dserrg@gmail.com> (raw)
If OOM killer finds a task which is about to exit or is already doing so,
there is no need to kill anyone. It should just wait until task dies.
Add missing fatal_signal_pending() check and allow selected task to use memory
reserves in order to exit quickly.
Also remove redundant PF_EXITING check after victim has been selected.
Signed-off-by: Sergey Dyasly <dserrg@gmail.com>
---
mm/oom_kill.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 98e75f2..ef83b81 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -275,13 +275,16 @@ enum oom_scan_t oom_scan_process_thread(struct task_struct *task,
if (oom_task_origin(task))
return OOM_SCAN_SELECT;
- if (task->flags & PF_EXITING && !force_kill) {
+ if ((task->flags & PF_EXITING || fatal_signal_pending(task)) &&
+ !force_kill) {
/*
* If this task is not being ptraced on exit, then wait for it
* to finish before killing some other task unnecessarily.
*/
- if (!(task->group_leader->ptrace & PT_TRACE_EXIT))
+ if (!(task->group_leader->ptrace & PT_TRACE_EXIT)) {
+ set_tsk_thread_flag(task, TIF_MEMDIE);
return OOM_SCAN_ABORT;
+ }
}
return OOM_SCAN_OK;
}
@@ -412,16 +415,6 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL,
DEFAULT_RATELIMIT_BURST);
- /*
- * If the task is already exiting, don't alarm the sysadmin or kill
- * its children or threads, just set TIF_MEMDIE so it can die quickly
- */
- if (p->flags & PF_EXITING) {
- set_tsk_thread_flag(p, TIF_MEMDIE);
- put_task_struct(p);
- return;
- }
-
if (__ratelimit(&oom_rs))
dump_header(p, gfp_mask, order, memcg, nodemask);
--
1.8.1.2
next reply other threads:[~2013-09-09 15:31 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-09 15:30 Sergey Dyasly [this message]
2013-09-09 15:30 ` [PATCH] OOM killer: wait for tasks with pending SIGKILL to exit Sergey Dyasly
2013-09-09 16:31 ` Oleg Nesterov
2013-09-09 16:31 ` Oleg Nesterov
2013-09-09 20:11 ` David Rientjes
2013-09-09 20:11 ` David Rientjes
2013-09-09 20:07 ` David Rientjes
2013-09-09 20:07 ` David Rientjes
2013-09-11 15:06 ` Sergey Dyasly
2013-09-11 15:06 ` Sergey Dyasly
2013-09-19 15:51 ` Sergey Dyasly
2013-09-19 15:51 ` Sergey Dyasly
2013-09-25 20:31 ` David Rientjes
2013-09-25 20:31 ` David Rientjes
2013-09-27 14:58 ` Sergey Dyasly
2013-09-27 14:58 ` Sergey Dyasly
2013-09-30 22:08 ` David Rientjes
2013-09-30 22:08 ` David Rientjes
2013-10-01 15:26 ` Sergey Dyasly
2013-10-01 15:26 ` Sergey Dyasly
2013-10-01 22:46 ` David Rientjes
2013-10-01 22:46 ` David Rientjes
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=1378740624-2456-1-git-send-email-dserrg@gmail.com \
--to=dserrg@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=handai.szj@taobao.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--cc=oleg@redhat.com \
--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 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.