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 // -----------------------------------------------------------------------------
126 // Theory of operations -- Monitors lists, thread residency, etc:
1825 SpinPause();
1826 }
1827
1828 // Admission control - verify preconditions for spinning
1829 //
1830 // We always spin a little bit, just to prevent _SpinDuration == 0 from
1831 // becoming an absorbing state. Put another way, we spin briefly to
1832 // sample, just in case the system load, parallelism, contention, or lock
1833 // modality changed.
1834 //
1835 // Consider the following alternative:
1836 // Periodically set _SpinDuration = _SpinLimit and try a long/full
1837 // spin attempt. "Periodically" might mean after a tally of
1838 // the # of failed spin attempts (or iterations) reaches some threshold.
1839 // This takes us into the realm of 1-out-of-N spinning, where we
1840 // hold the duration constant but vary the frequency.
1841
1842 ctr = _SpinDuration;
1843 if (ctr <= 0) return 0;
1844
1845 if (Knob_SuccRestrict && _succ != NULL) return 0;
1846 if (Knob_OState && NotRunnable (Self, (Thread *) _owner)) {
1847 return 0;
1848 }
1849
1850 int MaxSpin = Knob_MaxSpinners;
1851 if (MaxSpin >= 0) {
1852 if (_Spinner > MaxSpin) {
1853 return 0;
1854 }
1855 // Slightly racy, but benign ...
1856 Adjust(&_Spinner, 1);
1857 }
1858
1859 // We're good to spin ... spin ingress.
1860 // CONSIDER: use Prefetch::write() to avoid RTS->RTO upgrades
1861 // when preparing to LD...CAS _owner, etc and the CAS is likely
1862 // to succeed.
1863 if (_succ == NULL) {
1864 _succ = Self;
1865 }
|
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_MaxSpinners = -1; // Should be a function of # CPUs
107 static int Knob_Bonus = 100; // spin success bonus
108 static int Knob_BonusB = 100; // spin success bonus
109 static int Knob_Penalty = 200; // spin failure penalty
110 static int Knob_Poverty = 1000;
111 static int Knob_SpinAfterFutile = 1; // Spin after returning from park()
112 static int Knob_FixedSpin = 0;
113 static int Knob_OState = 3; // Spinner checks thread state of _owner
114 static int Knob_UsePause = 1;
115 static int Knob_ExitPolicy = 0;
116 static int Knob_PreSpin = 10; // 20-100 likely better
117 static int Knob_ResetEvent = 0;
118
119 static int Knob_FastHSSEC = 0;
120 static int Knob_MoveNotifyee = 2; // notify() - disposition of notifyee
121 static int Knob_QMode = 0; // EntryList-cxq policy - queue discipline
122 static volatile int InitDone = 0;
123
124 // -----------------------------------------------------------------------------
125 // Theory of operations -- Monitors lists, thread residency, etc:
1824 SpinPause();
1825 }
1826
1827 // Admission control - verify preconditions for spinning
1828 //
1829 // We always spin a little bit, just to prevent _SpinDuration == 0 from
1830 // becoming an absorbing state. Put another way, we spin briefly to
1831 // sample, just in case the system load, parallelism, contention, or lock
1832 // modality changed.
1833 //
1834 // Consider the following alternative:
1835 // Periodically set _SpinDuration = _SpinLimit and try a long/full
1836 // spin attempt. "Periodically" might mean after a tally of
1837 // the # of failed spin attempts (or iterations) reaches some threshold.
1838 // This takes us into the realm of 1-out-of-N spinning, where we
1839 // hold the duration constant but vary the frequency.
1840
1841 ctr = _SpinDuration;
1842 if (ctr <= 0) return 0;
1843
1844 if (Knob_OState && NotRunnable (Self, (Thread *) _owner)) {
1845 return 0;
1846 }
1847
1848 int MaxSpin = Knob_MaxSpinners;
1849 if (MaxSpin >= 0) {
1850 if (_Spinner > MaxSpin) {
1851 return 0;
1852 }
1853 // Slightly racy, but benign ...
1854 Adjust(&_Spinner, 1);
1855 }
1856
1857 // We're good to spin ... spin ingress.
1858 // CONSIDER: use Prefetch::write() to avoid RTS->RTO upgrades
1859 // when preparing to LD...CAS _owner, etc and the CAS is likely
1860 // to succeed.
1861 if (_succ == NULL) {
1862 _succ = Self;
1863 }
|