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

Function uma_zalloc_debug

freebsd/vm/uma_core.c:3298–3346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3296#if defined(INVARIANTS) || defined(DEBUG_MEMGUARD) || defined(WITNESS)
3297#define UMA_ZALLOC_DEBUG
3298static int
3299uma_zalloc_debug(uma_zone_t zone, void **itemp, void *udata, int flags)
3300{
3301 int error;
3302
3303 error = 0;
3304#ifdef WITNESS
3305 if (flags & M_WAITOK) {
3306 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
3307 "uma_zalloc_debug: zone \"%s\"", zone->uz_name);
3308 }
3309#endif
3310
3311#ifdef INVARIANTS
3312 KASSERT((flags & M_EXEC) == 0,
3313 ("uma_zalloc_debug: called with M_EXEC"));
3314 KASSERT(curthread->td_critnest == 0 || SCHEDULER_STOPPED(),
3315 ("uma_zalloc_debug: called within spinlock or critical section"));
3316 KASSERT((zone->uz_flags & UMA_ZONE_PCPU) == 0 || (flags & M_ZERO) == 0,
3317 ("uma_zalloc_debug: allocating from a pcpu zone with M_ZERO"));
3318#endif
3319
3320#ifdef DEBUG_MEMGUARD
3321 if ((zone->uz_flags & UMA_ZONE_SMR) == 0 && memguard_cmp_zone(zone)) {
3322 void *item;
3323 item = memguard_alloc(zone->uz_size, flags);
3324 if (item != NULL) {
3325 error = EJUSTRETURN;
3326 if (zone->uz_init != NULL &&
3327 zone->uz_init(item, zone->uz_size, flags) != 0) {
3328 *itemp = NULL;
3329 return (error);
3330 }
3331 if (zone->uz_ctor != NULL &&
3332 zone->uz_ctor(item, zone->uz_size, udata,
3333 flags) != 0) {
3334 counter_u64_add(zone->uz_fails, 1);
3335 zone->uz_fini(item, zone->uz_size);
3336 *itemp = NULL;
3337 return (error);
3338 }
3339 *itemp = item;
3340 return (error);
3341 }
3342 /* This is unfortunate but should not be fatal. */
3343 }
3344#endif
3345 return (error);
3346}
3347
3348static int
3349uma_zfree_debug(uma_zone_t zone, void *item, void *udata)

Callers 2

uma_zalloc_smrFunction · 0.85
uma_zalloc_argFunction · 0.85

Calls 3

memguard_cmp_zoneFunction · 0.85
memguard_allocFunction · 0.85
counter_u64_addFunction · 0.50

Tested by

no test coverage detected