RFR: Use os::naked_short_sleep instead of naked Thread events for sleeping
Aleksey Shipilev
shade at redhat.com
Wed Mar 7 10:15:09 UTC 2018
We are now using woefully dangerous Thread::current()->_ParkEvent for sleeping, which is a very
low-level primitive for synchronization. _ParkEvent is not even for sleeping, it is for Java
synchronization, and the protocol seems to require calling reset() before sleeping on it? Anyhow,
using the os::naked_short_sleep is what other VM code is doing for these sleeps, and we should do
the same.
diff -r 58279d273cc4 src/hotspot/share/gc/shenandoah/shenandoahConcurrentThread.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentThread.cpp Mon Mar 05 17:05:30 2018 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentThread.cpp Wed Mar 07 11:13:54 2018 +0100
@@ -194,7 +194,7 @@
}
// Wait before performing the next action
- Thread::current()->_ParkEvent->park(ShenandoahControlLoopInterval);
+ os::naked_short_sleep(ShenandoahControlLoopInterval);
// Make sure the _do_full_gc flag changes are seen.
OrderAccess::storeload();
@@ -202,7 +202,7 @@
// Wait for the actual stop(), can't leave run_service() earlier.
while (!should_terminate()) {
- Thread::current()->_ParkEvent->park(10);
+ os::naked_short_sleep(10);
}
}
@@ -444,7 +444,7 @@
GCCause::to_string(GCCause::_shenandoah_allocation_failure_evac),
Thread::current()->name());
while (heap->is_evacuation_in_progress()) { // wait.
- Thread::current()->_ParkEvent->park(1);
+ os::naked_short_sleep(1);
}
}
}
diff -r 58279d273cc4 src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Mon Mar 05 17:05:30 2018 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Wed Mar 07 11:13:54 2018 +0100
@@ -2849,7 +2849,7 @@
void ShenandoahHeap::try_inject_alloc_failure() {
if (ShenandoahAllocFailureALot && !cancelled_concgc() && ((os::random() % 1000) > 950)) {
_inject_alloc_failure.set();
- Thread::current()->_ParkEvent->park(1);
+ os::naked_short_sleep(1);
if (cancelled_concgc()) {
log_info(gc)("Allocation failure was successfully injected");
}
Testing: hotspot_gc_shenandoah
Thanks,
-Aleksey
More information about the shenandoah-dev
mailing list