From 1497c447eacf136ad83eb33948e5fe9dd2f49e32 Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Fri, 24 Jul 2026 21:36:13 +0200 Subject: [PATCH] Downport himem test improvements from mainline --- .../os/linux/vitals_linux_oswrapper.cpp | 6 +++++- .../jtreg/runtime/Vitals/TestHiMemReport.java | 12 ++++++------ .../Vitals/TestHiMemReportArgParsing.java | 18 +++++++++--------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/hotspot/os/linux/vitals_linux_oswrapper.cpp b/src/hotspot/os/linux/vitals_linux_oswrapper.cpp index edff0ec368fa..30e06b8df090 100644 --- a/src/hotspot/os/linux/vitals_linux_oswrapper.cpp +++ b/src/hotspot/os/linux/vitals_linux_oswrapper.cpp @@ -101,6 +101,7 @@ class ProcFile { char* endptr = NULL; 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; @@ -124,7 +125,10 @@ class ProcFile { if (s != NULL) { 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 37110595ccdd..b5b2f8a3f25f 100644 --- a/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java +++ b/test/hotspot/jtreg/runtime/Vitals/TestHiMemReport.java @@ -98,7 +98,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 @@ -118,7 +118,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(), @@ -152,12 +152,12 @@ 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", 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()); @@ -260,7 +260,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(), @@ -307,7 +307,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();