diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-08-13 08:36:29 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-12-15 17:35:14 -0300 |
commit | 5f6d8d97c69748180f0031dfa385aff75062c4d5 (patch) | |
tree | 97837a8eab4175385c32bacb10dc633b9070f266 /elf | |
parent | cb976fba4c51ede7bf8cee5035888527c308dfbc (diff) | |
download | glibc-5f6d8d97c69748180f0031dfa385aff75062c4d5.tar.gz glibc-5f6d8d97c69748180f0031dfa385aff75062c4d5.tar.xz glibc-5f6d8d97c69748180f0031dfa385aff75062c4d5.zip |
malloc: Add madvise support for Transparent Huge Pages
Linux Transparent Huge Pages (THP) current supports three different states: 'never', 'madvise', and 'always'. The 'never' is self-explanatory and 'always' will enable THP for all anonymous pages. However, 'madvise' is still the default for some system and for such case THP will be only used if the memory range is explicity advertise by the program through a madvise(MADV_HUGEPAGE) call. To enable it a new tunable is provided, 'glibc.malloc.hugetlb', where setting to a value diffent than 0 enables the madvise call. This patch issues the madvise(MADV_HUGEPAGE) call after a successful mmap() call at sysmalloc() with sizes larger than the default huge page size. The madvise() call is disable is system does not support THP or if it has the mode set to "never" and on Linux only support one page size for THP, even if the architecture supports multiple sizes. To test is a new rule is added tests-malloc-hugetlb1, which run the addes tests with the required GLIBC_TUNABLE setting. Checked on x86_64-linux-gnu. Reviewed-by: DJ Delorie <dj@redhat.com>
Diffstat (limited to 'elf')
-rw-r--r-- | elf/dl-tunables.list | 5 | ||||
-rw-r--r-- | elf/tst-rtld-list-tunables.exp | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/elf/dl-tunables.list b/elf/dl-tunables.list index ffcd7f18d4..d1fd3f3e91 100644 --- a/elf/dl-tunables.list +++ b/elf/dl-tunables.list @@ -92,6 +92,11 @@ glibc { minval: 0 security_level: SXID_IGNORE } + hugetlb { + type: INT_32 + minval: 0 + maxval: 1 + } } cpu { hwcap_mask { diff --git a/elf/tst-rtld-list-tunables.exp b/elf/tst-rtld-list-tunables.exp index 44e4834cfb..d8e363f2c5 100644 --- a/elf/tst-rtld-list-tunables.exp +++ b/elf/tst-rtld-list-tunables.exp @@ -1,6 +1,7 @@ glibc.malloc.arena_max: 0x0 (min: 0x1, max: 0x[f]+) glibc.malloc.arena_test: 0x0 (min: 0x1, max: 0x[f]+) glibc.malloc.check: 0 (min: 0, max: 3) +glibc.malloc.hugetlb: 0 (min: 0, max: 1) glibc.malloc.mmap_max: 0 (min: 0, max: 2147483647) glibc.malloc.mmap_threshold: 0x0 (min: 0x0, max: 0x[f]+) glibc.malloc.mxfast: 0x0 (min: 0x0, max: 0x[f]+) |