aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Andrews <will@FreeBSD.org>2015-01-24 17:32:45 +0000
committerWill Andrews <will@FreeBSD.org>2015-01-24 17:32:45 +0000
commit8311a2b8a4ee641d7ef0c46331378da0a328467b (patch)
treeaba62030ace445f000a3241cd0e7b30a14d516fa
parentce7e32798f0a5b337b63929c4c5dd237206862f1 (diff)
downloadsrc-8311a2b8a4ee641d7ef0c46331378da0a328467b.tar.gz
src-8311a2b8a4ee641d7ef0c46331378da0a328467b.zip
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
Notes
Notes: svn path=/head/; revision=277651
-rw-r--r--sys/vm/vm_pageout.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
index c81290ca097d..ecc3dabfe70f 100644
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -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);