8194085: Obsolete the deprecated SafepointSynchronize flags and remove related code
authorhseigel
Mon, 26 Feb 2018 11:28:05 -0500
changeset 49169 af8578e25d17
parent 49168 23348e42fb34
child 49170 49e095e658c7
8194085: Obsolete the deprecated SafepointSynchronize flags and remove related code Summary: Obsolete SafepointSpinBeforeYield, DeferThrSuspendLoopCount, and DeferPollingPageLoopCount and remove associated code. Reviewed-by: dcubed, coleenp, dholmes
src/hotspot/share/runtime/arguments.cpp
src/hotspot/share/runtime/globals.hpp
src/hotspot/share/runtime/safepoint.cpp
src/hotspot/share/runtime/safepoint.hpp
--- a/src/hotspot/share/runtime/arguments.cpp	Mon Feb 26 10:20:06 2018 -0500
+++ b/src/hotspot/share/runtime/arguments.cpp	Mon Feb 26 11:28:05 2018 -0500
@@ -50,6 +50,7 @@
 #include "runtime/globals_extension.hpp"
 #include "runtime/java.hpp"
 #include "runtime/os.hpp"
+#include "runtime/safepoint.hpp"
 #include "runtime/safepointMechanism.hpp"
 #include "runtime/vm_version.hpp"
 #include "services/management.hpp"
