JDK-8366434 : THP not working properly with G1 after JDK-8345655
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 25
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-08-29
  • Updated: 2025-09-05
  • Resolved: 2025-09-04
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 26
26 b14Fixed
Related Reports
Causes :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8366564 :  
Description
In JDK-8345655 we refactored the memory reservation code to be more maintainable and easier to follow. When doing this one of the code paths changed to always pass in `os::vm_page_size()` where it previously had used a page size provided by the caller. 

Even if the alignment for `ReservedSpace`s created this way show that they should be aligned to support large pages the page size member for the `ReservedSpace` does not convey that we want large pages for the space. In G1 when using `G1PageBaseVirtualSpace` we use the above mentioned page size as the alignment for the reservation. This leads to the reservations (made using the API) not being THP eligible. 

This is only an issue when the system is configured with the THP mode of `madvise`. If the mode is `always`, we will get THP eligible reservations. So a fairly simple workaround for this issue (given you have access to configuring your system) is to configure the THP mode to always.

Comments
Changeset: a03302d4 Branch: master Author: Stefan Johansson <sjohanss@openjdk.org> Date: 2025-09-04 06:33:57 +0000 URL: https://git.openjdk.org/jdk/commit/a03302d41bb9971736d4d56381ca0cad1eb3e34b
04-09-2025

RT Triage: This is a huge page issue, transferring to GC.
02-09-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/27051 Date: 2025-09-02 13:53:13 +0000
02-09-2025