MCPcopy Create free account
hub / github.com/F-Stack/f-stack / callout_callwheel_init

Function callout_callwheel_init

lib/ff_kern_timeout.c:224–263  ·  view source on GitHub ↗

* Kernel low level callwheel initialization * called on cpu0 during kernel startup. */

Source from the content-addressed store, hash-verified

222 * called on cpu0 during kernel startup.
223 */
224static void
225callout_callwheel_init(void *dummy)
226{
227 struct callout_cpu *cc;
228
229 /*
230 * Calculate the size of the callout wheel and the preallocated
231 * timeout() structures.
232 * XXX: Clip callout to result of previous function of maxusers
233 * maximum 384. This is still huge, but acceptable.
234 */
235 memset(CC_CPU(0), 0, sizeof(cc_cpu));
236 ncallout = imin(16 + maxproc + maxfiles, 18508);
237 TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
238
239 /*
240 * Calculate callout wheel size, should be next power of two higher
241 * than 'ncallout'.
242 */
243 callwheelsize = 1 << fls(ncallout);
244 callwheelmask = callwheelsize - 1;
245
246 /*
247 * Fetch whether we're pinning the swi's or not.
248 */
249 TUNABLE_INT_FETCH("kern.pin_default_swi", &pin_default_swi);
250 TUNABLE_INT_FETCH("kern.pin_pcpu_swi", &pin_pcpu_swi);
251
252 /*
253 * Only cpu0 handles timeout(9) and receives a preallocation.
254 *
255 * XXX: Once all timeout(9) consumers are converted this can
256 * be removed.
257 */
258 timeout_cpu = PCPU_GET(cpuid);
259 cc = CC_CPU(timeout_cpu);
260 cc->cc_callout = malloc(ncallout * sizeof(struct callout),
261 M_CALLOUT, M_WAITOK);
262 callout_cpu_init(cc, timeout_cpu);
263}
264SYSINIT(callwheel_init, SI_SUB_CPU, SI_ORDER_ANY, callout_callwheel_init, NULL);
265
266/*

Callers

nothing calls this directly

Calls 5

memsetFunction · 0.85
iminFunction · 0.85
mallocFunction · 0.85
callout_cpu_initFunction · 0.70
flsFunction · 0.50

Tested by

no test coverage detected