* Allocate an extent that is at least as large as specified size, with * specified alignment. */
| 305 | * specified alignment. |
| 306 | */ |
| 307 | static extent_t * |
| 308 | base_extent_alloc(tsdn_t *tsdn, base_t *base, size_t size, size_t alignment) { |
| 309 | malloc_mutex_assert_owner(tsdn, &base->mtx); |
| 310 | |
| 311 | extent_hooks_t *extent_hooks = base_extent_hooks_get(base); |
| 312 | /* |
| 313 | * Drop mutex during base_block_alloc(), because an extent hook will be |
| 314 | * called. |
| 315 | */ |
| 316 | malloc_mutex_unlock(tsdn, &base->mtx); |
| 317 | base_block_t *block = base_block_alloc(tsdn, base, extent_hooks, |
| 318 | base_ind_get(base), &base->pind_last, &base->extent_sn_next, size, |
| 319 | alignment); |
| 320 | malloc_mutex_lock(tsdn, &base->mtx); |
| 321 | if (block == NULL) { |
| 322 | return NULL; |
| 323 | } |
| 324 | block->next = base->blocks; |
| 325 | base->blocks = block; |
| 326 | if (config_stats) { |
| 327 | base->allocated += sizeof(base_block_t); |
| 328 | base->resident += PAGE_CEILING(sizeof(base_block_t)); |
| 329 | base->mapped += block->size; |
| 330 | if (metadata_thp_madvise() && |
| 331 | !(opt_metadata_thp == metadata_thp_auto |
| 332 | && !base->auto_thp_switched)) { |
| 333 | assert(base->n_thp > 0); |
| 334 | base->n_thp += HUGEPAGE_CEILING(sizeof(base_block_t)) >> |
| 335 | LG_HUGEPAGE; |
| 336 | } |
| 337 | assert(base->allocated <= base->resident); |
| 338 | assert(base->resident <= base->mapped); |
| 339 | assert(base->n_thp << LG_HUGEPAGE <= base->mapped); |
| 340 | } |
| 341 | return &block->extent; |
| 342 | } |
| 343 | |
| 344 | base_t * |
| 345 | b0get(void) { |
no test coverage detected