Add arena.i.retain_grow_limit

This option controls the max size when grow_retained.  This is useful when we
have customized extent hooks reserving physical memory (e.g. 1G huge pages).
Without this feature, the default increasing sequence could result in fragmented
and wasted physical memory.
This commit is contained in:
Qi Wang 2017-11-02 17:48:39 -07:00 committed by Qi Wang
parent 9f455e2786
commit e422fa8e7e
8 changed files with 146 additions and 5 deletions

View file

@ -1284,13 +1284,14 @@ extent_grow_retained(tsdn_t *tsdn, arena_t *arena,
}
/*
* Increment extent_grow_next if doing so wouldn't exceed the legal
* Increment extent_grow_next if doing so wouldn't exceed the allowed
* range.
*/
if (arena->extent_grow_next + egn_skip + 1 < NPSIZES) {
if (arena->extent_grow_next + egn_skip + 1 <=
arena->retain_grow_limit) {
arena->extent_grow_next += egn_skip + 1;
} else {
arena->extent_grow_next = NPSIZES - 1;
arena->extent_grow_next = arena->retain_grow_limit;
}
/* All opportunities for failure are past. */
malloc_mutex_unlock(tsdn, &arena->extent_grow_mtx);