Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/uma_core.c
Show First 20 Lines • Show All 3,423 Lines • ▼ Show 20 Lines | cache_alloc(uma_zone_t zone, uma_cache_t cache, void *udata, int flags) | ||||
critical_exit(); | critical_exit(); | ||||
if (bucket != NULL) { | if (bucket != NULL) { | ||||
KASSERT(bucket->ub_cnt == 0, | KASSERT(bucket->ub_cnt == 0, | ||||
("cache_alloc: Entered with non-empty alloc bucket.")); | ("cache_alloc: Entered with non-empty alloc bucket.")); | ||||
bucket_free(zone, bucket, udata); | bucket_free(zone, bucket, udata); | ||||
} | } | ||||
/* Short-circuit for zones without buckets and low memory. */ | |||||
if (zone->uz_bucket_size == 0 || bucketdisable) { | |||||
critical_enter(); | |||||
return (false); | |||||
} | |||||
/* | /* | ||||
* Attempt to retrieve the item from the per-CPU cache has failed, so | * Attempt to retrieve the item from the per-CPU cache has failed, so | ||||
* we must go back to the zone. This requires the zdom lock, so we | * we must go back to the zone. This requires the zdom lock, so we | ||||
* must drop the critical section, then re-acquire it when we go back | * must drop the critical section, then re-acquire it when we go back | ||||
* to the cache. Since the critical section is released, we may be | * to the cache. Since the critical section is released, we may be | ||||
* preempted or migrate. As such, make sure not to maintain any | * preempted or migrate. As such, make sure not to maintain any | ||||
* thread-local state specific to the cache from prior to releasing | * thread-local state specific to the cache from prior to releasing | ||||
* the critical section. | * the critical section. | ||||
*/ | */ | ||||
domain = PCPU_GET(domain); | domain = PCPU_GET(domain); | ||||
if ((cache_uz_flags(cache) & UMA_ZONE_ROUNDROBIN) != 0 || | if ((cache_uz_flags(cache) & UMA_ZONE_ROUNDROBIN) != 0 || | ||||
VM_DOMAIN_EMPTY(domain)) | VM_DOMAIN_EMPTY(domain)) | ||||
domain = zone_domain_highest(zone, domain); | domain = zone_domain_highest(zone, domain); | ||||
bucket = cache_fetch_bucket(zone, cache, domain); | bucket = cache_fetch_bucket(zone, cache, domain); | ||||
if (bucket == NULL) { | if (bucket == NULL && zone->uz_bucket_size != 0 && !bucketdisable) { | ||||
bucket = zone_alloc_bucket(zone, udata, domain, flags); | bucket = zone_alloc_bucket(zone, udata, domain, flags); | ||||
new = true; | new = true; | ||||
} else | } else { | ||||
new = false; | new = false; | ||||
} | |||||
CTR3(KTR_UMA, "uma_zalloc: zone %s(%p) bucket zone returned %p", | CTR3(KTR_UMA, "uma_zalloc: zone %s(%p) bucket zone returned %p", | ||||
zone->uz_name, zone, bucket); | zone->uz_name, zone, bucket); | ||||
if (bucket == NULL) { | if (bucket == NULL) { | ||||
critical_enter(); | critical_enter(); | ||||
return (false); | return (false); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,984 Lines • Show Last 20 Lines |