-
Bug
-
Resolution: Fixed
-
P4
-
21, 22
-
b07
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8314918 | 21.0.1 | Thomas Stuefe | P4 | Resolved | Fixed | b09 |
JDK-8321019 | 17.0.11-oracle | Poonam Bajaj Parhar | P4 | Resolved | Fixed | b01 |
JDK-8315349 | 17.0.10 | Thomas Stuefe | P4 | Resolved | Fixed | b01 |
- that THPs use the page size (in hotspot used as "default large page size") found in /proc/memlimit Hugepagesize)
- that THPs are enabled if that page size is >0.
Both assumptions are incorrect. THPs are enabled depending on the mode in `/sys/kernel/mm/transparent_hugepage/enabled` (tri-state). And the pagesize used by khugepaged is the one set in `/sys/kernel/mm/transparent_hugepage/hpage_pmd_size`. The latter can differ from the default large page size on the system (e.g. static hugepage default size could be 1g, whereas THP hugepage size is 2m).
-------------
Example 1: System has THPs disabled, but static hugepages (1g, 2m) configured:
```
thomas@starfish $ cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
thomas@starfish $ cat /proc/meminfo | grep Hugepage
Hugepagesize: 1048576 kB
```
We incorrectly assume THPs are enabled, and that THP page size is 1G (!), which we then proceed and use as heap page size, causing the heap size to be rounded up from 512m -> 1G:
```
thomas@starfish $ ./images/jdk/bin/java -Xmx512m -XX:+UseLargePages -XX:+UseTransparentHugePages -Xlog:pagesize -version
[0.001s][info][pagesize] Using the default large page size: 1G
[0.001s][info][pagesize] Usable page sizes: 4k, 2M, 1G
...
[0.016s][info][pagesize] Heap: min=1G max=1G base=0x00000000c0000000 size=1G page_size=1G
```
----------
Example 2: System has THPs enabled, but THP page size is just *2M*, whereas the system uses a static default hugepage size of *1G*:
```
thomas@starfish $ cat /sys/kernel/mm/transparent_hugepage/enabled
always [madvise] never
thomas@starfish $ cat /sys/kernel/mm/transparent_hugepage/hpage_pmd_size
2097152
thomas@starfish $ cat /proc/meminfo | grep Hugepage
Hugepagesize: 1048576 kB
```
WTHP page size is not correctly recognized as 2M. Instead, we again use 1G as page size for the heap:
```
thomas@starfish $ ./images/jdk/bin/java -Xmx512m -XX:+UseLargePages -XX:+UseTransparentHugePages -Xlog:pagesize -version
[0.001s][info][pagesize] Using the default large page size: 1G
[0.001s][info][pagesize] Usable page sizes: 4k, 2M, 1G
...
[0.010s][info][pagesize] Heap: min=1G max=1G base=0x00000000c0000000 size=1G page_size=1G
```
- backported by
-
JDK-8314918 Fix THP detection on Linux
- Resolved
-
JDK-8315349 Fix THP detection on Linux
- Resolved
-
JDK-8321019 Fix THP detection on Linux
- Resolved
- duplicates
-
JDK-8310295 runtime/os/TestTracePageSizes.java fails on machines with 1G pages configured
- Closed
-
JDK-8310261 Linux: THPs enabled even if system support missing
- Closed
- relates to
-
JDK-8312394 [linux] SIGSEGV if kernel was built without hugepage support
- Resolved
-
JDK-8312620 WSL Linux build crashes after JDK-8310233
- Resolved
-
JDK-8312366 [arm32] Build crashes after JDK-8310233
- Closed
-
JDK-8310262 Remove hugetlbfs sanity checks
- Open
-
JDK-8312182 THPs cause huge RSS due to thread start timing issue
- Resolved
-
JDK-8310687 JDK-8303215 is incomplete
- Resolved
- links to
-
Commit openjdk/jdk17u-dev/36817195
-
Commit openjdk/jdk21u/d6a4e469
-
Commit openjdk/jdk/37ca9024
-
Review openjdk/jdk11u-dev/2086
-
Review openjdk/jdk17u-dev/1679
-
Review openjdk/jdk17u-dev/1694
-
Review openjdk/jdk21u/60
-
Review openjdk/jdk/14739