aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/watchdogd
diff options
context:
space:
mode:
authorIan Lepore <ian@FreeBSD.org>2013-01-26 21:29:45 +0000
committerIan Lepore <ian@FreeBSD.org>2013-01-26 21:29:45 +0000
commite6af9f3a37d0adb679bf5aa8988c4b4b02f36f1c (patch)
treed91fe0e28b1b64e1a8fe2375c1e1b7154ccef86e /usr.sbin/watchdogd
parent922c0acd572a52f3111501d5bc93c85aeb82941c (diff)
downloadsrc-e6af9f3a37d0adb679bf5aa8988c4b4b02f36f1c.tar.gz
src-e6af9f3a37d0adb679bf5aa8988c4b4b02f36f1c.zip
Reduce watchdogd's memory footprint when running daemonized.
This uses the recently-added jemalloc(3) feature of setting the lg_chunk tuning option to zero to request that memory be allocated in the smallest chunks possible. Without this option, the default is to initally map 8MB, and then the mlockall() call wires that entire allocation even though the program only uses a few Kbytes of it at runtime. PR: bin/173332 Approved by: cognet (mentor)
Notes
Notes: svn path=/head/; revision=245949
Diffstat (limited to 'usr.sbin/watchdogd')
-rw-r--r--usr.sbin/watchdogd/watchdogd.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.sbin/watchdogd/watchdogd.c b/usr.sbin/watchdogd/watchdogd.c
index 8109aa1c0dbf..47c9e7d8b9ac 100644
--- a/usr.sbin/watchdogd/watchdogd.c
+++ b/usr.sbin/watchdogd/watchdogd.c
@@ -71,6 +71,14 @@ static int nap = 1;
static char *test_cmd = NULL;
/*
+ * Ask malloc() to map minimum-sized chunks of virtual address space at a time,
+ * so that mlockall() won't needlessly wire megabytes of unused memory into the
+ * process. This must be done using the malloc_conf string so that it gets set
+ * up before the first allocation, which happens before entry to main().
+ */
+const char * malloc_conf = "lg_chunk:0";
+
+/*
* Periodically pat the watchdog, preventing it from firing.
*/
int
@@ -188,7 +196,7 @@ watchdog_loop(void)
if (watchdog_onoff(0) == 0) {
end_program = 2;
} else {
- warnx("Could not stop the watchdog, not exiting");
+ warnx("Could not stop the watchdog, not exitting");
end_program = 0;
}
}