aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vm_kern.c
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2009-02-23 23:00:12 +0000
committerRobert Watson <rwatson@FreeBSD.org>2009-02-23 23:00:12 +0000
commit86f087370bb4c3f371b619dbb53c2bf4051ccfb5 (patch)
tree4887b292b5f814ad1502e0897e96e1bda6dfc078 /sys/vm/vm_kern.c
parenta714e55f736f1f8db0a90d8e6a4e04806c013e30 (diff)
downloadsrc-86f087370bb4c3f371b619dbb53c2bf4051ccfb5.tar.gz
src-86f087370bb4c3f371b619dbb53c2bf4051ccfb5.zip
Add a debugging sysctl, debug.vm_lowmem, that when assigned a value of
1 will trigger a pass through the VM's low-memory handlers, such as protocol and UMA drain routines. This makes it easier to exercise these otherwise rarely-invoked code paths. MFC after: 3 days
Notes
Notes: svn path=/head/; revision=188964
Diffstat (limited to 'sys/vm/vm_kern.c')
-rw-r--r--sys/vm/vm_kern.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c
index b43805885a50..f80ad30c48b3 100644
--- a/sys/vm/vm_kern.c
+++ b/sys/vm/vm_kern.c
@@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/malloc.h>
+#include <sys/sysctl.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -500,3 +501,24 @@ kmem_init(start, end)
/* ... and ending with the completion of the above `insert' */
vm_map_unlock(m);
}
+
+/*
+ * Allow userspace to directly trigger the VM drain routine for testing
+ * purposes.
+ */
+static int
+debug_vm_lowmem(SYSCTL_HANDLER_ARGS)
+{
+ int error, i;
+
+ i = 0;
+ error = sysctl_handle_int(oidp, &i, 0, req);
+ if (error)
+ return (error);
+ if (i)
+ EVENTHANDLER_INVOKE(vm_lowmem, 0);
+ return (0);
+}
+
+SYSCTL_PROC(_debug, OID_AUTO, vm_lowmem, CTLTYPE_INT | CTLFLAG_RW, 0, 0,
+ debug_vm_lowmem, "I", "set to trigger vm_lowmem event");