Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3977,6 +3977,17 @@ void os::Linux::large_page_init() {
// Query OS information first.
HugePages::initialize();

// SapMachine 2025-12-10 Enable UseTransparentHugePages if supported and the huge pages
// are not extremely large and no other configuration is selected by flags.
// Some GCs have additional requirements, are optimized for ultra-low latency or
// have limitations regarding configuration parameters with small heap sizes.
if (FLAG_IS_DEFAULT(UseLargePages) && FLAG_IS_DEFAULT(UseTransparentHugePages) &&
HugePages::supports_thp() && HugePages::thp_pagesize() <= 2*M &&
!UseZGC && !UseShenandoahGC &&
(FLAG_IS_DEFAULT(MaxHeapSize) || MaxHeapSize > 128*M)) {
_thp_requested = UseTransparentHugePages = true;
}

// If THPs are unconditionally enabled (THP mode "always"), khugepaged may attempt to
// coalesce small pages in thread stacks to huge pages. That costs a lot of memory and
// is usually unwanted for thread stacks. Therefore we attempt to prevent THP formation in
Expand Down
10 changes: 7 additions & 3 deletions src/java.base/share/man/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# SapMachine 2025-12-10 Changed description of UseTransparentHugePages which is
# tested by us.

title: 'JAVA(1) JDK @@VERSION_SHORT@@ | JDK Commands'
date: @@COPYRIGHT_YEAR@@
Expand Down Expand Up @@ -1576,9 +1578,11 @@ These `java` options control the runtime behavior of the Java HotSpot VM.

`-XX:+UseTransparentHugePages`
: **Linux only:** Enables the use of large pages that can dynamically grow or
shrink. This option is disabled by default. You may encounter performance
problems with transparent huge pages as the OS moves other pages around to
create huge pages; this option is made available for experimentation.
shrink. The VM may enable this option by default in some environments. You
may encounter performance problems with transparent huge pages as the OS
moves other pages around to create huge pages. You may encounter other
performance problems when only small pages are used as the OS needs to
maintain a large page table and address translations may become slow.

`-XX:+AllowUserSignalHandlers`
: **Non-Windows:** Enables installation of signal handlers by the application. By default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,13 @@ public static void main(String[] args) throws Exception {

// Reserved code cache is set, NonNmethod segment size is set, two other segments is automatically
// adjusted to half of the remaining space
// SapMachine 2025-12-10 We support 2MB transparent huge pages, so we need a multiple of it.
pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+SegmentedCodeCache",
"-XX:ReservedCodeCacheSize=100M",
"-XX:ReservedCodeCacheSize=102M", // original: 100M
"-XX:NonNMethodCodeHeapSize=10M",
"-XX:+PrintFlagsFinal",
"-version");
verifyCodeHeapSize(pb, " ProfiledCodeHeapSize", 47185920);
verifyCodeHeapSize(pb, " ProfiledCodeHeapSize", 48234496); // = 46M, original: 47185920

// Reserved code cache is set but NonNmethodCodeHeapSize is not set.
// It's calculated based on the number of compiler threads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,34 @@ public void run(CodeCacheCLITestCase.Description testCaseDescription,
Long.toString(expectedValues.reserved),
String.format("%s should have value %d.",
BlobType.All.sizeOptionName, expectedValues.reserved),
testCaseDescription.getTestOptions(options));
// SapMachine 2025-12-10 We don't get exact matches when rounding to large page sizes.
testCaseDescription.getTestOptions(options, "-XX:-UseLargePages"));

CommandLineOptionTest.verifyOptionValueForSameVM(
BlobType.NonNMethod.sizeOptionName,
Long.toString(expectedValues.nonNmethods),
String.format("%s should have value %d.",
BlobType.NonNMethod.sizeOptionName,
expectedValues.nonNmethods),
testCaseDescription.getTestOptions(options));
// SapMachine 2025-12-10 We don't get exact matches when rounding to large page sizes.
testCaseDescription.getTestOptions(options, "-XX:-UseLargePages"));

CommandLineOptionTest.verifyOptionValueForSameVM(
BlobType.MethodNonProfiled.sizeOptionName,
Long.toString(expectedValues.nonProfiled),
String.format("%s should have value %d.",
BlobType.MethodNonProfiled.sizeOptionName,
expectedValues.nonProfiled),
testCaseDescription.getTestOptions(options));
// SapMachine 2025-12-10 We don't get exact matches when rounding to large page sizes.
testCaseDescription.getTestOptions(options, "-XX:-UseLargePages"));

CommandLineOptionTest.verifyOptionValueForSameVM(
BlobType.MethodProfiled.sizeOptionName,
Long.toString(expectedValues.profiled),
String.format("%s should have value %d.",
BlobType.MethodProfiled.sizeOptionName,
expectedValues.profiled),
testCaseDescription.getTestOptions(options));
// SapMachine 2025-12-10 We don't get exact matches when rounding to large page sizes.
testCaseDescription.getTestOptions(options, "-XX:-UseLargePages"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
* questions.
*/

// SapMachine 2025-12-10 We use UseTransparentHugePages in some configurations.
/*
* @test id=Default
* @summary Test JVM large page setup (default options)
* @library /test/lib
* @requires os.family == "linux"
* @modules java.base/jdk.internal.misc
* java.management
* @run driver TestHugePageDecisionsAtVMStartup
* @run driver TestHugePageDecisionsAtVMStartup -XX:-UseTransparentHugePages
*/

/*
Expand Down