8210889: Some service thread cleanups can be starved

Do all available work on each iteration.

Reviewed-by: pliden, tschatzl, coleenp
This commit is contained in:
Kim Barrett 2018-09-19 20:07:02 -04:00
parent a24c991cd3
commit ea9331f871

View File

@ -86,7 +86,6 @@ void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) {
bool has_jvmti_events = false; bool has_jvmti_events = false;
bool has_gc_notification_event = false; bool has_gc_notification_event = false;
bool has_dcmd_notification_event = false; bool has_dcmd_notification_event = false;
bool acs_notify = false;
bool stringtable_work = false; bool stringtable_work = false;
bool symboltable_work = false; bool symboltable_work = false;
bool resolved_method_table_work = false; bool resolved_method_table_work = false;
@ -104,16 +103,20 @@ void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) {
ThreadBlockInVM tbivm(jt); ThreadBlockInVM tbivm(jt);
MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag); MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
while (!(sensors_changed = LowMemoryDetector::has_pending_requests()) && // Process all available work on each (outer) iteration, rather than
!(has_jvmti_events = JvmtiDeferredEventQueue::has_events()) && // only the first recognized bit of work, to avoid frequently true early
!(has_gc_notification_event = GCNotifier::has_event()) && // tests from potentially starving later work. Hence the use of
!(has_dcmd_notification_event = DCmdFactory::has_pending_jmx_notification()) && // arithmetic-or to combine results; we don't want short-circuiting.
!(stringtable_work = StringTable::has_work()) && while (((sensors_changed = LowMemoryDetector::has_pending_requests()) |
!(symboltable_work = SymbolTable::has_work()) && (has_jvmti_events = JvmtiDeferredEventQueue::has_events()) |
!(resolved_method_table_work = ResolvedMethodTable::has_work()) && (has_gc_notification_event = GCNotifier::has_event()) |
!(protection_domain_table_work = SystemDictionary::pd_cache_table()->has_work())) { (has_dcmd_notification_event = DCmdFactory::has_pending_jmx_notification()) |
// wait until one of the sensors has pending requests, or there is a (stringtable_work = StringTable::has_work()) |
// pending JVMTI event or JMX GC notification to post (symboltable_work = SymbolTable::has_work()) |
(resolved_method_table_work = ResolvedMethodTable::has_work()) |
(protection_domain_table_work = SystemDictionary::pd_cache_table()->has_work()))
== 0) {
// Wait until notified that there is some work to do.
Service_lock->wait(Mutex::_no_safepoint_check_flag); Service_lock->wait(Mutex::_no_safepoint_check_flag);
} }