-
Bug
-
Resolution: Duplicate
-
P4
-
21, 22
-
linux
If user enabled +UseTransparentHugePages, we do a sanity check to check support for THP:
```
bool os::Linux::transparent_huge_pages_sanity_check(bool warn,
size_t page_size) {
bool result = false;
void *p = mmap(nullptr, page_size * 2, PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE,
-1, 0);
if (p != MAP_FAILED) {
void *aligned_p = align_up(p, page_size);
result = madvise(aligned_p, page_size, MADV_HUGEPAGE) == 0;
munmap(p, page_size * 2);
}
if (warn && !result) {
warning("TransparentHugePages is not supported by the operating system.");
}
return result;
}
```
That does not work as expected. The madvice returns success even if THPs are disabled at the system level. As a result, the UseTransparentHugePages flag stays enabled:
```
thomas@starfish$ cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
thomas@starfish$ ./images/jdk/bin/java -XX:+UseTransparentHugePages -XX:+PrintFlagsFinal | grep Pages
bool LargePagesIndividualAllocationInjectError = false {develop} {default}
intx StackRedPages = 1 {pd product} {default}
intx StackReservedPages = 1 {pd product} {default}
intx StackShadowPages = 24 {pd product} {default}
intx StackYellowPages = 2 {pd product} {default}
bool UseLargePages = true {pd product} {default}
bool UseLargePagesIndividualAllocation = false {pd product} {default}
bool UseTransparentHugePages = true {product} {command line}
```
Also verified with gdb.
The real test would be to check /sys/kernel/mm/transparent_hugepage/enabled.
A variant of that problem is that we do workarounds meant for THP mode always, as inJDK-8303215. That also ties in with JDK-8310233.
So it seems THP setup needs some more TLC.
```
bool os::Linux::transparent_huge_pages_sanity_check(bool warn,
size_t page_size) {
bool result = false;
void *p = mmap(nullptr, page_size * 2, PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE,
-1, 0);
if (p != MAP_FAILED) {
void *aligned_p = align_up(p, page_size);
result = madvise(aligned_p, page_size, MADV_HUGEPAGE) == 0;
munmap(p, page_size * 2);
}
if (warn && !result) {
warning("TransparentHugePages is not supported by the operating system.");
}
return result;
}
```
That does not work as expected. The madvice returns success even if THPs are disabled at the system level. As a result, the UseTransparentHugePages flag stays enabled:
```
thomas@starfish$ cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
thomas@starfish$ ./images/jdk/bin/java -XX:+UseTransparentHugePages -XX:+PrintFlagsFinal | grep Pages
bool LargePagesIndividualAllocationInjectError = false {develop} {default}
intx StackRedPages = 1 {pd product} {default}
intx StackReservedPages = 1 {pd product} {default}
intx StackShadowPages = 24 {pd product} {default}
intx StackYellowPages = 2 {pd product} {default}
bool UseLargePages = true {pd product} {default}
bool UseLargePagesIndividualAllocation = false {pd product} {default}
bool UseTransparentHugePages = true {product} {command line}
```
Also verified with gdb.
The real test would be to check /sys/kernel/mm/transparent_hugepage/enabled.
A variant of that problem is that we do workarounds meant for THP mode always, as in
So it seems THP setup needs some more TLC.
- duplicates
-
JDK-8310233 Fix THP detection on Linux
- Resolved
- relates to
-
JDK-8310262 Remove hugetlbfs sanity checks
- Open
-
JDK-8310687 JDK-8303215 is incomplete
- Resolved
-
JDK-8310111 Shenandoah wastes memory when running with very large page sizes
- New