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

Function keg_ctor

freebsd/vm/uma_core.c:2250–2372  ·  view source on GitHub ↗

* Keg header ctor. This initializes all fields, locks, etc. And inserts * the keg onto the global keg list. * * Arguments/Returns follow uma_ctor specifications * udata Actually uma_kctor_args */

Source from the content-addressed store, hash-verified

2248 * udata Actually uma_kctor_args
2249 */
2250static int
2251keg_ctor(void *mem, int size, void *udata, int flags)
2252{
2253 struct uma_kctor_args *arg = udata;
2254 uma_keg_t keg = mem;
2255 uma_zone_t zone;
2256 int i;
2257
2258 bzero(keg, size);
2259 keg->uk_size = arg->size;
2260 keg->uk_init = arg->uminit;
2261 keg->uk_fini = arg->fini;
2262 keg->uk_align = arg->align;
2263 keg->uk_reserve = 0;
2264 keg->uk_flags = arg->flags;
2265
2266 /*
2267 * We use a global round-robin policy by default. Zones with
2268 * UMA_ZONE_FIRSTTOUCH set will use first-touch instead, in which
2269 * case the iterator is never run.
2270 */
2271 keg->uk_dr.dr_policy = DOMAINSET_RR();
2272 keg->uk_dr.dr_iter = 0;
2273
2274 /*
2275 * The primary zone is passed to us at keg-creation time.
2276 */
2277 zone = arg->zone;
2278 keg->uk_name = zone->uz_name;
2279
2280 if (arg->flags & UMA_ZONE_ZINIT)
2281 keg->uk_init = zero_init;
2282
2283 if (arg->flags & UMA_ZONE_MALLOC)
2284 keg->uk_flags |= UMA_ZFLAG_VTOSLAB;
2285
2286#ifndef SMP
2287 keg->uk_flags &= ~UMA_ZONE_PCPU;
2288#endif
2289
2290 keg_layout(keg);
2291
2292 /*
2293 * Use a first-touch NUMA policy for kegs that pmap_extract() will
2294 * work on. Use round-robin for everything else.
2295 *
2296 * Zones may override the default by specifying either.
2297 */
2298#ifdef NUMA
2299 if ((keg->uk_flags &
2300 (UMA_ZONE_ROUNDROBIN | UMA_ZFLAG_CACHE | UMA_ZONE_NOTPAGE)) == 0)
2301 keg->uk_flags |= UMA_ZONE_FIRSTTOUCH;
2302 else if ((keg->uk_flags & UMA_ZONE_FIRSTTOUCH) == 0)
2303 keg->uk_flags |= UMA_ZONE_ROUNDROBIN;
2304#endif
2305
2306 /*
2307 * If we haven't booted yet we need allocations to go through the

Callers 1

zone_ctorFunction · 0.85

Calls 4

bzeroFunction · 0.85
keg_layoutFunction · 0.85
slab_sizeofFunction · 0.85
hash_allocFunction · 0.85

Tested by

no test coverage detected