Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/uma_core.c
Show First 20 Lines • Show All 3,728 Lines • ▼ Show 20 Lines | #endif | ||||
/* Try to keep the buckets totally full */ | /* Try to keep the buckets totally full */ | ||||
for (i = 0; i < max; ) { | for (i = 0; i < max; ) { | ||||
if ((slab = keg_fetch_slab(keg, zone, domain, flags)) == NULL) | if ((slab = keg_fetch_slab(keg, zone, domain, flags)) == NULL) | ||||
break; | break; | ||||
#ifdef NUMA | #ifdef NUMA | ||||
stripe = howmany(max, vm_ndomains); | stripe = howmany(max, vm_ndomains); | ||||
#endif | #endif | ||||
dom = &keg->uk_domain[slab->us_domain]; | dom = &keg->uk_domain[slab->us_domain]; | ||||
while (slab->us_freecount && i < max) { | do { | ||||
bucket[i++] = slab_alloc_item(keg, slab); | bucket[i++] = slab_alloc_item(keg, slab); | ||||
if (dom->ud_free_items <= keg->uk_reserve) | if (dom->ud_free_items <= keg->uk_reserve) { | ||||
break; | /* | ||||
* Avoid depleting the reserve after a | |||||
* successful item allocation, even if | |||||
* M_USE_RESERVE is specified. | |||||
*/ | |||||
KEG_UNLOCK(keg, slab->us_domain); | |||||
goto out; | |||||
} | |||||
#ifdef NUMA | #ifdef NUMA | ||||
/* | /* | ||||
* If the zone is striped we pick a new slab for every | * If the zone is striped we pick a new slab for every | ||||
* N allocations. Eliminating this conditional will | * N allocations. Eliminating this conditional will | ||||
* instead pick a new domain for each bucket rather | * instead pick a new domain for each bucket rather | ||||
* than stripe within each bucket. The current option | * than stripe within each bucket. The current option | ||||
* produces more fragmentation and requires more cpu | * produces more fragmentation and requires more cpu | ||||
* time but yields better distribution. | * time but yields better distribution. | ||||
*/ | */ | ||||
if ((zone->uz_flags & UMA_ZONE_ROUNDROBIN) != 0 && | if ((zone->uz_flags & UMA_ZONE_ROUNDROBIN) != 0 && | ||||
vm_ndomains > 1 && --stripe == 0) | vm_ndomains > 1 && --stripe == 0) | ||||
break; | break; | ||||
#endif | #endif | ||||
} | } while (slab->us_freecount != 0 && i < max); | ||||
KEG_UNLOCK(keg, slab->us_domain); | KEG_UNLOCK(keg, slab->us_domain); | ||||
/* Don't block if we allocated any successfully. */ | /* Don't block if we allocated any successfully. */ | ||||
flags &= ~M_WAITOK; | flags &= ~M_WAITOK; | ||||
flags |= M_NOWAIT; | flags |= M_NOWAIT; | ||||
} | } | ||||
out: | |||||
return i; | return i; | ||||
} | } | ||||
static int | static int | ||||
zone_alloc_limit_hard(uma_zone_t zone, int count, int flags) | zone_alloc_limit_hard(uma_zone_t zone, int count, int flags) | ||||
{ | { | ||||
uint64_t old, new, total, max; | uint64_t old, new, total, max; | ||||
▲ Show 20 Lines • Show All 1,728 Lines • Show Last 20 Lines |