@@ -509,9 +510,6 @@
   { "MinRAMFraction",               JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
   { "InitialRAMFraction",           JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
   { "UseMembar",                    JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
-  { "SafepointSpinBeforeYield",     JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
-  { "DeferThrSuspendLoopCount",     JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
-  { "DeferPollingPageLoopCount",    JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
   { "IgnoreUnverifiableClassesDuringDump", JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
   { "CheckEndorsedAndExtDirs",      JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
   { "CompilerThreadHintNoPreempt",  JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) },
@@ -532,6 +530,9 @@
   { "PrintMalloc",                   JDK_Version::undefined(), JDK_Version::jdk(11), JDK_Version::jdk(12) },
   { "ShowSafepointMsgs",             JDK_Version::undefined(), JDK_Version::jdk(11), JDK_Version::jdk(12) },
   { "FastTLABRefill",                JDK_Version::jdk(10),     JDK_Version::jdk(11), JDK_Version::jdk(12) },
+  { "SafepointSpinBeforeYield",      JDK_Version::jdk(10),     JDK_Version::jdk(11), JDK_Version::jdk(12) },
+  { "DeferThrSuspendLoopCount",      JDK_Version::jdk(10),     JDK_Version::jdk(11), JDK_Version::jdk(12) },
+  { "DeferPollingPageLoopCount",     JDK_Version::jdk(10),     JDK_Version::jdk(11), JDK_Version::jdk(12) },
   { "PermSize",                      JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
   { "MaxPermSize",                   JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
   { "SharedReadWriteSize",           JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() },
@@ -2951,9 +2952,7 @@
       if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != Flag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(intx, DeferThrSuspendLoopCount, 1) != Flag::SUCCESS) {
-        return JNI_EINVAL;
-      }
+      SafepointSynchronize::set_defer_thr_suspend_loop_count();
       if (FLAG_SET_CMDLINE(bool, UseTLAB, false) != Flag::SUCCESS) {
         return JNI_EINVAL;
       }
--- a/src/hotspot/share/runtime/globals.hpp	Mon Feb 26 10:20:06 2018 -0500
+++ b/src/hotspot/share/runtime/globals.hpp	Mon Feb 26 11:28:05 2018 -0500
@@ -3256,21 +3256,6 @@
   develop(uintx, GCWorkerDelayMillis, 0,                                    \
           "Delay in scheduling GC workers (in milliseconds)")               \
                                                                             \
-  product(intx, DeferThrSuspendLoopCount,     4000,                         \
-          "(Unstable, Deprecated) "                                         \
-          "Number of times to iterate in safepoint loop "                   \
-          "before blocking VM threads ")                                    \
-          range(-1, max_jint-1)                                             \
-                                                                            \
-  product(intx, DeferPollingPageLoopCount,     -1,                          \
-          "(Unsafe,Unstable,Deprecated) "                                   \
-          "Number of iterations in safepoint loop "                         \
-          "before changing safepoint polling page to RO ")                  \
-          range(-1, max_jint-1)                                             \
-                                                                            \
-  product(intx, SafepointSpinBeforeYield, 2000, "(Unstable, Deprecated)")   \
-          range(0, max_intx)                                                \
-                                                                            \
   product(bool, PSChunkLargeArrays, true,                                   \
           "Process large arrays in chunks")                                 \
                                                                             \
--- a/src/hotspot/share/runtime/safepoint.cpp	Mon Feb 26 10:20:06 2018 -0500
+++ b/src/hotspot/share/runtime/safepoint.cpp	Mon Feb 26 11:28:05 2018 -0500
@@ -78,6 +78,8 @@
 volatile int SafepointSynchronize::_safepoint_counter = 0;
 int SafepointSynchronize::_current_jni_active_count = 0;
 long  SafepointSynchronize::_end_of_last_safepoint = 0;
+int SafepointSynchronize::_defer_thr_suspend_loop_count = 4000;
+static const int safepoint_spin_before_yield = 2000;
 static volatile int PageArmed = 0 ;        // safepoint polling page is RO|RW vs PROT_NONE
 static volatile int TryingToBlock = 0 ;    // proximate value -- for advisory use only
 static bool timeout_error_printed = false;
@@ -191,12 +193,10 @@
       // Make interpreter safepoint aware
       Interpreter::notice_safepoints();
 
-      if (DeferPollingPageLoopCount < 0) {
-        // Make polling safepoint aware
-        guarantee (PageArmed == 0, "invariant") ;
-        PageArmed = 1 ;
-        os::make_polling_page_unreadable();
-      }
+      // Make polling safepoint aware
+      guarantee (PageArmed == 0, "invariant") ;
+      PageArmed = 1 ;
+      os::make_polling_page_unreadable();
     }
 
     // Consider using active_processor_count() ... but that call is expensive.
@@ -309,19 +309,21 @@
           // 9. On windows consider using the return value from SwitchThreadTo()
           //    to drive subsequent spin/SwitchThreadTo()/Sleep(N) decisions.
 
-          if (SafepointMechanism::uses_global_page_poll() && int(iterations) == DeferPollingPageLoopCount) {
-            guarantee (PageArmed == 0, "invariant") ;
-            PageArmed = 1 ;
-            os::make_polling_page_unreadable();
+          if (int(iterations) == -1) { // overflow - something is wrong.
+            // We can only overflow here when we are using global
+            // polling pages. We keep this guarantee in its original
+            // form so that searches of the bug database for this
+            // failure mode find the right bugs.
+            guarantee (PageArmed == 0, "invariant");
           }
 
           // Instead of (ncpus > 1) consider either (still_running < (ncpus + EPSILON)) or
           // ((still_running + _waiting_to_block - TryingToBlock)) < ncpus)
           ++steps ;
-          if (ncpus > 1 && steps < SafepointSpinBeforeYield) {
+          if (ncpus > 1 && steps < safepoint_spin_before_yield) {
             SpinPause() ;     // MP-Polite spin
           } else
-            if (steps < DeferThrSuspendLoopCount) {
+            if (steps < _defer_thr_suspend_loop_count) {
               os::naked_yield() ;
             } else {
               os::naked_short_sleep(1);
@@ -1190,7 +1192,6 @@
 float  SafepointSynchronize::_ts_of_current_safepoint = 0.0f;
 
 static jlong  cleanup_end_time = 0;
-static bool   need_to_track_page_armed_status = false;
 static bool   init_done = false;
 
 // Helper method to print the header.
@@ -1202,11 +1203,6 @@
              "[ threads:    total initially_running wait_to_block ]"
              "[ time:    spin   block    sync cleanup    vmop ] ");
 
-  // no page armed status printed out if it is always armed.
-  if (need_to_track_page_armed_status) {
-    tty->print("page_armed ");
-  }
-
   tty->print_cr("page_trap_count");
 }
 
@@ -1229,9 +1225,6 @@
   guarantee(_safepoint_stats != NULL,
             "not enough memory for safepoint instrumentation data");
 
-  if (DeferPollingPageLoopCount >= 0) {
-    need_to_track_page_armed_status = true;
-  }
   init_done = true;
 }
 
@@ -1271,10 +1264,6 @@
     spstat->_time_to_spin = cur_time - spstat->_time_to_spin;
   }
 
-  if (need_to_track_page_armed_status) {
-    spstat->_page_armed = (PageArmed == 1);
-  }
-
   // Records the start time of waiting for to block. Updated when block is done.
   if (_waiting_to_block != 0) {
     spstat->_time_to_wait_to_block = cur_time;
@@ -1363,9 +1352,6 @@
                (int64_t)(sstats->_time_to_do_cleanups / MICROUNITS),
                (int64_t)(sstats->_time_to_exec_vmop / MICROUNITS));
 
-    if (need_to_track_page_armed_status) {
-      tty->print(INT32_FORMAT_W(10) " ", sstats->_page_armed);
-    }
     tty->print_cr(INT32_FORMAT_W(15) " ", sstats->_nof_threads_hit_page_trap);
   }
 }
@@ -1392,12 +1378,7 @@
   tty->cr();
 
   // Print out polling page sampling status.
-  if (!need_to_track_page_armed_status) {
-    tty->print_cr("Polling page always armed");
-  } else {
-    tty->print_cr("Defer polling page loop count = " INTX_FORMAT "\n",
-                  DeferPollingPageLoopCount);
-  }
+  tty->print_cr("Polling page always armed");
 
   for (int index = 0; index < VM_Operation::VMOp_Terminating; index++) {
     if (_safepoint_reasons[index] != 0) {
--- a/src/hotspot/share/runtime/safepoint.hpp	Mon Feb 26 10:20:06 2018 -0500
+++ b/src/hotspot/share/runtime/safepoint.hpp	Mon Feb 26 11:28:05 2018 -0500
@@ -94,7 +94,6 @@
     int    _nof_total_threads;                 // total number of Java threads
     int    _nof_initial_running_threads;       // total number of initially seen running threads
     int    _nof_threads_wait_to_block;         // total number of threads waiting for to block
-    bool   _page_armed;                        // true if polling page is armed, false otherwise
     int    _nof_threads_hit_page_trap;         // total number of threads hitting the page trap
     jlong  _time_to_spin;                      // total time in millis spent in spinning
     jlong  _time_to_wait_to_block;             // total time in millis spent in waiting for to block
@@ -107,6 +106,7 @@
   static volatile SynchronizeState _state;     // Threads might read this flag directly, without acquiring the Threads_lock
   static volatile int _waiting_to_block;       // number of threads we are waiting for to block
   static int _current_jni_active_count;        // Counts the number of active critical natives during the safepoint
+  static int _defer_thr_suspend_loop_count;    // Iterations before blocking VM threads
 
   // This counter is used for fast versions of jni_Get<Primitive>Field.
   // An even value means there is no ongoing safepoint operations.
@@ -202,6 +202,11 @@
   static address address_of_state()                        { return (address)&_state; }
 
   static address safepoint_counter_addr()                  { return (address)&_safepoint_counter; }
+
+  // This method is only used for -Xconcurrentio support.
+  static void set_defer_thr_suspend_loop_count() {
+    _defer_thr_suspend_loop_count = 1;
+  }
 };
 
 // State class for a thread suspended at a safepoint