# HG changeset patch # User gromero # Date 1526923435 14400 # Mon May 21 13:23:55 2018 -0400 # Node ID 7ee9df6fd123a103279fc487f33b79c8030a4c4e # Parent 67066e7971e1ceda21020b6bde18eeded67eab2e PPC64: Fix jtreg RTM tests after "8203305: Improve TM detection for enabling RTM on Linux / POWER9" diff --git a/src/hotspot/cpu/ppc/vm_version_ppc.cpp b/src/hotspot/cpu/ppc/vm_version_ppc.cpp --- a/src/hotspot/cpu/ppc/vm_version_ppc.cpp +++ b/src/hotspot/cpu/ppc/vm_version_ppc.cpp @@ -131,7 +131,7 @@ // Create and print feature-string. char buf[(num_features+1) * 16]; // Max 16 chars per feature. jio_snprintf(buf, sizeof(buf), - "ppc64%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + "ppc64%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", (has_fsqrt() ? " fsqrt" : ""), (has_isel() ? " isel" : ""), (has_lxarxeh() ? " lxarxeh" : ""), @@ -148,7 +148,8 @@ (has_vsx() ? " vsx" : ""), (has_ldbrx() ? " ldbrx" : ""), (has_stdbrx() ? " stdbrx" : ""), - (has_vshasig() ? " sha" : "") + (has_vshasig() ? " sha" : ""), + (has_tm() ? " rtm" : "") // Make sure number of %s matches num_features! ); _features_string = os::strdup(buf); @@ -319,35 +320,8 @@ if (PowerArchitecturePPC64 < 8) { vm_exit_during_initialization("RTM instructions are not available on this CPU."); } - bool os_support_tm = false; -#ifdef AIX - // Actually, this is supported since AIX 7.1.. Unfortunately, this first - // contained bugs, so that it can only be enabled after AIX 7.1.3.30. - // The Java property os.version, which is used in RTM tests to decide - // whether the feature is available, only knows major and minor versions. - // We don't want to change this property, as user code might depend on it. - // So the tests can not check on subversion 3.30, and we only enable RTM - // with AIX 7.2. - if (os::Aix::os_version() >= 0x07020000) { // At least AIX 7.2. - os_support_tm = true; - } -#endif -#if defined(LINUX) && defined(VM_LITTLE_ENDIAN) - unsigned long auxv = getauxval(AT_HWCAP2); - if (auxv & PPC_FEATURE2_HTM_NOSC) { - if (auxv & PPC_FEATURE2_HAS_HTM) { - // TM on POWER8 and POWER9 in compat mode (VM) is supported by the JVM. - // TM on POWER9 DD2.1 NV (baremetal) is not supported by the JVM (TM on - // POWER9 DD2.1 NV has a few issues that need a couple of firmware - // and kernel workarounds, so there is a new mode only supported - // on non-virtualized P9 machines called HTM with no Suspend Mode). - // TM on POWER9 D2.2+ NV is not supported at all by Linux. - os_support_tm = true; - } - } -#endif - if (!os_support_tm) { + if (!has_tm()) { vm_exit_during_initialization("RTM is not supported on this OS version."); } } @@ -754,6 +728,34 @@ Disassembler::decode((u_char*)code, (u_char*)code_end, tty); } +#ifdef AIX + // Actually, this is supported since AIX 7.1.. Unfortunately, this first + // contained bugs, so that it can only be enabled after AIX 7.1.3.30. + // The Java property os.version, which is used in RTM tests to decide + // whether the feature is available, only knows major and minor versions. + // We don't want to change this property, as user code might depend on it. + // So the tests can not check on subversion 3.30, and we only enable RTM + // with AIX 7.2. + if (os::Aix::os_version() >= 0x07020000) { // At least AIX 7.2. + features |= rtm_m; + } +#endif +#if defined(LINUX) && defined(VM_LITTLE_ENDIAN) + unsigned long auxv = getauxval(AT_HWCAP2); + + if (auxv & PPC_FEATURE2_HTM_NOSC) { + if (auxv & PPC_FEATURE2_HAS_HTM) { + // TM on POWER8 and POWER9 in compat mode (VM) is supported by the JVM. + // TM on POWER9 DD2.1 NV (baremetal) is not supported by the JVM (TM on + // POWER9 DD2.1 NV has a few issues that need a couple of firmware + // and kernel workarounds, so there is a new mode only supported + // on non-virtualized P9 machines called HTM with no Suspend Mode). + // TM on POWER9 D2.2+ NV is not supported at all by Linux. + features |= rtm_m; + } + } +#endif + _features = features; } diff --git a/src/hotspot/cpu/ppc/vm_version_ppc.hpp b/src/hotspot/cpu/ppc/vm_version_ppc.hpp --- a/src/hotspot/cpu/ppc/vm_version_ppc.hpp +++ b/src/hotspot/cpu/ppc/vm_version_ppc.hpp @@ -49,6 +49,7 @@ ldbrx, stdbrx, vshasig, + rtm, num_features // last entry to count features }; enum Feature_Flag_Set { @@ -64,12 +65,13 @@ vand_m = (1 << vand ), lqarx_m = (1 << lqarx ), vcipher_m = (1 << vcipher), - vshasig_m = (1 << vshasig), vpmsumb_m = (1 << vpmsumb), mfdscr_m = (1 << mfdscr ), vsx_m = (1 << vsx ), ldbrx_m = (1 << ldbrx ), stdbrx_m = (1 << stdbrx ), + vshasig_m = (1 << vshasig), + rtm_m = (1 << rtm ), all_features_m = (unsigned long)-1 }; @@ -107,6 +109,8 @@ static bool has_stdbrx() { return (_features & stdbrx_m) != 0; } static bool has_vshasig() { return (_features & vshasig_m) != 0; } static bool has_mtfprd() { return has_vpmsumb(); } // alias for P8 + // OS feature support + static bool has_tm() { return (_features & rtm_m) != 0; } // Assembler testing static void allow_all(); diff --git a/test/hotspot/jtreg/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java b/test/hotspot/jtreg/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java --- a/test/hotspot/jtreg/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java +++ b/test/hotspot/jtreg/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java @@ -36,6 +36,8 @@ protected static final String RTM_INSTR_ERROR = "RTM instructions are not available on this CPU"; + protected static final String RTM_OS_ERROR + = "RTM is not supported on this OS version"; protected static final String RTM_UNSUPPORTED_VM_ERROR = "RTM locking optimization is not supported in this VM"; protected static final String RTM_FOR_STACK_LOCKS_WARNING diff --git a/test/hotspot/jtreg/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java b/test/hotspot/jtreg/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java --- a/test/hotspot/jtreg/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java +++ b/test/hotspot/jtreg/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java @@ -48,28 +48,49 @@ private static final String DEFAULT_VALUE = "false"; public void runTestCases() throws Throwable { - String unrecongnizedOption + String unrecognizedOption = CommandLineOptionTest.getUnrecognizedOptionErrorMessage( "UseRTMLocking"); String errorMessage = RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR; if (Platform.isX86() || Platform.isX64() || Platform.isPPC()) { - String shouldFailMessage = "JVM startup should fail with option " - + "-XX:+UseRTMLocking on unsupported CPU"; - // verify that we get an error when use +UseRTMLocking - // on unsupported CPU - CommandLineOptionTest.verifySameJVMStartup( - new String[] { errorMessage }, - new String[] { unrecongnizedOption }, shouldFailMessage, - shouldFailMessage + ". Error message should be shown", - ExitCode.FAIL, "-XX:+UseRTMLocking"); + String shouldFailMessage = "JVM startup should fail with option " + + "-XX:+UseRTMLocking on unsupported CPU"; + + try { + // verify that we get an error when use +UseRTMLocking + // on unsupported CPU + CommandLineOptionTest.verifySameJVMStartup( + new String[] { errorMessage }, + new String[] { unrecognizedOption }, shouldFailMessage, + shouldFailMessage + ". Error message should be shown.", + ExitCode.FAIL, "-XX:+UseRTMLocking"); + } catch (Throwable e) { + // verify that we get an error when use +UseRTMLocking + // on unsupported OS. It might be the case that although CPU + // supports RTM the OS version does not support RTM + if (Platform.isPPC()) { + String errorMessage2 = RTMGenericCommandLineOptionTest.RTM_OS_ERROR; + String shouldFailMessage2 = "JVM startup should fail with option " + + "-XX:+UseRTMLocking on unsupported CPU or " + + "OS version"; + + CommandLineOptionTest.verifySameJVMStartup( + new String[] { errorMessage2 }, + new String[] { unrecognizedOption}, shouldFailMessage2, + shouldFailMessage2 + ". Error message should be shown.", + ExitCode.FAIL, "-XX:+UseRTMLocking"); + } else { + throw e; // checking unsupported OS error is not necessary + } + } String shouldPassMessage = "JVM startup should pass with option " + "-XX:-UseRTMLocking even on unsupported CPU"; // verify that we can pass -UseRTMLocking without // getting any error messages CommandLineOptionTest.verifySameJVMStartup(null, new String[] { - errorMessage, unrecongnizedOption }, shouldPassMessage, + errorMessage, unrecognizedOption }, shouldPassMessage, shouldPassMessage + " without any warnings", ExitCode.OK, "-XX:-UseRTMLocking"); @@ -84,12 +105,12 @@ + "Error message should be shown"; // verify that on non-x86 CPUs RTMLocking could not be used CommandLineOptionTest.verifySameJVMStartup( - new String[] { unrecongnizedOption }, + new String[] { unrecognizedOption }, null, shouldFailMessage, shouldFailMessage, ExitCode.FAIL, "-XX:+UseRTMLocking"); CommandLineOptionTest.verifySameJVMStartup( - new String[] { unrecongnizedOption }, + new String[] { unrecognizedOption }, null, shouldFailMessage, shouldFailMessage, ExitCode.FAIL, "-XX:-UseRTMLocking"); } diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -260,9 +260,7 @@ * @return true if VM runs RTM supported CPU and false otherwise. */ protected String vmRTMCPU() { - boolean vmRTMCPU = (Platform.isPPC() ? CPUInfo.hasFeature("tcheck") : CPUInfo.hasFeature("rtm")); - - return "" + vmRTMCPU; + return "" + CPUInfo.hasFeature("rtm"); } /** diff --git a/test/lib/sun/hotspot/cpuinfo/CPUInfo.java b/test/lib/sun/hotspot/cpuinfo/CPUInfo.java --- a/test/lib/sun/hotspot/cpuinfo/CPUInfo.java +++ b/test/lib/sun/hotspot/cpuinfo/CPUInfo.java @@ -36,7 +36,7 @@ * * CPUInfo uses WhiteBox to gather information, * so WhiteBox class should be added to bootclasspath - * and option -XX:+WhiteBoxAPI should expclicetly + * and option -XX:+WhiteBoxAPI should be explicitly * specified on command line. */ public class CPUInfo {