8212108: SafepointSynchronizer never ending counter (big enough)

Reviewed-by: dholmes, eosterlund
This commit is contained in:
Robbin Ehn 2018-11-23 10:43:18 +01:00
parent 954c14dc83
commit 72235f33c7
6 changed files with 38 additions and 29 deletions

View file

@ -118,13 +118,13 @@ class DependencyContext : public StackObj {
// Safepoints are forbidden during DC lifetime. GC can invalidate // Safepoints are forbidden during DC lifetime. GC can invalidate
// _dependency_context_addr if it relocates the holder // _dependency_context_addr if it relocates the holder
// (e.g. CallSiteContext Java object). // (e.g. CallSiteContext Java object).
int _safepoint_counter; uint64_t _safepoint_counter;
DependencyContext(intptr_t* addr) : _dependency_context_addr(addr), DependencyContext(intptr_t* addr) : _dependency_context_addr(addr),
_safepoint_counter(SafepointSynchronize::_safepoint_counter) {} _safepoint_counter(SafepointSynchronize::safepoint_counter()) {}
~DependencyContext() { ~DependencyContext() {
assert(_safepoint_counter == SafepointSynchronize::_safepoint_counter, "safepoint happened"); assert(_safepoint_counter == SafepointSynchronize::safepoint_counter(), "safepoint happened");
} }
#else #else
DependencyContext(intptr_t* addr) : _dependency_context_addr(addr) {} DependencyContext(intptr_t* addr) : _dependency_context_addr(addr) {}

View file

@ -67,7 +67,7 @@
<Event name="BiasedLockRevocation" category="Java Application" label="Biased Lock Revocation" description="Revoked bias of object" thread="true" <Event name="BiasedLockRevocation" category="Java Application" label="Biased Lock Revocation" description="Revoked bias of object" thread="true"
stackTrace="true"> stackTrace="true">
<Field type="Class" name="lockClass" label="Lock Class" description="Class of object whose biased lock was revoked" /> <Field type="Class" name="lockClass" label="Lock Class" description="Class of object whose biased lock was revoked" />
<Field type="int" name="safepointId" label="Safepoint Identifier" relation="SafepointId" /> <Field type="ulong" name="safepointId" label="Safepoint Identifier" relation="SafepointId" />
<Field type="Thread" name="previousOwner" label="Previous Owner" description="Thread owning the bias before revocation" /> <Field type="Thread" name="previousOwner" label="Previous Owner" description="Thread owning the bias before revocation" />
</Event> </Event>
@ -80,7 +80,7 @@
thread="true" stackTrace="true"> thread="true" stackTrace="true">
<Field type="Class" name="revokedClass" label="Revoked Class" description="Class whose biased locks were revoked" /> <Field type="Class" name="revokedClass" label="Revoked Class" description="Class whose biased locks were revoked" />
<Field type="boolean" name="disableBiasing" label="Disable Further Biasing" description="Whether further biasing for instances of this class will be allowed" /> <Field type="boolean" name="disableBiasing" label="Disable Further Biasing" description="Whether further biasing for instances of this class will be allowed" />
<Field type="int" name="safepointId" label="Safepoint Identifier" relation="SafepointId" /> <Field type="ulong" name="safepointId" label="Safepoint Identifier" relation="SafepointId" />
</Event> </Event>
<Event name="ReservedStackActivation" category="Java Virtual Machine, Runtime" label="Reserved Stack Activation" <Event name="ReservedStackActivation" category="Java Virtual Machine, Runtime" label="Reserved Stack Activation"
@ -519,14 +519,14 @@
</Event> </Event>
<Event name="SafepointBegin" category="Java Virtual Machine, Runtime, Safepoint" label="Safepoint Begin" description="Safepointing begin" thread="true"> <Event name="SafepointBegin" category="Java Virtual Machine, Runtime, Safepoint" label="Safepoint Begin" description="Safepointing begin" thread="true">
<Field type="int" name="safepointId" label="Safepoint Identifier" relation="SafepointId" /> <Field type="ulong" name="safepointId" label="Safepoint Identifier" relation="SafepointId" />
<Field type="int" name="totalThreadCount" label="Total Threads" description="The total number of threads at the start of safe point" /> <Field type="int" name="totalThreadCount" label="Total Threads" description="The total number of threads at the start of safe point" />
<Field type="int" name="jniCriticalThreadCount" label="JNI Critical Threads" description="The number of threads in JNI critical sections" /> <Field type="int" name="jniCriticalThreadCount" label="JNI Critical Threads" description="The number of threads in JNI critical sections" />
</Event> </Event>
<Event name="SafepointStateSynchronization" category="Java Virtual Machine, Runtime, Safepoint" label="Safepoint State Synchronization" description="Synchronize run state of threads" <Event name="SafepointStateSynchronization" category="Java Virtual Machine, Runtime, Safepoint" label="Safepoint State Synchronization" description="Synchronize run state of threads"
thread="true"> thread="true">
<Field type="int" name="safepointId" label="Safepoint Identifier" relation="SafepointId" /> <Field type="ulong" name="safepointId" label="Safepoint Identifier" relation="SafepointId" />
<Field type="int" name="initialThreadCount" label="Initial Threads" description="The number of threads running at the beginning of state check" /> <Field type="int" name="initialThreadCount" label="Initial Threads" description="The number of threads running at the beginning of state check" />
<Field type="int" name="runningThreadCount" label="Running Threads" description="The number of threads still running" /> <Field type="int" name="runningThreadCount" label="Running Threads" description="The number of threads still running" />
<Field type="int" name="iterations" label="Iterations" description="Number of state check iterations" /> <Field type="int" name="iterations" label="Iterations" description="Number of state check iterations" />
@ -534,23 +534,23 @@
<Event name="SafepointWaitBlocked" category="Java Virtual Machine, Runtime, Safepoint" label="Safepoint Wait Blocked" description="Safepointing begin waiting on running threads to block" <Event name="SafepointWaitBlocked" category="Java Virtual Machine, Runtime, Safepoint" label="Safepoint Wait Blocked" description="Safepointing begin waiting on running threads to block"
thread="true"> thread="true">
<Field type="int" name="safepointId" label="Safepoint Identifier" relation="SafepointId" /> <Field type="ulong" name="safepointId" label="Safepoint Identifier" relation="SafepointId" />
<Field type="int" name="runningThreadCount" label="Running Threads" description="The number running of threads wait for safe point" /> <Field type="int" name="runningThreadCount" label="Running Threads" description="The number running of threads wait for safe point" />
</Event> </Event>
<Event name="SafepointCleanup" category="Java Virtual Machine, Runtime, Safepoint" label="Safepoint Cleanup" description="Safepointing begin running cleanup tasks" <Event name="SafepointCleanup" category="Java Virtual Machine, Runtime, Safepoint" label="Safepoint Cleanup" description="Safepointing begin running cleanup tasks"
thread="true"> thread="true">
<Field type="int" name="safepointId" label="Safepoint Identifier" relation="SafepointId" /> <Field type="ulong" name="safepointId" label="Safepoint Identifier" relation="SafepointId" />
</Event> </Event>
<Event name="SafepointCleanupTask" category="Java Virtual Machine, Runtime, Safepoint" label="Safepoint Cleanup Task" description="Safepointing begin running cleanup tasks" <Event name="SafepointCleanupTask" category="Java Virtual Machine, Runtime, Safepoint" label="Safepoint Cleanup Task" description="Safepointing begin running cleanup tasks"
thread="true"> thread="true">
<Field type="int" name="safepointId" label="Safepoint Identifier" relation="SafepointId" /> <Field type="ulong" name="safepointId" label="Safepoint Identifier" relation="SafepointId" />
<Field type="string" name="name" label="Task Name" description="The task name" /> <Field type="string" name="name" label="Task Name" description="The task name" />
</Event> </Event>
<Event name="SafepointEnd" category="Java Virtual Machine, Runtime, Safepoint" label="Safepoint End" description="Safepointing end" thread="true"> <Event name="SafepointEnd" category="Java Virtual Machine, Runtime, Safepoint" label="Safepoint End" description="Safepointing end" thread="true">
<Field type="int" name="safepointId" label="Safepoint Identifier" relation="SafepointId" /> <Field type="ulong" name="safepointId" label="Safepoint Identifier" relation="SafepointId" />
</Event> </Event>
<Event name="ExecuteVMOperation" category="Java Virtual Machine, Runtime" label="VM Operation" description="Execution of a VM Operation" thread="true"> <Event name="ExecuteVMOperation" category="Java Virtual Machine, Runtime" label="VM Operation" description="Execution of a VM Operation" thread="true">
@ -559,7 +559,7 @@
<Field type="boolean" name="blocking" label="Caller Blocked" description="If the calling thread was blocked until the operation was complete" /> <Field type="boolean" name="blocking" label="Caller Blocked" description="If the calling thread was blocked until the operation was complete" />
<Field type="Thread" name="caller" label="Caller" transition="from" <Field type="Thread" name="caller" label="Caller" transition="from"
description="Thread requesting operation. If non-blocking, will be set to 0 indicating thread is unknown" /> description="Thread requesting operation. If non-blocking, will be set to 0 indicating thread is unknown" />
<Field type="int" name="safepointId" label="Safepoint Identifier" description="The safepoint (if any) under which this operation was completed" <Field type="ulong" name="safepointId" label="Safepoint Identifier" description="The safepoint (if any) under which this operation was completed"
relation="SafepointId" /> relation="SafepointId" />
</Event> </Event>

View file

@ -141,7 +141,7 @@ static void post_safepoint_end_event(EventSafepointEnd* event) {
SafepointSynchronize::SynchronizeState volatile SafepointSynchronize::_state = SafepointSynchronize::_not_synchronized; SafepointSynchronize::SynchronizeState volatile SafepointSynchronize::_state = SafepointSynchronize::_not_synchronized;
volatile int SafepointSynchronize::_waiting_to_block = 0; volatile int SafepointSynchronize::_waiting_to_block = 0;
volatile int SafepointSynchronize::_safepoint_counter = 0; volatile uint64_t SafepointSynchronize::_safepoint_counter = 0;
int SafepointSynchronize::_current_jni_active_count = 0; int SafepointSynchronize::_current_jni_active_count = 0;
long SafepointSynchronize::_end_of_last_safepoint = 0; long SafepointSynchronize::_end_of_last_safepoint = 0;
int SafepointSynchronize::_defer_thr_suspend_loop_count = 4000; int SafepointSynchronize::_defer_thr_suspend_loop_count = 4000;

View file

@ -101,8 +101,8 @@ class SafepointSynchronize : AllStatic {
// safepoint. The fact that Threads_lock is held throughout each pair of // safepoint. The fact that Threads_lock is held throughout each pair of
// increments (at the beginning and end of each safepoint) guarantees // increments (at the beginning and end of each safepoint) guarantees
// race freedom. // race freedom.
public: static volatile uint64_t _safepoint_counter;
static volatile int _safepoint_counter;
private: private:
static long _end_of_last_safepoint; // Time of last safepoint in milliseconds static long _end_of_last_safepoint; // Time of last safepoint in milliseconds
static julong _coalesced_vmop_count; // coalesced vmop count static julong _coalesced_vmop_count; // coalesced vmop count
@ -134,7 +134,7 @@ public:
// Query // Query
inline static bool is_at_safepoint() { return _state == _synchronized; } inline static bool is_at_safepoint() { return _state == _synchronized; }
inline static bool is_synchronizing() { return _state == _synchronizing; } inline static bool is_synchronizing() { return _state == _synchronizing; }
inline static int safepoint_counter() { return _safepoint_counter; } inline static uint64_t safepoint_counter() { return _safepoint_counter; }
inline static void increment_jni_active_count() { inline static void increment_jni_active_count() {
assert_locked_or_safepoint(Safepoint_lock); assert_locked_or_safepoint(Safepoint_lock);
@ -176,8 +176,17 @@ public:
// Assembly support // Assembly support
static address address_of_state() { return (address)&_state; } static address address_of_state() { return (address)&_state; }
static address safepoint_counter_addr() { return (address)&_safepoint_counter; } // Only used for making sure that no safepoint has happened in
// JNI_FastGetField. Therefore only the low 32-bits are needed
// even if this is a 64-bit counter.
static address safepoint_counter_addr() {
#ifdef VM_LITTLE_ENDIAN
return (address)&_safepoint_counter;
#else /* BIG */
// Return pointer to the 32 LSB:
return (address) (((uint32_t*)(&_safepoint_counter)) + 1);
#endif
}
}; };
// Some helper assert macros for safepoint checks. // Some helper assert macros for safepoint checks.

View file

@ -275,13 +275,13 @@ public class TestBiasedLockRevocationEvents {
List<RecordedEvent> events = Events.fromRecording(recording); List<RecordedEvent> events = Events.fromRecording(recording);
// Determine which safepoints included single and bulk revocation VM operations // Determine which safepoints included single and bulk revocation VM operations
Set<Integer> vmOperationsSingle = new HashSet<>(); Set<Long> vmOperationsSingle = new HashSet<>();
Set<Integer> vmOperationsBulk = new HashSet<>(); Set<Long> vmOperationsBulk = new HashSet<>();
for (RecordedEvent event : events) { for (RecordedEvent event : events) {
if (event.getEventType().getName().equals(EventNames.ExecuteVMOperation)) { if (event.getEventType().getName().equals(EventNames.ExecuteVMOperation)) {
String operation = event.getValue("operation"); String operation = event.getValue("operation");
Integer safepointId = event.getValue("safepointId"); Long safepointId = event.getValue("safepointId");
if (operation.equals("RevokeBias")) { if (operation.equals("RevokeBias")) {
vmOperationsSingle.add(safepointId); vmOperationsSingle.add(safepointId);
@ -297,14 +297,14 @@ public class TestBiasedLockRevocationEvents {
// Match all revoke events to a corresponding VMOperation event // Match all revoke events to a corresponding VMOperation event
for (RecordedEvent event : events) { for (RecordedEvent event : events) {
if (event.getEventType().getName().equals(EventNames.BiasedLockRevocation)) { if (event.getEventType().getName().equals(EventNames.BiasedLockRevocation)) {
Integer safepointId = event.getValue("safepointId"); Long safepointId = event.getValue("safepointId");
String lockClass = ((RecordedClass)event.getValue("lockClass")).getName(); String lockClass = ((RecordedClass)event.getValue("lockClass")).getName();
if (lockClass.equals(MyLock.class.getName())) { if (lockClass.equals(MyLock.class.getName())) {
Asserts.assertTrue(vmOperationsSingle.contains(safepointId)); Asserts.assertTrue(vmOperationsSingle.contains(safepointId));
revokeCount++; revokeCount++;
} }
} else if (event.getEventType().getName().equals(EventNames.BiasedLockClassRevocation)) { } else if (event.getEventType().getName().equals(EventNames.BiasedLockClassRevocation)) {
Integer safepointId = event.getValue("safepointId"); Long safepointId = event.getValue("safepointId");
String lockClass = ((RecordedClass)event.getValue("revokedClass")).getName(); String lockClass = ((RecordedClass)event.getValue("revokedClass")).getName();
if (lockClass.toString().equals(MyLock.class.getName())) { if (lockClass.toString().equals(MyLock.class.getName())) {
Asserts.assertTrue(vmOperationsBulk.contains(safepointId)); Asserts.assertTrue(vmOperationsBulk.contains(safepointId));

View file

@ -84,9 +84,9 @@ public class TestSafepointEvents {
} }
// Collect all events grouped by safepoint id // Collect all events grouped by safepoint id
SortedMap<Integer, Set<String>> safepointIds = new TreeMap<>(); SortedMap<Long, Set<String>> safepointIds = new TreeMap<>();
for (RecordedEvent event : Events.fromRecording(recording)) { for (RecordedEvent event : Events.fromRecording(recording)) {
Integer safepointId = event.getValue("safepointId"); Long safepointId = event.getValue("safepointId");
if (!safepointIds.containsKey(safepointId)) { if (!safepointIds.containsKey(safepointId)) {
safepointIds.put(safepointId, new HashSet<>()); safepointIds.put(safepointId, new HashSet<>());
} }