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

@ -6,6 +6,12 @@
#include "jemalloc/internal/ehooks.h"
#include "jemalloc/internal/mutex.h"
/*
* Alignment when THP is not enabled. Set to constant 2M in case the HUGEPAGE
* value is unexpected high (which would cause VM over-reservation).
*/
#define BASE_BLOCK_MIN_ALIGN ((size_t)2 << 20)
enum metadata_thp_mode_e {
metadata_thp_disabled = 0,
/*
@ -26,7 +32,6 @@ typedef enum metadata_thp_mode_e metadata_thp_mode_t;
extern metadata_thp_mode_t opt_metadata_thp;
extern const char *const metadata_thp_mode_names[];
/* Embedded at the beginning of every block of base-managed virtual memory. */
typedef struct base_block_s base_block_t;
struct base_block_s {