JDK-8319795 : Static huge pages are not used for CodeCache
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 22
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-11-09
  • Updated: 2024-01-04
  • Resolved: 2023-12-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 23
23 b04Fixed
Related Reports
Relates :  
Relates :  
Description
This is a regression introduced by JDK-8261894.
It modified `os::can_execute_large_page_memory`:
```
bool os::can_execute_large_page_memory() {
-  return UseTransparentHugePages || UseHugeTLBFS;
+  return UseTransparentHugePages;
}
```

CodeCache::page_size uses `os::can_execute_large_page_memory` to detect page sizes. It fails when static huge pages are used. This results static huge pages are not used for CodeCache.

The correct code should be:
```
bool os::can_execute_large_page_memory() {
  return UseLargePages;
}
```

Here is a log showing static huge pages are used for the Java heap but not for CodeCache.

```
% uname -r -s
Linux 5.4.258-178.360.amzn2int.x86_64
% cat /proc/meminfo | grep -i huge
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
FileHugePages:         0 kB
HugePages_Total:     100
HugePages_Free:      100
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:          204800 kB
% bin/java -Xms100m -Xmx100m -XX:-TieredCompilation -XX:InitialCodeCacheSize=48m -XX:+UseLargePages -Xlog:pagesize=info -version
[0.001s][info][pagesize] Static hugepage support:
[0.001s][info][pagesize]   hugepage size: 2M
[0.001s][info][pagesize]   hugepage size: 1G
[0.001s][info][pagesize]   default hugepage size: 2M
[0.001s][info][pagesize] Transparent hugepage (THP) support:
[0.001s][info][pagesize]   THP mode: madvise
[0.001s][info][pagesize]   THP pagesize: 2M
[0.001s][info][pagesize] Using the default large page size: 2M
[0.001s][info][pagesize] UseLargePages=1, UseTransparentHugePages=0
[0.001s][info][pagesize] Large page support enabled. Usable page sizes: 4k, 2M. Default large page size: 2M.
[0.002s][info][pagesize] CodeCache:  min=48M max=48M base=0x00007f3d60ad4000 size=48M page_size=4K
[0.089s][info][pagesize] Heap:  min=100M max=100M base=0x00000000f9c00000 size=100M page_size=2M
[0.089s][info][pagesize] Block Offset Table: req_size=200K req_page_size=4K base=0x00007f3d60098000 size=200K page_size=4K
[0.089s][info][pagesize] Card Table: req_size=200K req_page_size=4K base=0x00007f3d60066000 size=200K page_size=4K
[0.089s][info][pagesize] Mark Bitmap: req_size=1600K req_page_size=4K base=0x00007f3d5893b000 size=1600K page_size=4K
openjdk version "22-internal" 2024-03-19
OpenJDK Runtime Environment (fastdebug build 22-internal-adhoc.eastig.jdk)
OpenJDK 64-Bit Server VM (fastdebug build 22-internal-adhoc.eastig.jdk, mixed mode)
```

Comments
Changeset: 3b908c47 Author: Evgeny Astigeevich <eastigeevich@openjdk.org> Date: 2023-12-21 18:51:50 +0000 URL: https://git.openjdk.org/jdk/commit/3b908c478186cbfd9d449422aaa5adacd5e5c2d4
21-12-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16582 Date: 2023-11-09 15:20:26 +0000
09-11-2023

Customers having a lot of compiled code and using static huge pages are impacted. Their performance will be affected. They can use THP as a workaround but this will imply THP to the Java heap. The workaround might cause performance degradations due to the dynamic nature of THP. ILW=MMM => P3
09-11-2023