More informative logging for OOM-killer
PATCH 1/1 More informative logging for OOM-killer
Hi,
On a number of occasions I encountered machines which suffered from occasional OOM's, but tracking down what caused them was tricky because the OOM-killer only reported the process name of the process it killed, and this would be something non-conclusive like 'java' or 'python'.
I figured it'd be useful to report not only the process name, but also the parameters/commandline it had been started with.
The (text/plain) attached patch is a first shot at this. I'm not much of a kernel hacker, so this is probably not quite commit-worthy material yet - but I'm prepared to make changes if you guys can point me into the right direction here, and I won't feel insulted if someone else takes this over.
Let me know,
Arnout
Documentation/sysctl/vm.txt +10 -0
@@ -31,6 +31,7 @@ - min_unmapped_ratio - min_slab_ratio - panic_on_oom +- informative_oom ==============================================================
@@ -205,3 +206,12 @@ The default value is 0. +============================================================= + +informative_oom + +This enables printing the commandline of processes killed by oom_killer. This +will do an allocation at a point where the system is already low on memory, +but for most systems the improved diagnostics will be worth it. + +The default value is 1.
include/linux/sysctl.h +1 -0
@@ -202,6 +202,7 @@VM_PANIC_ON_OOM =33 ,/* panic at out-of-memory */ VM_VDSO_ENABLED =34 ,/* map VDSO into new processes? */ VM_MIN_SLAB =35 ,/* Percent pages ignored by zone reclaim */ + VM_INFORMATIVE_OOM=36, /* show commandline of oom_killed process */ };
kernel/sysctl.c +9 -0
@@ -64,6 +64,7 @@extern int sysctl_overcommit_memory;extern int sysctl_overcommit_ratio;extern int sysctl_panic_on_oom; +extern int sysctl_informative_oom;extern int max_threads;extern int core_uses_pid;extern int suid_dumpable;
@@ -808,6 +809,14 @@ .proc_handler = &proc_dointvec, }, { + .ctl_name = VM_INFORMATIVE_OOM, + .procname = "informative_oom", + .data = &sysctl_informative_oom, + .maxlen = sizeof(sysctl_informative_oom), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { .ctl_name = VM_OVERCOMMIT_RATIO, .procname = "overcommit_ratio", .data = &sysctl_overcommit_ratio,
mm/oom_kill.c +54 -0
73 lines not on this page · raw message
mm/oom_kill.c line 339
Quoted 3 lines · On Thursday 14 June 2007 23:23:22 Arnout Engelen wrote:
mm/oom_kill.c +3
-0+// TODO is this a proper upper bound for the +// length of a commandline? +char buffer[PAGE_SIZE /sizeof (char )];
That's a 100% guaranteed stack overflow with 4K stacks.
And sizeof(char) is always 1 btw.
-Andi
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>