svn commit: r277651 - head/sys/vm
Will Andrews
will at FreeBSD.org
Sat Jan 24 17:32:46 UTC 2015
Author: will
Date: Sat Jan 24 17:32:45 2015
New Revision: 277651
URL: https://svnweb.freebsd.org/changeset/base/277651
Log:
Add vm.panic_on_oom sysctl, which enables those who would rather panic than
kill a process, when the system runs out of memory. Defaults to off.
Usually, this is most useful when the OOM condition is due to mismanagement
of memory, on a system where the applications in question don't respond well
to being killed.
In theory, if the system is properly managed, it shouldn't be possible to
hit this condition. If it does, the panic can be more desirable for some
users (since it can be a good means of finding the root cause) rather than
killing the largest process and continuing on its merry way.
As kib@ mentions in the differential, there is also protect(1), which uses
procctl(PROC_SPROTECT) to ensure that some processes are immune. However,
a panic approach is still useful in some environments. This is primarily
intended as a development/debugging tool.
Differential Revision: D1627
Reviewed by: kib
MFC after: 1 week
Modified:
head/sys/vm/vm_pageout.c
Modified: head/sys/vm/vm_pageout.c
==============================================================================
--- head/sys/vm/vm_pageout.c Sat Jan 24 17:11:11 2015 (r277650)
+++ head/sys/vm/vm_pageout.c Sat Jan 24 17:32:45 2015 (r277651)
@@ -180,6 +180,12 @@ static int vm_swap_enabled = 1;
static int vm_swap_idle_enabled = 0;
#endif
+static int vm_panic_on_oom = 0;
+
+SYSCTL_INT(_vm, OID_AUTO, panic_on_oom,
+ CTLFLAG_RWTUN, &vm_panic_on_oom, 0,
+ "panic on out of memory instead of killing the largest process");
+
SYSCTL_INT(_vm, OID_AUTO, pageout_wakeup_thresh,
CTLFLAG_RW, &vm_pageout_wakeup_thresh, 0,
"free page threshold for waking up the pageout daemon");
@@ -1585,6 +1591,8 @@ vm_pageout_oom(int shortage)
}
sx_sunlock(&allproc_lock);
if (bigproc != NULL) {
+ if (vm_panic_on_oom != 0)
+ panic("out of swap space");
PROC_LOCK(bigproc);
killproc(bigproc, "out of swap space");
sched_nice(bigproc, PRIO_MIN);
More information about the svn-src-head
mailing list