< prev index next >

src/hotspot/share/runtime/objectMonitor.cpp

Print this page
rev 51780 : imported patch syncknobs-00-base
rev 51781 : imported patch syncknobs-01-Knob_ReportSettings
rev 51782 : imported patch syncknobs-02-Knob_SpinBackOff
rev 51783 : imported patch syncknobs-03-BackOffMask
rev 51784 : imported patch syncknobs-04-Knob_ExitRelease
rev 51785 : imported patch syncknobs-05-Knob_InlineNotify
rev 51786 : imported patch syncknobs-06-Knob_Verbose
rev 51787 : imported patch syncknobs-07-Knob_VerifyInUse
rev 51788 : imported patch syncknobs-08-Knob_VerifyMatch
rev 51789 : imported patch syncknobs-09-Knob_SpinBase
rev 51790 : imported patch syncknobs-10-Knob_CASPenalty
rev 51791 : imported patch syncknobs-11-Knob_OXPenalty
rev 51792 : imported patch syncknobs-12-Knob_SpinSetSucc
rev 51793 : imported patch syncknobs-13-Knob_SpinEarly
rev 51794 : imported patch syncknobs-14-Knob_SuccEnabled


  86     if (DTraceMonitorProbes) {                                             \
  87       DTRACE_MONITOR_PROBE_COMMON(obj, thread);                            \
  88       HOTSPOT_MONITOR_##probe(jtid,                                        \
  89                               (uintptr_t)(monitor), bytes, len);           \
  90     }                                                                      \
  91   }
  92 
  93 #else //  ndef DTRACE_ENABLED
  94 
  95 #define DTRACE_MONITOR_WAIT_PROBE(obj, thread, millis, mon)    {;}
  96 #define DTRACE_MONITOR_PROBE(probe, obj, thread, mon)          {;}
  97 
  98 #endif // ndef DTRACE_ENABLED
  99 
 100 // Tunables ...
 101 // The knob* variables are effectively final.  Once set they should
 102 // never be modified hence.  Consider using __read_mostly with GCC.
 103 
 104 int ObjectMonitor::Knob_SpinLimit    = 5000;    // derived by an external tool -
 105 
 106 static int Knob_SuccEnabled         = 1;       // futile wake throttling
 107 static int Knob_SuccRestrict        = 0;       // Limit successors + spinners to at-most-one
 108 static int Knob_MaxSpinners         = -1;      // Should be a function of # CPUs
 109 static int Knob_Bonus               = 100;     // spin success bonus
 110 static int Knob_BonusB              = 100;     // spin success bonus
 111 static int Knob_Penalty             = 200;     // spin failure penalty
 112 static int Knob_Poverty             = 1000;
 113 static int Knob_SpinAfterFutile     = 1;       // Spin after returning from park()
 114 static int Knob_FixedSpin           = 0;
 115 static int Knob_OState              = 3;       // Spinner checks thread state of _owner
 116 static int Knob_UsePause            = 1;
 117 static int Knob_ExitPolicy          = 0;
 118 static int Knob_PreSpin             = 10;      // 20-100 likely better
 119 static int Knob_ResetEvent          = 0;
 120 
 121 static int Knob_FastHSSEC           = 0;
 122 static int Knob_MoveNotifyee        = 2;       // notify() - disposition of notifyee
 123 static int Knob_QMode               = 0;       // EntryList-cxq policy - queue discipline
 124 static volatile int InitDone        = 0;
 125 
 126 // -----------------------------------------------------------------------------


