changeset 47632:0c2e1f8eccaa

8187042: Events to show which objects are associated with biased object revocations Reviewed-by: mgronlun, dholmes, egahlin Contributed-by: robin.westberg@oracle.com
author egahlin
date Mon, 16 Oct 2017 18:25:07 +0200
parents 494e1490b341
children 1c21c60f51bf
files src/hotspot/share/runtime/biasedLocking.cpp src/hotspot/share/trace/traceevents.xml
diffstat 2 files changed, 39 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/runtime/biasedLocking.cpp	Mon Oct 16 16:44:23 2017 +0200
+++ b/src/hotspot/share/runtime/biasedLocking.cpp	Mon Oct 16 18:25:07 2017 +0200
@@ -35,6 +35,7 @@
 #include "runtime/vframe.hpp"
 #include "runtime/vmThread.hpp"
 #include "runtime/vm_operations.hpp"
+#include "trace/tracing.hpp"
 
 static bool _biased_locking_enabled = false;
 BiasedLockingCounters BiasedLocking::_counters;
@@ -643,23 +644,43 @@
       // stale epoch.
       ResourceMark rm;
       log_info(biasedlocking)("Revoking bias by walking my own stack:");
+      EventBiasedLockSelfRevocation event;
       BiasedLocking::Condition cond = revoke_bias(obj(), false, false, (JavaThread*) THREAD);
       ((JavaThread*) THREAD)->set_cached_monitor_info(NULL);
       assert(cond == BIAS_REVOKED, "why not?");
+      if (event.should_commit()) {
+        event.set_lockClass(k);
+        event.commit();
+      }
       return cond;
     } else {
+      EventBiasedLockRevocation event;
       VM_RevokeBias revoke(&obj, (JavaThread*) THREAD);
       VMThread::execute(&revoke);
+      if (event.should_commit() && (revoke.status_code() != NOT_BIASED)) {
+        event.set_lockClass(k);
+        // Subtract 1 to match the id of events committed inside the safepoint
+        event.set_safepointId(SafepointSynchronize::safepoint_counter() - 1);
+        event.commit();
+      }
       return revoke.status_code();
     }
   }
 
   assert((heuristics == HR_BULK_REVOKE) ||
          (heuristics == HR_BULK_REBIAS), "?");
+  EventBiasedLockClassRevocation event;
   VM_BulkRevokeBias bulk_revoke(&obj, (JavaThread*) THREAD,
                                 (heuristics == HR_BULK_REBIAS),
                                 attempt_rebias);
   VMThread::execute(&bulk_revoke);
+  if (event.should_commit()) {
+    event.set_revokedClass(obj->klass());
+    event.set_disableBiasing((heuristics != HR_BULK_REBIAS));
+    // Subtract 1 to match the id of events committed inside the safepoint
+    event.set_safepointId(SafepointSynchronize::safepoint_counter() - 1);
+    event.commit();
+  }
   return bulk_revoke.status_code();
 }
 
--- a/src/hotspot/share/trace/traceevents.xml	Mon Oct 16 16:44:23 2017 +0200
+++ b/src/hotspot/share/trace/traceevents.xml	Mon Oct 16 18:25:07 2017 +0200
@@ -104,6 +104,24 @@
     <value type="INFLATECAUSE" field="cause" label="Monitor Inflation Cause" description="Cause of inflation"/>
   </event>
 
+  <event id="BiasedLockRevocation" path="java/biased_lock_revocation" label="Biased Lock Revocation"
+         description="Revoked bias of object" has_thread="true" has_stacktrace="true" is_instant="false">
+    <value type="CLASS" field="lockClass" label="Lock Class" description="Class of object whose biased lock was revoked"/>
+    <value type="INTEGER" field="safepointId" label="Safepoint Identifier" relation="SafepointId"/>
+  </event>
+
+  <event id="BiasedLockSelfRevocation" path="java/biased_lock_self_revocation" label="Biased Lock Self Revocation"
+         description="Revoked bias of object biased towards own thread" has_thread="true" has_stacktrace="true" is_instant="false">
+    <value type="CLASS" field="lockClass" label="Lock Class" description="Class of object whose biased lock was revoked"/>
+  </event>
+
+  <event id="BiasedLockClassRevocation" path="java/biased_lock_class_revocation" label="Biased Lock Class Revocation"
+         description="Revoked biases for all instances of a class" has_thread="true" has_stacktrace="true" is_instant="false">
+    <value type="CLASS" field="revokedClass" label="Revoked Class" description="Class whose biased locks were revoked"/>
+    <value type="BOOLEAN" field="disableBiasing" label="Disable Further Biasing" description="Whether further biasing for instances of this class will be allowed"/>
+    <value type="INTEGER" field="safepointId" label="Safepoint Identifier" relation="SafepointId"/>
+  </event>
+
   <event id="ReservedStackActivation" path="vm/runtime/reserved_stack_activation" label="Reserved Stack Activation"
          description="Activation of Reserved Stack Area caused by stack overflow with ReservedStackAccess annotated method in call stack"
          has_thread="true" has_stacktrace="true" is_instant="true">