Fix the VM over-reservation on aarch64 w/ larger pages.

HUGEPAGE could be larger on some platforms (e.g. 512M on aarch64 w/ 64K pages),
in which case it would cause grow_retained / exp_grow to over-reserve VMs.

Similarly, make sure the base alloc has a const 2M alignment.
This commit is contained in:
Qi Wang 2024-03-28 14:43:17 -07:00 committed by Qi Wang
parent baa5a90cc6
commit cd05b19f10
3 changed files with 36 additions and 10 deletions

View file

@ -3,6 +3,12 @@
void
exp_grow_init(exp_grow_t *exp_grow) {
exp_grow->next = sz_psz2ind(HUGEPAGE);
/*
* Enforce a minimal of 2M grow, which is convenient for the huge page
* use cases. Avoid using HUGEPAGE as the value though, because on some
* platforms it can be very large (e.g. 512M on aarch64 w/ 64K pages).
*/
const size_t min_grow = (size_t)2 << 20;
exp_grow->next = sz_psz2ind(min_grow);
exp_grow->limit = sz_psz2ind(SC_LARGE_MAXCLASS);
}