| 141 | } |
| 142 | |
| 143 | static void |
| 144 | base_auto_thp_switch(tsdn_t *tsdn, base_t *base) { |
| 145 | assert(opt_metadata_thp == metadata_thp_auto); |
| 146 | malloc_mutex_assert_owner(tsdn, &base->mtx); |
| 147 | if (base->auto_thp_switched) { |
| 148 | return; |
| 149 | } |
| 150 | /* Called when adding a new block. */ |
| 151 | bool should_switch; |
| 152 | if (base_ind_get(base) != 0) { |
| 153 | should_switch = (base_get_num_blocks(base, true) == |
| 154 | BASE_AUTO_THP_THRESHOLD); |
| 155 | } else { |
| 156 | should_switch = (base_get_num_blocks(base, true) == |
| 157 | BASE_AUTO_THP_THRESHOLD_A0); |
| 158 | } |
| 159 | if (!should_switch) { |
| 160 | return; |
| 161 | } |
| 162 | |
| 163 | base->auto_thp_switched = true; |
| 164 | assert(!config_stats || base->n_thp == 0); |
| 165 | /* Make the initial blocks THP lazily. */ |
| 166 | base_block_t *block = base->blocks; |
| 167 | while (block != NULL) { |
| 168 | assert((block->size & HUGEPAGE_MASK) == 0); |
| 169 | pages_huge(block, block->size); |
| 170 | if (config_stats) { |
| 171 | base->n_thp += HUGEPAGE_CEILING(block->size - |
| 172 | extent_bsize_get(&block->extent)) >> LG_HUGEPAGE; |
| 173 | } |
| 174 | block = block->next; |
| 175 | assert(block == NULL || (base_ind_get(base) == 0)); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | static void * |
| 180 | base_extent_bump_alloc_helper(extent_t *extent, size_t *gap_size, size_t size, |
no test coverage detected