summaryrefslogtreecommitdiffstats
path: root/usr.sbin/watchdogd
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2013-01-26 21:29:45 +0000
committerian <ian@FreeBSD.org>2013-01-26 21:29:45 +0000
commitfc60ef94da43c5c4218e21f42aa2769c13b89e37 (patch)
treed91fe0e28b1b64e1a8fe2375c1e1b7154ccef86e /usr.sbin/watchdogd
parentdc3eff401fd8f122ed908c7be997eeb928fa85ba (diff)
downloadFreeBSD-src-fc60ef94da43c5c4218e21f42aa2769c13b89e37.zip
FreeBSD-src-fc60ef94da43c5c4218e21f42aa2769c13b89e37.tar.gz
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)
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 8109aa1..47c9e7d 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;
}
}
OpenPOWER on IntegriCloud