JDK-8304954 : SegmentedCodeCache fails when using large pages
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,17,21
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-03-27
  • Updated: 2024-05-22
  • Resolved: 2023-07-28
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 17 JDK 21 JDK 22
17.0.10-oracleFixed 21.0.1Fixed 22 b09Fixed
Related Reports
Relates :  
Description
When large pages are enabled, the VM tries to use at least one page for all code cache segments which fails if there is not enough space:

$ java -XX:+UseLargePages -XX:+SegmentedCodeCache -XX:InitialCodeCacheSize=2g -XX:ReservedCodeCacheSize=2g -XX:LargePageSizeInBytes=1g -Xlog:pagesize*=debug -version
[0.000s][debug][pagesize] Large Page sizes: 2M, 1G
[0.000s][info ][pagesize] Overriding default large page size (2M) using LargePageSizeInBytes: 1G
[0.001s][info ][pagesize] Usable page sizes: 4k, 2M, 1G
[0.003s][debug][pagesize] Commit special mapping: 0x00007fefc0000000, size=2G, page size=1G
[0.003s][info ][pagesize] CodeHeap 'non-nmethods':  min=1G max=6M base=0x00007fefffc00000 page_size=1G size=6M
Error occurred during initialization of VM
Could not reserve enough space in CodeHeap 'non-nmethods' (6144K)

We should not exit them VM but fall back to a smaller page size for the failing segment.

Thanks to Scott Oaks for reporting.
Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/1734 Date: 2023-09-13 12:28:10 +0000
13-09-2023

Fix request [17u] I backport this for parity with 17.0.10-oracle. Medium risk as fuddling with memory. Trivial resolve needed. Test passes.
13-09-2023

Thanks Vladimir, corrected.
07-08-2023

[~thartmann] The fix request and PR says JDK 21u but label is jdk21-fix-request
04-08-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u/pull/41 Date: 2023-08-04 10:18:48 +0000
04-08-2023

Fix Request (21u): Fixes support for large pages in the code cache. The fix is low risk, applies cleanly and includes a regression test. Tested with tier 1 - 3.
04-08-2023

Changeset: cad6114e Author: Damon Fenacci <dfenacci@openjdk.org> Date: 2023-07-28 09:09:48 +0000 URL: https://git.openjdk.org/jdk/commit/cad6114e1c69bfebe5f7892c3e105b4c70d04398
28-07-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/14903 Date: 2023-07-17 13:34:55 +0000
20-07-2023

Raising priority because this was reported again.
06-07-2023

ILW = VM exits when failing to reserve memory for code cache segment, with large pages and a large code cache size, disable segmented code cache or increase reserved code cache size = HLL = P4
27-03-2023