* [PATCH] sysrq: Don't panic_on_oom if the user requested an OOM kill.
@ 2009-05-18 10:41 Geoffrey Thomas
2009-05-18 20:52 ` David Rientjes
0 siblings, 1 reply; 3+ messages in thread
From: Geoffrey Thomas @ 2009-05-18 10:41 UTC (permalink / raw
To: linux-kernel; +Cc: Geoffrey Thomas
If I specifically request an OOM kill via magic sysrq, I don't want
panic_on_oom to apply and crash the machine. I ran into this on a server
with panic_on_oom and automatic reboot after panic configured on the
assumption that nobody is likely physically present. If I'm able to use
magic sysrq, though, I can use that to reboot the machine slightly more
safely, if that's what I wanted.
This patch adds an extra parameter to out_of_memory to ignore the value
of sysctl_panic_on_oom, and just proceed with the OOM kill.
Signed-off-by: Geoffrey Thomas <geofft@mit.edu>
---
drivers/char/sysrq.c | 2 +-
include/linux/oom.h | 3 ++-
mm/oom_kill.c | 8 +++++---
mm/page_alloc.c | 2 +-
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index d6a807f..0233d5a 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -329,7 +329,7 @@ static struct sysrq_key_op sysrq_term_op = {
static void moom_callback(struct work_struct *ignored)
{
- out_of_memory(node_zonelist(0, GFP_KERNEL), GFP_KERNEL, 0);
+ out_of_memory(node_zonelist(0, GFP_KERNEL), GFP_KERNEL, 0, 1);
}
static DECLARE_WORK(moom_work, moom_callback);
diff --git a/include/linux/oom.h b/include/linux/oom.h
index a7979ba..b273c7c 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -26,7 +26,8 @@ enum oom_constraint {
extern int try_set_zone_oom(struct zonelist *zonelist, gfp_t gfp_flags);
extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
-extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order);
+extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
+ int order, int dontpanic);
extern int register_oom_notifier(struct notifier_block *nb);
extern int unregister_oom_notifier(struct notifier_block *nb);
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 92bcf1d..7bc4dcf 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -583,13 +583,15 @@ rest_and_return:
* @zonelist: zonelist pointer
* @gfp_mask: memory allocation flags
* @order: amount of memory being requested as a power of 2
+ * @dontpanic: whether to ignore panic_on_oom (used by magic-sysrq)
*
* If we run out of memory, we have the choice between either
* killing a random task (bad), letting the system crash (worse)
* OR try to be smart about which process to kill. Note that we
* don't have to be perfect here, we just have to be good.
*/
-void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
+void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
+ int order, int dontpanic)
{
unsigned long freed = 0;
enum oom_constraint constraint;
@@ -599,7 +601,7 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
/* Got some memory back in the last second. */
return;
- if (sysctl_panic_on_oom == 2)
+ if (!dontpanic && sysctl_panic_on_oom == 2)
panic("out of memory. Compulsory panic_on_oom is selected.\n");
/*
@@ -616,7 +618,7 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
break;
case CONSTRAINT_NONE:
- if (sysctl_panic_on_oom)
+ if (!dontpanic && sysctl_panic_on_oom)
panic("out of memory. panic_on_oom is selected\n");
/* Fall-through */
case CONSTRAINT_CPUSET:
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index fe753ec..b5f42d6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1625,7 +1625,7 @@ nofail_alloc:
goto nopage;
}
- out_of_memory(zonelist, gfp_mask, order);
+ out_of_memory(zonelist, gfp_mask, order, 0);
clear_zonelist_oom(zonelist, gfp_mask);
goto restart;
}
--
1.6.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sysrq: Don't panic_on_oom if the user requested an OOM kill.
2009-05-18 10:41 Geoffrey Thomas
@ 2009-05-18 20:52 ` David Rientjes
0 siblings, 0 replies; 3+ messages in thread
From: David Rientjes @ 2009-05-18 20:52 UTC (permalink / raw
To: Geoffrey Thomas; +Cc: linux-kernel
On Mon, 18 May 2009, Geoffrey Thomas wrote:
> If I specifically request an OOM kill via magic sysrq, I don't want
> panic_on_oom to apply and crash the machine. I ran into this on a server
> with panic_on_oom and automatic reboot after panic configured on the
> assumption that nobody is likely physically present. If I'm able to use
> magic sysrq, though, I can use that to reboot the machine slightly more
> safely, if that's what I wanted.
>
> This patch adds an extra parameter to out_of_memory to ignore the value
> of sysctl_panic_on_oom, and just proceed with the OOM kill.
>
> Signed-off-by: Geoffrey Thomas <geofft@mit.edu>
Nack, it's your own fault for asking for panic_on_oom and then not wanting
it to panic on oom.
Disable /proc/sys/vm/panic_on_oom before invoking the oom killer and then
reenable it afterwards.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sysrq: Don't panic_on_oom if the user requested an OOM kill.
[not found] ` <cDi6w-7CM-27@gated-at.bofh.it>
@ 2009-05-18 22:35 ` Bodo Eggert
0 siblings, 0 replies; 3+ messages in thread
From: Bodo Eggert @ 2009-05-18 22:35 UTC (permalink / raw
To: David Rientjes, Geoffrey Thomas, linux-kernel
David Rientjes <rientjes@google.com> wrote:
> On Mon, 18 May 2009, Geoffrey Thomas wrote:
>> If I specifically request an OOM kill via magic sysrq, I don't want
>> panic_on_oom to apply and crash the machine. I ran into this on a server
>> with panic_on_oom and automatic reboot after panic configured on the
>> assumption that nobody is likely physically present. If I'm able to use
>> magic sysrq, though, I can use that to reboot the machine slightly more
>> safely, if that's what I wanted.
>>
>> This patch adds an extra parameter to out_of_memory to ignore the value
>> of sysctl_panic_on_oom, and just proceed with the OOM kill.
>>
>> Signed-off-by: Geoffrey Thomas <geofft@mit.edu>
>
> Nack, it's your own fault for asking for panic_on_oom and then not wanting
> it to panic on oom.
>
> Disable /proc/sys/vm/panic_on_oom before invoking the oom killer and then
> reenable it afterwards.
Did you even think about the reasons for pressing sysrq-foo?
Like - e.g. - NOT BEING ABLE TO LOG IN?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-18 22:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cD8Tq-1IB-7@gated-at.bofh.it>
[not found] ` <cDi6w-7CM-27@gated-at.bofh.it>
2009-05-18 22:35 ` [PATCH] sysrq: Don't panic_on_oom if the user requested an OOM kill Bodo Eggert
2009-05-18 10:41 Geoffrey Thomas
2009-05-18 20:52 ` David Rientjes
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 read-only IMAP folder(s) and NNTP newsgroup(s).