summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_timeout.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2013-03-08 10:14:58 +0000
committerandre <andre@FreeBSD.org>2013-03-08 10:14:58 +0000
commit7f0cc3ba06376c70d7259b9d2b80a8ad5d4583be (patch)
tree3b153971c209175c11aa60030eb1581e42e42d1e /sys/kern/kern_timeout.c
parentac59206acfdd9f611aea30d00816ffca9f8011b2 (diff)
downloadFreeBSD-src-7f0cc3ba06376c70d7259b9d2b80a8ad5d4583be.zip
FreeBSD-src-7f0cc3ba06376c70d7259b9d2b80a8ad5d4583be.tar.gz
Move the auto-sizing of the callout array from init_param2() to
kern_timeout_callwheel_alloc() where it is actually used. This is a mechanical move and no tuning parameters are changed. The pre-allocated callout array is only used for legacy timeout(9) calls and is only allocated and active on cpu0. Eventually all remaining users of timeout(9) should switch to the callout_* API. Reviewed by: davide
Diffstat (limited to 'sys/kern/kern_timeout.c')
-rw-r--r--sys/kern/kern_timeout.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index df459cd..ecc65fc 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/callout.h>
+#include <sys/file.h>
#include <sys/interrupt.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
@@ -101,6 +102,11 @@ SYSCTL_INT(_debug, OID_AUTO, to_avg_mpcalls_dir, CTLFLAG_RD, &avg_mpcalls_dir,
0, "Average number of MP direct callouts made per callout_process call. "
"Units = 1/1000");
#endif
+
+static int ncallout;
+SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RDTUN, &ncallout, 0,
+ "Number of entries in callwheel and size of timeout() preallocation");
+
/*
* TODO:
* allocate more timeout table slots when table overflows.
@@ -252,6 +258,14 @@ kern_timeout_callwheel_alloc(caddr_t v)
timeout_cpu = PCPU_GET(cpuid);
cc = CC_CPU(timeout_cpu);
+
+ /*
+ * Calculate the size of the callout wheel and the preallocated
+ * timeout() structures.
+ */
+ ncallout = imin(16 + maxproc + maxfiles, 18508);
+ TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
+
/*
* Calculate callout wheel size, should be next power of two higher
* than 'ncallout'.
OpenPOWER on IntegriCloud