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

Function uma_zalloc_arg

freebsd/vm/uma_core.c:3432–3471  ·  view source on GitHub ↗

See uma.h */

Source from the content-addressed store, hash-verified

3430
3431/* See uma.h */
3432void *
3433uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
3434{
3435 uma_cache_bucket_t bucket;
3436 uma_cache_t cache;
3437
3438 /* Enable entropy collection for RANDOM_ENABLE_UMA kernel option */
3439 random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA);
3440
3441 /* This is the fast path allocation */
3442 CTR3(KTR_UMA, "uma_zalloc_arg zone %s(%p) flags %d", zone->uz_name,
3443 zone, flags);
3444
3445#ifdef UMA_ZALLOC_DEBUG
3446 void *item;
3447
3448 KASSERT((zone->uz_flags & UMA_ZONE_SMR) == 0,
3449 ("uma_zalloc_arg: called with SMR zone."));
3450 if (uma_zalloc_debug(zone, &item, udata, flags) == EJUSTRETURN)
3451 return (item);
3452#endif
3453
3454 /*
3455 * If possible, allocate from the per-CPU cache. There are two
3456 * requirements for safe access to the per-CPU cache: (1) the thread
3457 * accessing the cache must not be preempted or yield during access,
3458 * and (2) the thread must not migrate CPUs without switching which
3459 * cache it accesses. We rely on a critical section to prevent
3460 * preemption and migration. We release the critical section in
3461 * order to acquire the zone mutex if we are unable to allocate from
3462 * the current cache; when we re-acquire the critical section, we
3463 * must detect and handle migration if it has occurred.
3464 */
3465 critical_enter();
3466 cache = &zone->uz_cpu[curcpu];
3467 bucket = &cache->uc_allocbucket;
3468 if (__predict_false(bucket->ucb_cnt == 0))
3469 return (cache_alloc_retry(zone, cache, udata, flags));
3470 return (cache_alloc_item(zone, cache, bucket, udata, flags));
3471}
3472
3473/*
3474 * Replenish an alloc bucket and possibly restore an old one. Called in

Callers 15

m_getFunction · 0.85
m_gethdrFunction · 0.85
m_getclFunction · 0.85
uma_zallocFunction · 0.85
kmem_cache_allocFunction · 0.85
audit_newFunction · 0.85
m_getFunction · 0.85
m_gethdrFunction · 0.85
m_getclFunction · 0.85
_busdma_alloc_dmamapFunction · 0.85
mb_zinit_packFunction · 0.85
m_clgetFunction · 0.85

Calls 4

uma_zalloc_debugFunction · 0.85
cache_alloc_retryFunction · 0.85
cache_alloc_itemFunction · 0.85
critical_enterFunction · 0.50

Tested by

no test coverage detected