From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: mhocko@suse.cz, hannes@cmpxchg.org, rientjes@google.com
Cc: linux-mm@kvack.org
Subject: What is oom_killer_disable() for?
Date: Sun, 10 Jan 2016 02:02:32 +0900 [thread overview]
Message-ID: <201601100202.DHE57897.OVLJOMHFOtFFSQ@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <1452337485-8273-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp>
I wonder what oom_killer_disable() wants to do.
(1) We need to save a consistent memory snapshot image when suspending,
is this correct?
(2) To obtain a consistent memory snapshot image, we need to freeze all
but current thread in order to avoid modifying on-memory data while
saving to disk, is this correct?
(3) Then, what is the purpose of disabling the OOM killer? Why do we
need to disable the OOM killer? Is it because the OOM killer thaws
already frozen threads?
(4) Then, why do we wait for TIF_MEMDIE threads to terminate? We can
freeze thawed threads again without waiting for TIF_MEMDIE threads,
can't we? Is it because we need free memory for saving to disk?
(5) Then, why waiting for only TIF_MEMDIE threads is sufficient? There
is no TIF_MEMDIE threads does not guarantee that we have free memory,
for there might be !TIF_MEMDIE threads which are still sharing memory
used by TIF_MEMDIE threads.
(6) Since oom_killer_disable() already disabled the OOM killer,
!TIF_MEMDIE threads which are sharing memory used by TIF_MEMDIE
threads cannot get TIF_MEMDIE by calling out_of_memory().
Also, since out_of_memory() returns false after oom_killer_disable()
disabled the OOM killer, allocation requests by these !TIF_MEMDIE
threads start failing. Why do we need to give up with accepting
undesirable errors (e.g. failure of syscalls which modify an object's
attribute)? Why don't we abort suspend operation by marking that
re-enabling of the OOM killer might caused modification of on-memory
data (like patch shown below)? We can make final decision after memory
image snapshot is saved to disk, can't we? We can reply users that
"suspend operation was cancelled due to out of memory" and ask users
to try again, instead of failing e.g. chmod() syscall and/or asking
users to check serial console for errors after the OOM killer was
disabled.
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index b7342a2..665a559 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -588,6 +588,8 @@ int hibernation_platform_enter(void)
return error;
}
+extern bool oom_killer_disable_aborted;
+
/**
* power_down - Shut the machine down for hibernation.
*
@@ -600,6 +602,10 @@ static void power_down(void)
#ifdef CONFIG_SUSPEND
int error;
#endif
+ if (oom_killer_disable_aborted) {
+ printk(KERN_ERR "PM: Suspend aborted due to out of memory\n");
+ return;
+ }
switch (hibernation_mode) {
case HIBERNATION_REBOOT:
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index bafa6b2..07ed44a 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -426,6 +426,7 @@ static atomic_t oom_victims = ATOMIC_INIT(0);
static DECLARE_WAIT_QUEUE_HEAD(oom_victims_wait);
bool oom_killer_disabled __read_mostly;
+bool oom_killer_disable_aborted __read_mostly;
#ifdef CONFIG_MMU
/*
@@ -618,6 +619,7 @@ bool oom_killer_disable(void)
if (mutex_lock_killable(&oom_lock))
return false;
oom_killer_disabled = true;
+ oom_killer_disable_aborted = false;
mutex_unlock(&oom_lock);
/* Do not wait forever in case existing victims got stuck. */
@@ -632,6 +634,7 @@ bool oom_killer_disable(void)
*/
void oom_killer_enable(void)
{
+ oom_killer_disable_aborted = false;
oom_killer_disabled = false;
}
@@ -840,8 +843,10 @@ bool out_of_memory(struct oom_control *oc)
unsigned int uninitialized_var(points);
enum oom_constraint constraint = CONSTRAINT_NONE;
- if (oom_killer_disabled)
- return false;
+ if (oom_killer_disabled) {
+ oom_killer_disable_aborted = true;
+ oom_killer_disabled = false;
+ }
blocking_notifier_call_chain(&oom_notify_list, 0, &freed);
if (freed > 0)
--
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 prev parent reply other threads:[~2016-01-09 17:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-09 11:04 [PATCH] mm,oom: make oom_killer_disable() killable Tetsuo Handa
2016-01-09 17:02 ` Tetsuo Handa [this message]
2016-01-11 14:49 ` What is oom_killer_disable() for? Michal Hocko
2016-01-12 10:17 ` Tetsuo Handa
2016-01-12 12:38 ` Rafael J. Wysocki
2016-01-12 12:17 ` Rafael J. Wysocki
2016-01-11 14:12 ` [PATCH] mm,oom: make oom_killer_disable() killable 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=201601100202.DHE57897.OVLJOMHFOtFFSQ@I-love.SAKURA.ne.jp \
--to=penguin-kernel@i-love.sakura.ne.jp \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox