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

Function zone_alloc_item

freebsd/vm/uma_core.c:4083–4132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4081 */
4082
4083static void *
4084zone_alloc_item(uma_zone_t zone, void *udata, int domain, int flags)
4085{
4086 void *item;
4087
4088 if (zone->uz_max_items > 0 && zone_alloc_limit(zone, 1, flags) == 0) {
4089 counter_u64_add(zone->uz_fails, 1);
4090 return (NULL);
4091 }
4092
4093 /* Avoid allocs targeting empty domains. */
4094 if (domain != UMA_ANYDOMAIN && VM_DOMAIN_EMPTY(domain))
4095 domain = UMA_ANYDOMAIN;
4096
4097 if (zone->uz_import(zone->uz_arg, &item, 1, domain, flags) != 1)
4098 goto fail_cnt;
4099
4100 /*
4101 * We have to call both the zone's init (not the keg's init)
4102 * and the zone's ctor. This is because the item is going from
4103 * a keg slab directly to the user, and the user is expecting it
4104 * to be both zone-init'd as well as zone-ctor'd.
4105 */
4106 if (zone->uz_init != NULL) {
4107 if (zone->uz_init(item, zone->uz_size, flags) != 0) {
4108 zone_free_item(zone, item, udata, SKIP_FINI | SKIP_CNT);
4109 goto fail_cnt;
4110 }
4111 }
4112 item = item_ctor(zone, zone->uz_flags, zone->uz_size, udata, flags,
4113 item);
4114 if (item == NULL)
4115 goto fail;
4116
4117 counter_u64_add(zone->uz_allocs, 1);
4118 CTR3(KTR_UMA, "zone_alloc_item item %p from %s(%p)", item,
4119 zone->uz_name, zone);
4120
4121 return (item);
4122
4123fail_cnt:
4124 counter_u64_add(zone->uz_fails, 1);
4125fail:
4126 if (zone->uz_max_items > 0)
4127 zone_free_limit(zone, 1);
4128 CTR2(KTR_UMA, "zone_alloc_item failed from %s(%p)",
4129 zone->uz_name, zone);
4130
4131 return (NULL);
4132}
4133
4134/* See uma.h */
4135void

Callers 8

hash_allocFunction · 0.85
keg_alloc_slabFunction · 0.85
uma_kcreateFunction · 0.85
uma_zcreateFunction · 0.85
uma_zsecond_createFunction · 0.85
uma_zcache_createFunction · 0.85
cache_alloc_retryFunction · 0.85
uma_zalloc_domainFunction · 0.85

Calls 5

zone_alloc_limitFunction · 0.85
zone_free_itemFunction · 0.85
item_ctorFunction · 0.85
zone_free_limitFunction · 0.85
counter_u64_addFunction · 0.50

Tested by

no test coverage detected