From f2b10c6c228f7be879b3f043accb22e0bc6535d6 Mon Sep 17 00:00:00 2001 From: Axel Boldt-Christmas Date: Thu, 21 Nov 2024 09:54:25 +0000 Subject: [PATCH] 8340422: ZGC: TestAllocateHeapAt.java should not run with transparent hugepages Reviewed-by: stefank, jsikstro --- test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java | 11 +++++++++++ .../os/THPsInThreadStackPreventionTest.java | 3 +++ .../os/TestHugePageDecisionsAtVMStartup.java | 2 ++ .../jtreg/runtime/os/TestHugePageDetection.java | 2 ++ test/jtreg-ext/requires/VMProps.java | 1 + .../lib/os/linux}/HugePageConfiguration.java | 17 ++++++++++++++--- 6 files changed, 33 insertions(+), 3 deletions(-) rename test/{hotspot/jtreg/runtime/os => lib/jdk/test/lib/os/linux}/HugePageConfiguration.java (96%) diff --git a/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java b/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java index dbcca704fab..f960ac3a547 100644 --- a/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java +++ b/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java @@ -27,13 +27,17 @@ package gc.z; * @test TestAllocateHeapAt * @requires vm.gc.Z & os.family == "linux" * @requires !vm.opt.final.UseLargePages + * @requires !vm.opt.final.UseTransparentHugePages * @summary Test ZGC with -XX:AllocateHeapAt * @library /test/lib * @run main/othervm gc.z.TestAllocateHeapAt . true * @run main/othervm gc.z.TestAllocateHeapAt non-existing-directory false */ +import jdk.test.lib.os.linux.HugePageConfiguration; +import jdk.test.lib.os.linux.HugePageConfiguration.ShmemTHPMode; import jdk.test.lib.process.ProcessTools; +import jtreg.SkippedException; public class TestAllocateHeapAt { public static void main(String[] args) throws Exception { @@ -42,6 +46,13 @@ public class TestAllocateHeapAt { final String heapBackingFile = "Heap Backing File: " + directory; final String failedToCreateFile = "Failed to create file " + directory; + final HugePageConfiguration hugePageConfiguration = HugePageConfiguration.readFromOS(); + final ShmemTHPMode mode = hugePageConfiguration.getShmemThpMode(); + + if (mode != ShmemTHPMode.never && mode != ShmemTHPMode.advise) { + throw new SkippedException("The UseTransparentHugePages option may not be respected with Shmem THP Mode: " + mode.name()); + } + ProcessTools.executeTestJava( "-XX:+UseZGC", "-Xlog:gc*", diff --git a/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java b/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java index 519bcc94b01..02fb77bf242 100644 --- a/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java +++ b/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java @@ -45,10 +45,13 @@ * @requires os.family == "linux" * @requires vm.debug * @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="aarch64" + * @library /test/lib * @modules java.base/jdk.internal.misc * java.management * @run main/manual THPsInThreadStackPreventionTest PATCH-DISABLED */ + +import jdk.test.lib.os.linux.HugePageConfiguration; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import jtreg.SkippedException; diff --git a/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java b/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java index daf1269e7ab..2def134b9d3 100644 --- a/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java +++ b/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java @@ -47,11 +47,13 @@ * @summary Test JVM large page setup (+THP) * @library /test/lib * @requires os.family == "linux" + * @library /test/lib * @modules java.base/jdk.internal.misc * java.management * @run driver TestHugePageDecisionsAtVMStartup -XX:+UseTransparentHugePages */ +import jdk.test.lib.os.linux.HugePageConfiguration; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import java.util.ArrayList; diff --git a/test/hotspot/jtreg/runtime/os/TestHugePageDetection.java b/test/hotspot/jtreg/runtime/os/TestHugePageDetection.java index 2e2d9092c74..7231f30ed41 100644 --- a/test/hotspot/jtreg/runtime/os/TestHugePageDetection.java +++ b/test/hotspot/jtreg/runtime/os/TestHugePageDetection.java @@ -28,12 +28,14 @@ * @library /test/lib * @requires vm.flagless * @requires os.family == "linux" + * @library /test/lib * @modules java.base/jdk.internal.misc * java.management * @run driver TestHugePageDetection */ import java.util.*; +import jdk.test.lib.os.linux.HugePageConfiguration; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 5544ad1bebd..f5dcb44db2b 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -378,6 +378,7 @@ public class VMProps implements Callable> { vmOptFinalFlag(map, "UnlockExperimentalVMOptions"); vmOptFinalFlag(map, "UseCompressedOops"); vmOptFinalFlag(map, "UseLargePages"); + vmOptFinalFlag(map, "UseTransparentHugePages"); vmOptFinalFlag(map, "UseVectorizedMismatchIntrinsic"); } diff --git a/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java b/test/lib/jdk/test/lib/os/linux/HugePageConfiguration.java similarity index 96% rename from test/hotspot/jtreg/runtime/os/HugePageConfiguration.java rename to test/lib/jdk/test/lib/os/linux/HugePageConfiguration.java index adde51ec75f..0bb6db16021 100644 --- a/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java +++ b/test/lib/jdk/test/lib/os/linux/HugePageConfiguration.java @@ -22,6 +22,8 @@ * questions. */ +package jdk.test.lib.os.linux; + import jdk.test.lib.process.OutputAnalyzer; import java.io.*; @@ -33,7 +35,7 @@ import java.util.regex.Pattern; // - a) the Operating System (the truth) // - b) the JVM log (-Xlog:pagesize) // This is used e.g. in TestHugePageDetection to determine if the JVM detects the correct settings from the OS. -class HugePageConfiguration { +public class HugePageConfiguration { public static class ExplicitHugePageConfig implements Comparable { public long pageSize = -1; @@ -63,11 +65,11 @@ class HugePageConfiguration { Set _explicitHugePageConfigurations; long _explicitDefaultHugePageSize = -1; - enum THPMode {always, never, madvise} + public enum THPMode {always, never, madvise} THPMode _thpMode; long _thpPageSize; - enum ShmemTHPMode {always, within_size, advise, never, deny, force, unknown} + public enum ShmemTHPMode {always, within_size, advise, never, deny, force, unknown} ShmemTHPMode _shmemThpMode; public Set getExplicitHugePageConfigurations() { @@ -133,6 +135,15 @@ class HugePageConfiguration { '}'; } + @Override + public int hashCode() { + return Objects.hash(_explicitDefaultHugePageSize, + _thpPageSize, + _explicitHugePageConfigurations, + _thpMode, + _shmemThpMode); + } + @Override public boolean equals(Object o) { if (this == o) return true;