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
This commit is contained in:
Andre Oppermann 2013-03-08 10:14:58 +00:00
parent 08907adea3
commit f8ccf82a4c
3 changed files with 14 additions and 14 deletions

View File

@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/bus.h> #include <sys/bus.h>
#include <sys/callout.h> #include <sys/callout.h>
#include <sys/file.h>
#include <sys/interrupt.h> #include <sys/interrupt.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#include <sys/ktr.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. " 0, "Average number of MP direct callouts made per callout_process call. "
"Units = 1/1000"); "Units = 1/1000");
#endif #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: * TODO:
* allocate more timeout table slots when table overflows. * allocate more timeout table slots when table overflows.
@ -252,6 +258,14 @@ kern_timeout_callwheel_alloc(caddr_t v)
timeout_cpu = PCPU_GET(cpuid); timeout_cpu = PCPU_GET(cpuid);
cc = CC_CPU(timeout_cpu); 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 * Calculate callout wheel size, should be next power of two higher
* than 'ncallout'. * than 'ncallout'.

View File

@ -91,7 +91,6 @@ int maxprocperuid; /* max # of procs per user */
int maxfiles; /* sys. wide open files limit */ int maxfiles; /* sys. wide open files limit */
int maxfilesperproc; /* per-proc open files limit */ int maxfilesperproc; /* per-proc open files limit */
int msgbufsize; /* size of kernel message buffer */ int msgbufsize; /* size of kernel message buffer */
int ncallout; /* maximum # of timer events */
int nbuf; int nbuf;
int ngroups_max; /* max # groups per process */ int ngroups_max; /* max # groups per process */
int nswbuf; int nswbuf;
@ -109,8 +108,6 @@ u_long sgrowsiz; /* amount to grow stack */
SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN, &hz, 0, SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN, &hz, 0,
"Number of clock ticks per second"); "Number of clock ticks per second");
SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RDTUN, &ncallout, 0,
"Number of pre-allocated timer events");
SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN, &nbuf, 0, SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN, &nbuf, 0,
"Number of buffers in the buffer cache"); "Number of buffers in the buffer cache");
SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN, &nswbuf, 0, SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN, &nswbuf, 0,
@ -326,15 +323,6 @@ init_param2(long physpages)
nbuf = NBUF; nbuf = NBUF;
TUNABLE_INT_FETCH("kern.nbuf", &nbuf); TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
/*
* XXX: Does the callout wheel have to be so big?
*
* Clip callout to result of previous function of maxusers maximum
* 384. This is still huge, but acceptable.
*/
ncallout = imin(16 + maxproc + maxfiles, 18508);
TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
/* /*
* The default for maxpipekva is min(1/64 of the kernel address space, * The default for maxpipekva is min(1/64 of the kernel address space,
* max(1/64 of main memory, 512KB)). See sys_pipe.c for more details. * max(1/64 of main memory, 512KB)). See sys_pipe.c for more details.

View File

@ -63,8 +63,6 @@ struct callout_handle {
}; };
#ifdef _KERNEL #ifdef _KERNEL
extern int ncallout;
#define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE) #define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE)
#define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE) #define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE)
#define callout_drain(c) _callout_stop_safe(c, 1) #define callout_drain(c) _callout_stop_safe(c, 1)