From: Michal Hocko <mhocko@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Rientjes <rientjes@google.com>,
Konstantin Khlebnikov <khlebnikov@openvz.org>,
Oleg Nesterov <oleg@redhat.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
Rusty Russell <rusty@rustcorp.com.au>,
Tejun Heo <htejun@gmail.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 2/2] oom: do not live lock on frozen tasks
Date: Tue, 27 Sep 2011 10:01:47 +0200 [thread overview]
Message-ID: <65d9dff7ff78fad1f146e71d32f9f92741281b46.1317110948.git.mhocko@suse.cz> (raw)
In-Reply-To: <cover.1317110948.git.mhocko@suse.cz>
Konstantin Khlebnikov has reported (https://lkml.org/lkml/2011/8/23/45)
that OOM can end up in a live lock if select_bad_process picks up a frozen
task.
Unfortunately we cannot mark such processes as unkillable to ignore them
because we could panic the system even though there is a chance that
somebody could thaw the process so we can make a forward process (e.g. a
process from another cpuset or with a different nodemask).
Let's thaw an OOM selected frozen process right after we've sent fatal
signal from oom_kill_task.
Thawing is safe if the frozen task doesn't access any suspended device
(e.g. by ioctl) on the way out to the userspace where we handle the
signal and die. Note, we are not interested in the kernel threads because
they are not oom killable.
Accessing suspended devices by a userspace processes shouldn't be an
issue because devices are suspended only after userspace is already
frozen and oom is disabled at that time.
Other than that userspace accesses the fridge only from the
signal handling routines so we are able to handle SIGKILL without any
negative side effects or we always check for pending signals after
we return from try_to_freeze (e.g. in lguest).
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Reported-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: David Rientjes <rientjes@google.com>
---
mm/oom_kill.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 626303b..c419a7e 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -32,6 +32,7 @@
#include <linux/mempolicy.h>
#include <linux/security.h>
#include <linux/ptrace.h>
+#include <linux/freezer.h>
int sysctl_panic_on_oom;
int sysctl_oom_kill_allocating_task;
@@ -451,10 +452,15 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem)
task_pid_nr(q), q->comm);
task_unlock(q);
force_sig(SIGKILL, q);
+
+ if (frozen(q))
+ thaw_process(q);
}
set_tsk_thread_flag(p, TIF_MEMDIE);
force_sig(SIGKILL, p);
+ if (frozen(p))
+ thaw_process(p);
return 0;
}
--
1.7.5.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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-09-27 18:10 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-27 8:09 [PATCH 0/2] oom: fix livelock when frozen task is selected Michal Hocko
2011-09-27 6:56 ` [PATCH 1/2] lguest: move process freezing before pending signals check Michal Hocko
2011-10-12 6:55 ` Michal Hocko
2011-10-12 23:57 ` Rusty Russell
2011-10-13 5:48 ` Michal Hocko
2011-09-27 8:01 ` Michal Hocko [this message]
2011-09-27 18:35 ` [patch] oom: thaw threads if oom killed thread is frozen before deferring David Rientjes
2011-09-28 10:44 ` Michal Hocko
2011-09-29 11:51 ` Michal Hocko
2011-09-29 12:05 ` Oleg Nesterov
2011-09-29 13:02 ` Michal Hocko
2011-09-29 16:32 ` Michal Hocko
2011-09-29 16:37 ` Oleg Nesterov
2011-09-29 18:00 ` Michal Hocko
2011-09-30 1:51 ` Tejun Heo
2011-09-30 7:41 ` Michal Hocko
2011-09-30 7:46 ` Tejun Heo
2011-09-30 8:04 ` Michal Hocko
2011-09-30 15:30 ` Oleg Nesterov
2011-10-28 22:23 ` [PATCH 2/2] oom: do not live lock on frozen tasks Andrew Morton
2011-10-29 9:01 ` 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=65d9dff7ff78fad1f146e71d32f9f92741281b46.1317110948.git.mhocko@suse.cz \
--to=mhocko@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=htejun@gmail.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=khlebnikov@openvz.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=oleg@redhat.com \
--cc=rientjes@google.com \
--cc=rjw@sisk.pl \
--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