2187 n = PerfDataManager::create_counter(SUN_RT, #n, PerfData::U_Events, \
2188 CHECK); \
2189 }
2190 #define NEWPERFVARIABLE(n) \
2191 { \
2192 n = PerfDataManager::create_variable(SUN_RT, #n, PerfData::U_Events, \
2193 CHECK); \
2194 }
2195 NEWPERFCOUNTER(_sync_Inflations);
2196 NEWPERFCOUNTER(_sync_Deflations);
2197 NEWPERFCOUNTER(_sync_ContendedLockAttempts);
2198 NEWPERFCOUNTER(_sync_FutileWakeups);
2199 NEWPERFCOUNTER(_sync_Parks);
2200 NEWPERFCOUNTER(_sync_Notifications);
2201 NEWPERFVARIABLE(_sync_MonExtant);
2202 #undef NEWPERFCOUNTER
2203 #undef NEWPERFVARIABLE
2204 }
2205 }
2206
2207 static char * kvGet(char * kvList, const char * Key) {
2208 if (kvList == NULL) return NULL;
2209 size_t n = strlen(Key);
2210 char * Search;
2211 for (Search = kvList; *Search; Search += strlen(Search) + 1) {
2212 if (strncmp (Search, Key, n) == 0) {
2213 if (Search[n] == '=') return Search + n + 1;
2214 if (Search[n] == 0) return(char *) "1";
2215 }
2216 }
2217 return NULL;
2218 }
2219
2220 static int kvGetInt(char * kvList, const char * Key, int Default) {
2221 char * v = kvGet(kvList, Key);
2222 int rslt = v ? ::strtol(v, NULL, 0) : Default;
2223 if (Knob_ReportSettings && v != NULL) {
2224 tty->print_cr("INFO: SyncKnob: %s %d(%d)", Key, rslt, Default) ;
2225 tty->flush();
2226 }
2227 return rslt;
2228 }
2229
2230 void ObjectMonitor::DeferredInitialize() {
2231 if (InitDone > 0) return;
2232 if (Atomic::cmpxchg (-1, &InitDone, 0) != 0) {
2233 while (InitDone != 1) /* empty */;
2234 return;
2235 }
2236
2237 // One-shot global initialization ...
2238 // The initialization is idempotent, so we don't need locks.
2239 // In the future consider doing this via os::init_2().
2240 // SyncKnobs consist of <Key>=<Value> pairs in the style
2241 // of environment variables. Start by converting ':' to NUL.
2242
2243 if (SyncKnobs == NULL) SyncKnobs = "";
2244
2245 size_t sz = strlen(SyncKnobs);
2246 char * knobs = (char *) os::malloc(sz + 2, mtInternal);
2247 if (knobs == NULL) {
2248 vm_exit_out_of_memory(sz + 2, OOM_MALLOC_ERROR, "Parse SyncKnobs");
2249 guarantee(0, "invariant");
2250 }
2251 strcpy(knobs, SyncKnobs);
2252 knobs[sz+1] = 0;
2253 for (char * p = knobs; *p; p++) {
2254 if (*p == ':') *p = 0;
2255 }
2256
2257 #define SETKNOB(x) { Knob_##x = kvGetInt(knobs, #x, Knob_##x); }
2258 SETKNOB(ReportSettings);
2259 SETKNOB(ExitRelease);
2260 SETKNOB(InlineNotify);
2261 SETKNOB(Verbose);
2262 SETKNOB(VerifyInUse);
2263 SETKNOB(VerifyMatch);
2264 SETKNOB(FixedSpin);
2265 SETKNOB(SpinLimit);
2266 SETKNOB(SpinBase);
2267 SETKNOB(SpinBackOff);
2268 SETKNOB(CASPenalty);
2269 SETKNOB(OXPenalty);
2270 SETKNOB(SpinSetSucc);
2271 SETKNOB(SuccEnabled);
2272 SETKNOB(SuccRestrict);
2273 SETKNOB(Penalty);
2274 SETKNOB(Bonus);
2275 SETKNOB(BonusB);
2276 SETKNOB(Poverty);
2277 SETKNOB(SpinAfterFutile);
2278 SETKNOB(UsePause);
2279 SETKNOB(SpinEarly);
2280 SETKNOB(OState);
2281 SETKNOB(MaxSpinners);
2282 SETKNOB(PreSpin);
2283 SETKNOB(ExitPolicy);
2284 SETKNOB(QMode);
2285 SETKNOB(ResetEvent);
2286 SETKNOB(MoveNotifyee);
2287 SETKNOB(FastHSSEC);
2288 #undef SETKNOB
2289
2290 if (os::is_MP()) {
2291 BackOffMask = (1 << Knob_SpinBackOff) - 1;
2292 if (Knob_ReportSettings) {
2293 tty->print_cr("INFO: BackOffMask=0x%X", BackOffMask);
2294 }
2295 // CONSIDER: BackOffMask = ROUNDUP_NEXT_POWER2 (ncpus-1)
2296 } else {
2297 Knob_SpinLimit = 0;
2298 Knob_SpinBase = 0;
2299 Knob_PreSpin = 0;
2300 Knob_FixedSpin = -1;
2301 }
2302
2303 os::free(knobs);
2304 OrderAccess::fence();
2305 InitDone = 1;
2306 }
2307
|
2187 n = PerfDataManager::create_counter(SUN_RT, #n, PerfData::U_Events, \
2188 CHECK); \
2189 }
2190 #define NEWPERFVARIABLE(n) \
2191 { \
2192 n = PerfDataManager::create_variable(SUN_RT, #n, PerfData::U_Events, \
2193 CHECK); \
2194 }
2195 NEWPERFCOUNTER(_sync_Inflations);
2196 NEWPERFCOUNTER(_sync_Deflations);
2197 NEWPERFCOUNTER(_sync_ContendedLockAttempts);
2198 NEWPERFCOUNTER(_sync_FutileWakeups);
2199 NEWPERFCOUNTER(_sync_Parks);
2200 NEWPERFCOUNTER(_sync_Notifications);
2201 NEWPERFVARIABLE(_sync_MonExtant);
2202 #undef NEWPERFCOUNTER
2203 #undef NEWPERFVARIABLE
2204 }
2205 }
2206
2207 void ObjectMonitor::DeferredInitialize() {
2208 if (InitDone > 0) return;
2209 if (Atomic::cmpxchg (-1, &InitDone, 0) != 0) {
2210 while (InitDone != 1) /* empty */;
2211 return;
2212 }
2213
2214 // One-shot global initialization ...
2215 // The initialization is idempotent, so we don't need locks.
2216 // In the future consider doing this via os::init_2().
2217
2218 if (os::is_MP()) {
2219 BackOffMask = (1 << Knob_SpinBackOff) - 1;
2220 if (Knob_ReportSettings) {
2221 tty->print_cr("INFO: BackOffMask=0x%X", BackOffMask);
2222 }
2223 // CONSIDER: BackOffMask = ROUNDUP_NEXT_POWER2 (ncpus-1)
2224 } else {
2225 Knob_SpinLimit = 0;
2226 Knob_SpinBase = 0;
2227 Knob_PreSpin = 0;
2228 Knob_FixedSpin = -1;
2229 }
2230
2231 OrderAccess::fence();
2232 InitDone = 1;
2233 }
2234
|