8203669: PPC64: Fix jtreg RTM tests after "8203305: Improve TM detection for enabling RTM on Linux / POWER9"

Reviewed-by: mdoerr, goetz
This commit is contained in:
Gustavo Romero 2018-05-21 13:23:55 -04:00
parent aabea5d599
commit c4b890cac0
6 changed files with 78 additions and 54 deletions

View File

@ -131,7 +131,7 @@ void VM_Version::initialize() {
// 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 @@ void VM_Version::initialize() {
(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,47 +320,14 @@ void VM_Version::initialize() {
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.");
}
}
if (UseRTMLocking) {
#if INCLUDE_RTM_OPT
if (!UnlockExperimentalVMOptions) {
vm_exit_during_initialization("UseRTMLocking is only available as experimental option on this platform. "
"It must be enabled via -XX:+UnlockExperimentalVMOptions flag.");
} else {
warning("UseRTMLocking is only available as experimental option on this platform.");
}
if (!FLAG_IS_CMDLINE(UseRTMLocking)) {
// RTM locking should be used only for applications with
// high lock contention. For now we do not use it by default.
@ -755,6 +723,37 @@ void VM_Version::determine_features() {
}
_features = features;
#ifdef AIX
// To enable it on AIX it's necessary POWER8 or above and at least AIX 7.2.
// 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 (has_lqarx()) { // POWER8 or above
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
}
// Power 8: Configure Data Stream Control Register.

View File

@ -49,6 +49,7 @@ protected:
ldbrx,
stdbrx,
vshasig,
rtm,
num_features // last entry to count features
};
enum Feature_Flag_Set {
@ -64,12 +65,13 @@ protected:
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 @@ public:
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();

View File

@ -36,6 +36,8 @@ public abstract class RTMGenericCommandLineOptionTest {
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

View File

@ -48,28 +48,49 @@ public class TestUseRTMLockingOptionOnUnsupportedCPU {
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 @@ public class TestUseRTMLockingOptionOnUnsupportedCPU {
+ "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");
}

View File

@ -280,9 +280,7 @@ public class VMProps implements Callable<Map<String, String>> {
* @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");
}
/**

View File

@ -36,7 +36,7 @@ import sun.hotspot.WhiteBox;
*
* 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 {