svn commit: r245949 - head/usr.sbin/watchdogd
Ian Lepore
ian at FreeBSD.org
Sat Jan 26 21:29:46 UTC 2013
Author: ian
Date: Sat Jan 26 21:29:45 2013
New Revision: 245949
URL: http://svnweb.freebsd.org/changeset/base/245949
Log:
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)
Modified:
head/usr.sbin/watchdogd/watchdogd.c
Modified: head/usr.sbin/watchdogd/watchdogd.c
==============================================================================
--- head/usr.sbin/watchdogd/watchdogd.c Sat Jan 26 20:16:58 2013 (r245948)
+++ head/usr.sbin/watchdogd/watchdogd.c Sat Jan 26 21:29:45 2013 (r245949)
@@ -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;
}
}
More information about the svn-src-head
mailing list