Lines Matching refs:base
130 base_get_num_blocks(base_t *base, bool with_new_block) { in base_get_num_blocks() argument
131 base_block_t *b = base->blocks; in base_get_num_blocks()
144 base_auto_thp_switch(tsdn_t *tsdn, base_t *base) { in base_auto_thp_switch() argument
146 malloc_mutex_assert_owner(tsdn, &base->mtx); in base_auto_thp_switch()
147 if (base->auto_thp_switched) { in base_auto_thp_switch()
152 if (base_ind_get(base) != 0) { in base_auto_thp_switch()
153 should_switch = (base_get_num_blocks(base, true) == in base_auto_thp_switch()
156 should_switch = (base_get_num_blocks(base, true) == in base_auto_thp_switch()
163 base->auto_thp_switched = true; in base_auto_thp_switch()
164 assert(!config_stats || base->n_thp == 0); in base_auto_thp_switch()
166 base_block_t *block = base->blocks; in base_auto_thp_switch()
171 base->n_thp += HUGEPAGE_CEILING(block->size - in base_auto_thp_switch()
175 assert(block == NULL || (base_ind_get(base) == 0)); in base_auto_thp_switch()
198 base_extent_bump_alloc_post(base_t *base, extent_t *extent, size_t gap_size, in base_extent_bump_alloc_post() argument
207 extent_heap_insert(&base->avail[index_floor], extent); in base_extent_bump_alloc_post()
211 base->allocated += size; in base_extent_bump_alloc_post()
217 base->resident += PAGE_CEILING((uintptr_t)addr + size) - in base_extent_bump_alloc_post()
219 assert(base->allocated <= base->resident); in base_extent_bump_alloc_post()
220 assert(base->resident <= base->mapped); in base_extent_bump_alloc_post()
222 metadata_thp_always || base->auto_thp_switched)) { in base_extent_bump_alloc_post()
223 base->n_thp += (HUGEPAGE_CEILING((uintptr_t)addr + size) in base_extent_bump_alloc_post()
226 assert(base->mapped >= base->n_thp << LG_HUGEPAGE); in base_extent_bump_alloc_post()
232 base_extent_bump_alloc(base_t *base, extent_t *extent, size_t size, in base_extent_bump_alloc() argument
238 base_extent_bump_alloc_post(base, extent, gap_size, ret, size); in base_extent_bump_alloc()
248 base_block_alloc(tsdn_t *tsdn, base_t *base, extent_hooks_t *extent_hooks, in base_block_alloc() argument
283 base != NULL) { in base_block_alloc()
285 malloc_mutex_lock(tsdn, &base->mtx); in base_block_alloc()
286 base_auto_thp_switch(tsdn, base); in base_block_alloc()
287 if (base->auto_thp_switched) { in base_block_alloc()
290 malloc_mutex_unlock(tsdn, &base->mtx); in base_block_alloc()
308 base_extent_alloc(tsdn_t *tsdn, base_t *base, size_t size, size_t alignment) { in base_extent_alloc() argument
309 malloc_mutex_assert_owner(tsdn, &base->mtx); in base_extent_alloc()
311 extent_hooks_t *extent_hooks = base_extent_hooks_get(base); in base_extent_alloc()
316 malloc_mutex_unlock(tsdn, &base->mtx); in base_extent_alloc()
317 base_block_t *block = base_block_alloc(tsdn, base, extent_hooks, in base_extent_alloc()
318 base_ind_get(base), &base->pind_last, &base->extent_sn_next, size, in base_extent_alloc()
320 malloc_mutex_lock(tsdn, &base->mtx); in base_extent_alloc()
324 block->next = base->blocks; in base_extent_alloc()
325 base->blocks = block; in base_extent_alloc()
327 base->allocated += sizeof(base_block_t); in base_extent_alloc()
328 base->resident += PAGE_CEILING(sizeof(base_block_t)); in base_extent_alloc()
329 base->mapped += block->size; in base_extent_alloc()
332 && !base->auto_thp_switched)) { in base_extent_alloc()
333 assert(base->n_thp > 0); in base_extent_alloc()
334 base->n_thp += HUGEPAGE_CEILING(sizeof(base_block_t)) >> in base_extent_alloc()
337 assert(base->allocated <= base->resident); in base_extent_alloc()
338 assert(base->resident <= base->mapped); in base_extent_alloc()
339 assert(base->n_thp << LG_HUGEPAGE <= base->mapped); in base_extent_alloc()
362 base_t *base = (base_t *)base_extent_bump_alloc_helper(&block->extent, in base_new() local
364 base->ind = ind; in base_new()
365 atomic_store_p(&base->extent_hooks, extent_hooks, ATOMIC_RELAXED); in base_new()
366 if (malloc_mutex_init(&base->mtx, "base", WITNESS_RANK_BASE, in base_new()
371 base->pind_last = pind_last; in base_new()
372 base->extent_sn_next = extent_sn_next; in base_new()
373 base->blocks = block; in base_new()
374 base->auto_thp_switched = false; in base_new()
376 extent_heap_new(&base->avail[i]); in base_new()
379 base->allocated = sizeof(base_block_t); in base_new()
380 base->resident = PAGE_CEILING(sizeof(base_block_t)); in base_new()
381 base->mapped = block->size; in base_new()
382 base->n_thp = (opt_metadata_thp == metadata_thp_always) && in base_new()
385 assert(base->allocated <= base->resident); in base_new()
386 assert(base->resident <= base->mapped); in base_new()
387 assert(base->n_thp << LG_HUGEPAGE <= base->mapped); in base_new()
389 base_extent_bump_alloc_post(base, &block->extent, gap_size, base, in base_new()
392 return base; in base_new()
396 base_delete(tsdn_t *tsdn, base_t *base) { in base_delete() argument
397 extent_hooks_t *extent_hooks = base_extent_hooks_get(base); in base_delete()
398 base_block_t *next = base->blocks; in base_delete()
402 base_unmap(tsdn, extent_hooks, base_ind_get(base), block, in base_delete()
408 base_extent_hooks_get(base_t *base) { in base_extent_hooks_get() argument
409 return (extent_hooks_t *)atomic_load_p(&base->extent_hooks, in base_extent_hooks_get()
414 base_extent_hooks_set(base_t *base, extent_hooks_t *extent_hooks) { in base_extent_hooks_set() argument
415 extent_hooks_t *old_extent_hooks = base_extent_hooks_get(base); in base_extent_hooks_set()
416 atomic_store_p(&base->extent_hooks, extent_hooks, ATOMIC_RELEASE); in base_extent_hooks_set()
421 base_alloc_impl(tsdn_t *tsdn, base_t *base, size_t size, size_t alignment, in base_alloc_impl() argument
428 malloc_mutex_lock(tsdn, &base->mtx); in base_alloc_impl()
430 extent = extent_heap_remove_first(&base->avail[i]); in base_alloc_impl()
438 extent = base_extent_alloc(tsdn, base, usize, alignment); in base_alloc_impl()
446 ret = base_extent_bump_alloc(base, extent, usize, alignment); in base_alloc_impl()
451 malloc_mutex_unlock(tsdn, &base->mtx); in base_alloc_impl()
464 base_alloc(tsdn_t *tsdn, base_t *base, size_t size, size_t alignment) { in base_alloc() argument
465 return base_alloc_impl(tsdn, base, size, alignment, NULL); in base_alloc()
469 base_alloc_extent(tsdn_t *tsdn, base_t *base) { in base_alloc_extent() argument
471 extent_t *extent = base_alloc_impl(tsdn, base, sizeof(extent_t), in base_alloc_extent()
481 base_stats_get(tsdn_t *tsdn, base_t *base, size_t *allocated, size_t *resident, in base_stats_get() argument
485 malloc_mutex_lock(tsdn, &base->mtx); in base_stats_get()
486 assert(base->allocated <= base->resident); in base_stats_get()
487 assert(base->resident <= base->mapped); in base_stats_get()
488 *allocated = base->allocated; in base_stats_get()
489 *resident = base->resident; in base_stats_get()
490 *mapped = base->mapped; in base_stats_get()
491 *n_thp = base->n_thp; in base_stats_get()
492 malloc_mutex_unlock(tsdn, &base->mtx); in base_stats_get()
496 base_prefork(tsdn_t *tsdn, base_t *base) { in base_prefork() argument
497 malloc_mutex_prefork(tsdn, &base->mtx); in base_prefork()
501 base_postfork_parent(tsdn_t *tsdn, base_t *base) { in base_postfork_parent() argument
502 malloc_mutex_postfork_parent(tsdn, &base->mtx); in base_postfork_parent()
506 base_postfork_child(tsdn_t *tsdn, base_t *base) { in base_postfork_child() argument
507 malloc_mutex_postfork_child(tsdn, &base->mtx); in base_postfork_child()