* Kernel low level callwheel initialization * called on cpu0 during kernel startup. */
| 222 | * called on cpu0 during kernel startup. |
| 223 | */ |
| 224 | static void |
| 225 | callout_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 | } |
| 264 | SYSINIT(callwheel_init, SI_SUB_CPU, SI_ORDER_ANY, callout_callwheel_init, NULL); |
| 265 | |
| 266 | /* |
nothing calls this directly
no test coverage detected