Check the UMA zone's full bucket cache before short-circuiting an alloc.
The global "bucketdisable" flag indicates that we are in a low memory situation and should avoid allocating buckets. However, in the allocation path we were checking it before the full bucket cache and bailing even if the cache is non-empty. Defer the check so that we have a shot at allocating from the cache. This came up because M_NOWAIT allocations from the buf trie node zone must always succeed. In one scenario, all of the preallocated trie nodes were in the bucket list, and a new slab allocation could not succeed due to a memory shortage. The short-circuiting caused an allocation failure which triggered a panic. Reported by: pho Reviewed by: cem Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25980
This commit is contained in:
+3
-8
@@ -3429,12 +3429,6 @@ cache_alloc(uma_zone_t zone, uma_cache_t cache, void *udata, int flags)
|
||||
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
|
||||
* we must go back to the zone. This requires the zdom lock, so we
|
||||
@@ -3449,11 +3443,12 @@ cache_alloc(uma_zone_t zone, uma_cache_t cache, void *udata, int flags)
|
||||
VM_DOMAIN_EMPTY(domain))
|
||||
domain = zone_domain_highest(zone, 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);
|
||||
new = true;
|
||||
} else
|
||||
} else {
|
||||
new = false;
|
||||
}
|
||||
|
||||
CTR3(KTR_UMA, "uma_zalloc: zone %s(%p) bucket zone returned %p",
|
||||
zone->uz_name, zone, bucket);
|
||||
|
||||
Reference in New Issue
Block a user