From 1dfc9186fb15693d2409cc0427f56c8136809030 Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Fri, 24 Jul 2026 14:47:57 +0200 Subject: [PATCH 1/2] Downport himem test improvements from mainline --- .../os/linux/vitals_linux_oswrapper.cpp | 6 +++++- .../jtreg/runtime/Vitals/TestHiMemReport.java | 10 +++++----- .../Vitals/TestHiMemReportArgParsing.java | 18 +++++++++--------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/hotspot/os/linux/vitals_linux_oswrapper.cpp b/src/hotspot/os/linux/vitals_linux_oswrapper.cpp index 639e77841ebd..a3d997dd6a45 100644 --- a/src/hotspot/os/linux/vitals_linux_oswrapper.cpp +++ b/src/hotspot/os/linux/vitals_linux_oswrapper.cpp @@ -97,6 +97,7 @@ class ProcFile { char* endptr = nullptr; value = (value_t)::strtoll(text, &endptr, 10); if (endptr == text || errno != 0) { + log_debug(vitals, os)("Failed to parse \"%s\"", text); value = INVALID_VALUE; } else { value *= scale; @@ -120,7 +121,10 @@ class ProcFile { if (s != nullptr) { errno = 0; const char* p = s + ::strlen(prefix); - return as_value(p, scale); + value = as_value(p, scale); + log_trace(vitals, os)("Reading \"%s\": %llu", prefix, (unsigned long long) value); + } else { + log_debug(vitals, os)("Could not find prefix \"%s\"", prefix); } return value; } diff --git a/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java b/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java index f7434151dad5..c770e0ea0665 100644 --- a/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java +++ b/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java @@ -100,7 +100,7 @@ static void testPrint() throws Exception { ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:+HiMemReport", "-XX:HiMemReportMax=64m", "-XX:NativeMemoryTracking=summary", - "-Xlog:vitals=trace", "-XX:+PrintVitalsAtExit", "-XX:VitalsSampleInterval=1", + "-Xlog:vitals=trace,vitals+os=trace", "-XX:+PrintVitalsAtExit", "-XX:VitalsSampleInterval=1", "-Xmx128m", "-Xms128m", "-XX:+AlwaysPreTouch", TestHiMemReport.class.getName(), "sleep", "2" // num seconds to sleep to give the reporter thread time to generate output @@ -120,7 +120,7 @@ static void testDump() throws Exception { ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:+HiMemReport", "-XX:HiMemReportMax=64m", "-XX:NativeMemoryTracking=summary", - "-Xlog:vitals=trace", "-XX:+PrintVitalsAtExit", "-XX:VitalsSampleInterval=1", + "-Xlog:vitals=trace,vitals+os=trace", "-XX:+PrintVitalsAtExit", "-XX:VitalsSampleInterval=1", "-XX:HiMemReportDir=himemreport-1", "-Xmx128m", "-Xms128m", "-XX:+AlwaysPreTouch", TestHiMemReport.class.getName(), @@ -154,7 +154,7 @@ static void testDumpWithExecToReportDir() throws Exception { ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:+HiMemReport", "-XX:HiMemReportMax=64m", "-XX:HiMemReportDir=himemreport-2", - "-Xlog:vitals=trace", "-XX:+PrintVitalsAtExit", "-XX:VitalsSampleInterval=1", + "-Xlog:vitals=trace,vitals+os=trace", "-XX:+PrintVitalsAtExit", "-XX:VitalsSampleInterval=1", "-XX:HiMemReportExec=VM.flags -all;VM.metaspace show-loaders;GC.heap_dump", "-XX:NativeMemoryTracking=summary", "-Xmx128m", "-Xms128m", "-XX:+AlwaysPreTouch", @@ -262,7 +262,7 @@ static void testDumpWithExecToStderr() throws Exception { ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:+HiMemReport", "-XX:HiMemReportMax=64m", "-XX:HiMemReportExec=VM.flags -all;VM.metaspace show-loaders", - "-Xlog:vitals=trace", "-XX:+PrintVitalsAtExit", "-XX:VitalsSampleInterval=1", + "-Xlog:vitals=trace,vitals+os=trace", "-XX:+PrintVitalsAtExit", "-XX:VitalsSampleInterval=1", "-XX:NativeMemoryTracking=summary", "-Xmx128m", "-Xms128m", "-XX:+AlwaysPreTouch", TestHiMemReport.class.getName(), @@ -309,7 +309,7 @@ static void testDumpWithExecToStderr() throws Exception { static void testHasNaturalMax() throws IOException { ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:+PrintVitalsAtExit", "-XX:VitalsSampleInterval=1", - "-XX:+HiMemReport", "-Xlog:vitals=trace", "-Xmx64m", "-version"); + "-XX:+HiMemReport", "-Xlog:vitals=trace,vitals+os=trace", "-Xmx64m", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldNotMatch("HiMemReport.*limit could not be established"); diff --git a/test/hotspot/jtreg/runtime/Vitals/TestHiMemReportArgParsing.java b/test/hotspot/jtreg/runtime/Vitals/TestHiMemReportArgParsing.java index 96b3ba3a8d5a..7f993b99fffa 100644 --- a/test/hotspot/jtreg/runtime/Vitals/TestHiMemReportArgParsing.java +++ b/test/hotspot/jtreg/runtime/Vitals/TestHiMemReportArgParsing.java @@ -78,8 +78,8 @@ static void testValidNonExistingReportDir() throws IOException { File subdir = VitalsUtils.createSubTestDir("test-outputdir-1", false); VitalsUtils.fileShouldNotExist(subdir); ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( - "-XX:+HiMemReport", "-XX:HiMemReportDir=" + subdir.getAbsolutePath(), "-Xlog:vitals", - "-Xmx64m", "-version"); + "-XX:+HiMemReport", "-XX:HiMemReportDir=" + subdir.getAbsolutePath(), + "-Xlog:vitals=trace,vitals+os=trace", "-Xmx64m", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.reportDiagnosticSummary(); output.shouldHaveExitValue(0); @@ -97,8 +97,8 @@ static void testValidExistingReportDir() throws IOException { File subdir = VitalsUtils.createSubTestDir("test-outputdir-2", true); VitalsUtils.fileShouldExist(subdir); ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( - "-XX:+HiMemReport", "-XX:HiMemReportDir=" + subdir.getAbsolutePath(), "-Xlog:vitals", - "-Xmx64m", "-version"); + "-XX:+HiMemReport", "-XX:HiMemReportDir=" + subdir.getAbsolutePath(), + "-Xlog:vitals=trace,vitals+os=trace", "-Xmx64m", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.reportDiagnosticSummary(); output.shouldHaveExitValue(0); @@ -117,8 +117,8 @@ static void testInValidReportDir() throws IOException { File f = new File("/tmp/gibsnicht/gibsnicht/gibsnicht"); VitalsUtils.fileShouldNotExist(f); ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( - "-XX:+HiMemReport", "-XX:HiMemReportDir=" + f.getAbsolutePath(), "-Xlog:vitals", - "-Xmx64m", "-version"); + "-XX:+HiMemReport", "-XX:HiMemReportDir=" + f.getAbsolutePath(), + "-Xlog:vitals=trace,vitals+os=trace", "-Xmx64m", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.reportDiagnosticSummary(); output.shouldNotHaveExitValue(0); @@ -134,7 +134,7 @@ static void testInValidReportDir() throws IOException { */ static void testHiMemReportOn() throws IOException { ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( - "-XX:+HiMemReport", "-Xlog:vitals", + "-XX:+HiMemReport", "-Xlog:vitals=trace,vitals+os=trace", "-Xmx64m", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.reportDiagnosticSummary(); @@ -150,7 +150,7 @@ static void testHiMemReportOn() throws IOException { */ static void testHiMemReportOff() throws IOException { ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( - "-XX:-HiMemReport", "-Xlog:vitals", + "-XX:-HiMemReport", "-Xlog:vitals=trace,vitals+os=trace", "-Xmx64m", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.reportDiagnosticSummary(); @@ -163,7 +163,7 @@ static void testHiMemReportOff() throws IOException { */ static void testHiMemReportOffByDefault() throws IOException { ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( - "-Xlog:vitals", + "-Xlog:vitals=trace,vitals+os=trace", "-Xmx64m", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.reportDiagnosticSummary(); From 1b1d630fc29e28b76acb2dfc302b128f79dd9078 Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Fri, 24 Jul 2026 17:40:50 +0200 Subject: [PATCH 2/2] In crease GC dump timeout since we have more log output. --- test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java b/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java index c770e0ea0665..569ac46f872c 100644 --- a/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java +++ b/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java @@ -159,7 +159,7 @@ static void testDumpWithExecToReportDir() throws Exception { "-XX:NativeMemoryTracking=summary", "-Xmx128m", "-Xms128m", "-XX:+AlwaysPreTouch", TestHiMemReport.class.getName(), - "sleep", "12" // num seconds to sleep to give the reporter thread time to generate output + "sleep", "30" // num seconds to sleep to give the reporter thread time to generate output ); OutputAnalyzer output = new OutputAnalyzer(pb.start());