1225     assert(jSelf->is_suspend_equivalent(), "invariant");
1226     jSelf->clear_suspend_equivalent();
1227     if (2 == Mode) OrderAccess::storeload();
1228     if (!jSelf->is_external_suspend()) return false;
1229     // We raced a suspension -- fall thru into the slow path
1230     jSelf->set_suspend_equivalent();
1231   }
1232   return jSelf->handle_special_suspend_equivalent_condition();
1233 }
1234 
1235 
1236 void ObjectMonitor::ExitEpilog(Thread * Self, ObjectWaiter * Wakee) {
1237   assert(_owner == Self, "invariant");
1238 
1239   // Exit protocol:
1240   // 1. ST _succ = wakee
1241   // 2. membar #loadstore|#storestore;
1242   // 2. ST _owner = NULL
1243   // 3. unpark(wakee)
1244 
1245   _succ = Knob_SuccEnabled ? Wakee->_thread : NULL;
1246   ParkEvent * Trigger = Wakee->_event;
1247 
1248   // Hygiene -- once we've set _owner = NULL we can't safely dereference Wakee again.
1249   // The thread associated with Wakee may have grabbed the lock and "Wakee" may be
1250   // out-of-scope (non-extant).
1251   Wakee  = NULL;
1252 
1253   // Drop the lock
1254   OrderAccess::release_store(&_owner, (void*)NULL);
1255   OrderAccess::fence();                               // ST _owner vs LD in unpark()
1256 
1257   DTRACE_MONITOR_PROBE(contended__exit, this, object(), Self);
1258   Trigger->unpark();
1259 
1260   // Maintain stats and report events to JVMTI
1261   OM_PERFDATA_OP(Parks, inc());
1262 }
1263 
1264 
1265 // -----------------------------------------------------------------------------




  86     if (DTraceMonitorProbes) {                                             \
  87       DTRACE_MONITOR_PROBE_COMMON(obj, thread);                            \
  88       HOTSPOT_MONITOR_##probe(jtid,                                        \
  89                               (uintptr_t)(monitor), bytes, len);           \
  90     }                                                                      \
  91   }
  92 
  93 #else //  ndef DTRACE_ENABLED
  94 
  95 #define DTRACE_MONITOR_WAIT_PROBE(obj, thread, millis, mon)    {;}
  96 #define DTRACE_MONITOR_PROBE(probe, obj, thread, mon)          {;}
  97 
  98 #endif // ndef DTRACE_ENABLED
  99 
 100 // Tunables ...
 101 // The knob* variables are effectively final.  Once set they should
 102 // never be modified hence.  Consider using __read_mostly with GCC.
 103 
 104 int ObjectMonitor::Knob_SpinLimit    = 5000;    // derived by an external tool -
 105 

 106 static int Knob_SuccRestrict        = 0;       // Limit successors + spinners to at-most-one
 107 static int Knob_MaxSpinners         = -1;      // Should be a function of # CPUs
 108 static int Knob_Bonus               = 100;     // spin success bonus
 109 static int Knob_BonusB              = 100;     // spin success bonus
 110 static int Knob_Penalty             = 200;     // spin failure penalty
 111 static int Knob_Poverty             = 1000;
 112 static int Knob_SpinAfterFutile     = 1;       // Spin after returning from park()
 113 static int Knob_FixedSpin           = 0;
 114 static int Knob_OState              = 3;       // Spinner checks thread state of _owner
 115 static int Knob_UsePause            = 1;
 116 static int Knob_ExitPolicy          = 0;
 117 static int Knob_PreSpin             = 10;      // 20-100 likely better
 118 static int Knob_ResetEvent          = 0;
 119 
 120 static int Knob_FastHSSEC           = 0;
 121 static int Knob_MoveNotifyee        = 2;       // notify() - disposition of notifyee
 122 static int Knob_QMode               = 0;       // EntryList-cxq policy - queue discipline
 123 static volatile int InitDone        = 0;
 124 
 125 // -----------------------------------------------------------------------------


1224     assert(jSelf->is_suspend_equivalent(), "invariant");
1225     jSelf->clear_suspend_equivalent();
1226     if (2 == Mode) OrderAccess::storeload();
1227     if (!jSelf->is_external_suspend()) return false;
1228     // We raced a suspension -- fall thru into the slow path
1229     jSelf->set_suspend_equivalent();
1230   }
1231   return jSelf->handle_special_suspend_equivalent_condition();
1232 }
1233 
1234 
1235 void ObjectMonitor::ExitEpilog(Thread * Self, ObjectWaiter * Wakee) {
1236   assert(_owner == Self, "invariant");
1237 
1238   // Exit protocol:
1239   // 1. ST _succ = wakee
1240   // 2. membar #loadstore|#storestore;
1241   // 2. ST _owner = NULL
1242   // 3. unpark(wakee)
1243 
1244   _succ = Wakee->_thread;
1245   ParkEvent * Trigger = Wakee->_event;
1246 
1247   // Hygiene -- once we've set _owner = NULL we can't safely dereference Wakee again.
1248   // The thread associated with Wakee may have grabbed the lock and "Wakee" may be
1249   // out-of-scope (non-extant).
1250   Wakee  = NULL;
1251 
1252   // Drop the lock
1253   OrderAccess::release_store(&_owner, (void*)NULL);
1254   OrderAccess::fence();                               // ST _owner vs LD in unpark()
1255 
1256   DTRACE_MONITOR_PROBE(contended__exit, this, object(), Self);
1257   Trigger->unpark();
1258 
1259   // Maintain stats and report events to JVMTI
1260   OM_PERFDATA_OP(Parks, inc());
1261 }
1262 
1263 
1264 // -----------------------------------------------------------------------------


< prev index next >