46 import jdk.test.lib.Asserts;
47 import jdk.test.lib.process.OutputAnalyzer;
48 import jdk.test.lib.cli.CommandLineOptionTest;
49 import jdk.test.lib.Platform;
50
51 import java.util.List;
52
53 /**
54 * Test verifies that RTMSpinLoopCount increase time spent between retries
55 * by comparing amount of retries done with different RTMSpinLoopCount's values.
56 */
57 public class TestRTMSpinLoopCount {
58 private static final int LOCKING_TIME = 1000;
59 private static final int RTM_RETRY_COUNT = 1000;
60 private static final boolean INFLATE_MONITOR = true;
61 private static final long MAX_ABORTS = RTM_RETRY_COUNT + 1L;
62 private static int[] SPIN_LOOP_COUNTS;
63
64 protected void runTestCases() throws Throwable {
65
66 if (Platform.isPPC()) {
67 SPIN_LOOP_COUNTS = new int[] { 0, 10, 100, 1_000, 10_000 };
68 } else {
69 SPIN_LOOP_COUNTS = new int[] { 0, 100, 1_000, 10_000, 100_000 };
70 }
71
72 long[] aborts = new long[TestRTMSpinLoopCount.SPIN_LOOP_COUNTS.length];
73
74 for (int i = 0; i < TestRTMSpinLoopCount.SPIN_LOOP_COUNTS.length; i++) {
75 aborts[i] = getAbortsCountOnLockBusy(
76 TestRTMSpinLoopCount.SPIN_LOOP_COUNTS[i]);
77 }
78
79 for (int i = 1; i < aborts.length; i++) {
80 Asserts.assertLTE(aborts[i], aborts[i - 1], "Increased spin loop "
81 + "count should not increase retries count.");
82 }
83 }
84
85 private long getAbortsCountOnLockBusy(int spinLoopCount) throws Throwable {
86 CompilableTest test = new BusyLock();
87
88 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
89 test,
90 CommandLineOptionTest.prepareNumericFlag("RTMRetryCount",
|
46 import jdk.test.lib.Asserts;
47 import jdk.test.lib.process.OutputAnalyzer;
48 import jdk.test.lib.cli.CommandLineOptionTest;
49 import jdk.test.lib.Platform;
50
51 import java.util.List;
52
53 /**
54 * Test verifies that RTMSpinLoopCount increase time spent between retries
55 * by comparing amount of retries done with different RTMSpinLoopCount's values.
56 */
57 public class TestRTMSpinLoopCount {
58 private static final int LOCKING_TIME = 1000;
59 private static final int RTM_RETRY_COUNT = 1000;
60 private static final boolean INFLATE_MONITOR = true;
61 private static final long MAX_ABORTS = RTM_RETRY_COUNT + 1L;
62 private static int[] SPIN_LOOP_COUNTS;
63
64 protected void runTestCases() throws Throwable {
65
66 SPIN_LOOP_COUNTS = new int[] { 0, 100, 1_000, 10_000, 100_000 };
67
68 long[] aborts = new long[TestRTMSpinLoopCount.SPIN_LOOP_COUNTS.length];
69
70 for (int i = 0; i < TestRTMSpinLoopCount.SPIN_LOOP_COUNTS.length; i++) {
71 aborts[i] = getAbortsCountOnLockBusy(
72 TestRTMSpinLoopCount.SPIN_LOOP_COUNTS[i]);
73 }
74
75 for (int i = 1; i < aborts.length; i++) {
76 Asserts.assertLTE(aborts[i], aborts[i - 1], "Increased spin loop "
77 + "count should not increase retries count.");
78 }
79 }
80
81 private long getAbortsCountOnLockBusy(int spinLoopCount) throws Throwable {
82 CompilableTest test = new BusyLock();
83
84 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
85 test,
86 CommandLineOptionTest.prepareNumericFlag("RTMRetryCount",
|