JDK-8259495 : Collectors do not use 1g large pages in absence of 2m large pages for heap
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 17
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • Submitted: 2021-01-08
  • Updated: 2024-04-08
  • Resolved: 2024-04-08
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
23Resolved
Related Reports
Relates :  
Description
When trying to use 1g pages without any 2m large pages (using numbers for x64 linux, other archs should be the same) available, the request to do so fails. Only if you have reserved enough 2m pages to cover the entire heap the VM uses 1g pages. E.g.

set
/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages = 30
/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages = 0

Running G1 with:

$ java -Xmx20g -Xms20g -XX:+UseLargePages -XX:LargePageSizeInBytes=1g -XX:+PrintFlagsFinal -XX:+AlwaysPreTouch -XX:+UseG1GC Hello

OpenJDK 64-Bit Server VM warning: Failed to reserve shared memory. (error = 1) <----- !!
[0.058s][warning][gc] Pretouch size 21474836480 chunk size 4194304 page size 4096 <----- !!
[0.403s][warning][gc] Pretouch size 335544320 chunk size 4194304 page size 4096
[0.411s][warning][gc] Pretouch size 335544320 chunk size 4194304 page size 4096
[0.418s][warning][gc] Pretouch size 41943040 chunk size 4194304 page size 4096
[0.420s][warning][gc] Pretouch size 41943040 chunk size 4194304 page size 4096
[0.427s][warning][gc] Pretouch size 41943040 chunk size 4194304 page size 4096
<waits for input>

(and in another console look:
$ cat hugepages-1048576kB/free_hugepages
30
$ cat hugepages-2048kb/free_hugepages
0

Set /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages to 13000 (covering the 20gb too):

[0.001s][warning][gc] LargePageSizeInBytes=1073741824 large_page_size 1073741824 
[0.056s][warning][gc] Pretouch size 21474836480 chunk size 1073741824 page size 1073741824 <---- !!
[0.999s][warning][gc] Pretouch size 335544320 chunk size 4194304 page size 4096
[1.009s][warning][gc] Pretouch size 335544320 chunk size 4194304 page size 4096
[1.017s][warning][gc] Pretouch size 41943040 chunk size 4194304 page size 4096
[1.020s][warning][gc] Pretouch size 41943040 chunk size 4194304 page size 4096
[1.030s][warning][gc] Pretouch size 41943040 chunk size 4194304 page size 4096

$ cat hugepages-1048576kB/free_hugepages 10 (i.e. 20 allocated)
$ cat hugepages-2048kb/free_hugepages 13000

Maybe an OS specific issue, i.e. maybe this is how it's supposed to work, that you have to provide both 2M and 1g large pages in such cases. If so, this issue can be closed.
Comments
Everything seems to work fine on master (jdk 23).
08-04-2024

It is actually sufficient to have enough 2m pages in nr_overcommit_hugepages to make the VM use 1g pages in that case.
11-01-2021