Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/uma_core.c
Show First 20 Lines • Show All 325 Lines • ▼ Show 20 Lines | |||||
static void *slab_alloc_item(uma_keg_t keg, uma_slab_t slab); | static void *slab_alloc_item(uma_keg_t keg, uma_slab_t slab); | ||||
static void slab_free_item(uma_zone_t zone, uma_slab_t slab, void *item); | static void slab_free_item(uma_zone_t zone, uma_slab_t slab, void *item); | ||||
static size_t slab_sizeof(int nitems); | static size_t slab_sizeof(int nitems); | ||||
static uma_keg_t uma_kcreate(uma_zone_t zone, size_t size, uma_init uminit, | static uma_keg_t uma_kcreate(uma_zone_t zone, size_t size, uma_init uminit, | ||||
uma_fini fini, int align, uint32_t flags); | uma_fini fini, int align, uint32_t flags); | ||||
static int zone_import(void *, void **, int, int, int); | static int zone_import(void *, void **, int, int, int); | ||||
static void zone_release(void *, void **, int); | static void zone_release(void *, void **, int); | ||||
static bool cache_alloc(uma_zone_t, uma_cache_t, void *, int); | static bool cache_alloc(uma_zone_t, uma_cache_t, void *, int); | ||||
static bool cache_free(uma_zone_t, uma_cache_t, void *, void *, int); | static bool cache_free(uma_zone_t, uma_cache_t, void *, int); | ||||
static int sysctl_vm_zone_count(SYSCTL_HANDLER_ARGS); | static int sysctl_vm_zone_count(SYSCTL_HANDLER_ARGS); | ||||
static int sysctl_vm_zone_stats(SYSCTL_HANDLER_ARGS); | static int sysctl_vm_zone_stats(SYSCTL_HANDLER_ARGS); | ||||
static int sysctl_handle_uma_zone_allocs(SYSCTL_HANDLER_ARGS); | static int sysctl_handle_uma_zone_allocs(SYSCTL_HANDLER_ARGS); | ||||
static int sysctl_handle_uma_zone_frees(SYSCTL_HANDLER_ARGS); | static int sysctl_handle_uma_zone_frees(SYSCTL_HANDLER_ARGS); | ||||
static int sysctl_handle_uma_zone_flags(SYSCTL_HANDLER_ARGS); | static int sysctl_handle_uma_zone_flags(SYSCTL_HANDLER_ARGS); | ||||
static int sysctl_handle_uma_slab_efficiency(SYSCTL_HANDLER_ARGS); | static int sysctl_handle_uma_slab_efficiency(SYSCTL_HANDLER_ARGS); | ||||
static int sysctl_handle_uma_zone_items(SYSCTL_HANDLER_ARGS); | static int sysctl_handle_uma_zone_items(SYSCTL_HANDLER_ARGS); | ||||
▲ Show 20 Lines • Show All 4,062 Lines • ▼ Show 20 Lines | if ((uz_flags & UMA_ZONE_FIRSTTOUCH) != 0 && | ||||
bucket = &cache->uc_crossbucket; | bucket = &cache->uc_crossbucket; | ||||
} | } | ||||
#endif | #endif | ||||
if (__predict_true(bucket->ucb_cnt < bucket->ucb_entries)) { | if (__predict_true(bucket->ucb_cnt < bucket->ucb_entries)) { | ||||
cache_bucket_push(cache, bucket, item); | cache_bucket_push(cache, bucket, item); | ||||
critical_exit(); | critical_exit(); | ||||
return; | return; | ||||
} | } | ||||
} while (cache_free(zone, cache, NULL, item, itemdomain)); | } while (cache_free(zone, cache, NULL, itemdomain)); | ||||
critical_exit(); | critical_exit(); | ||||
/* | /* | ||||
* If nothing else caught this, we'll just do an internal free. | * If nothing else caught this, we'll just do an internal free. | ||||
*/ | */ | ||||
zone_free_item(zone, item, NULL, SKIP_NONE); | zone_free_item(zone, item, NULL, SKIP_NONE); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | if (bucket->ucb_cnt == bucket->ucb_entries && | ||||
cache->uc_freebucket.ucb_entries) | cache->uc_freebucket.ucb_entries) | ||||
cache_bucket_swap(&cache->uc_freebucket, | cache_bucket_swap(&cache->uc_freebucket, | ||||
&cache->uc_allocbucket); | &cache->uc_allocbucket); | ||||
if (__predict_true(bucket->ucb_cnt < bucket->ucb_entries)) { | if (__predict_true(bucket->ucb_cnt < bucket->ucb_entries)) { | ||||
cache_bucket_push(cache, bucket, item); | cache_bucket_push(cache, bucket, item); | ||||
critical_exit(); | critical_exit(); | ||||
return; | return; | ||||
} | } | ||||
} while (cache_free(zone, cache, udata, item, itemdomain)); | } while (cache_free(zone, cache, udata, itemdomain)); | ||||
critical_exit(); | critical_exit(); | ||||
/* | /* | ||||
* If nothing else caught this, we'll just do an internal free. | * If nothing else caught this, we'll just do an internal free. | ||||
*/ | */ | ||||
zfree_item: | zfree_item: | ||||
zone_free_item(zone, item, udata, SKIP_DTOR); | zone_free_item(zone, item, udata, SKIP_DTOR); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | |||||
* Populate a free or cross bucket for the current cpu cache. Free any | * Populate a free or cross bucket for the current cpu cache. Free any | ||||
* existing full bucket either to the zone cache or back to the slab layer. | * existing full bucket either to the zone cache or back to the slab layer. | ||||
* | * | ||||
* Enters and returns in a critical section. false return indicates that | * Enters and returns in a critical section. false return indicates that | ||||
* we can not satisfy this free in the cache layer. true indicates that | * we can not satisfy this free in the cache layer. true indicates that | ||||
* the caller should retry. | * the caller should retry. | ||||
*/ | */ | ||||
static __noinline bool | static __noinline bool | ||||
cache_free(uma_zone_t zone, uma_cache_t cache, void *udata, void *item, | cache_free(uma_zone_t zone, uma_cache_t cache, void *udata, int itemdomain) | ||||
int itemdomain) | |||||
{ | { | ||||
uma_cache_bucket_t cbucket; | uma_cache_bucket_t cbucket; | ||||
uma_bucket_t newbucket, bucket; | uma_bucket_t newbucket, bucket; | ||||
CRITICAL_ASSERT(curthread); | CRITICAL_ASSERT(curthread); | ||||
if (zone->uz_bucket_size == 0) | if (zone->uz_bucket_size == 0) | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 1,213 Lines • Show Last 20 Lines |