8286707: JFR: Don't commit JFR internal jdk.JavaMonitorWait events

Reviewed-by: dholmes, egahlin
This commit is contained in:
Joakim Nordström 2022-10-19 10:34:17 +00:00 committed by Markus Grönlund
parent 857b0f9b05
commit fc889577ea
6 changed files with 26 additions and 9 deletions

View File

@ -38,7 +38,7 @@ static jobject install_chunk_monitor(JavaThread* thread) {
// read static field
HandleMark hm(thread);
static const char klass[] = "jdk/jfr/internal/JVM";
static const char field[] = "FILE_DELTA_CHANGE";
static const char field[] = "CHUNK_ROTATION_MONITOR";
static const char signature[] = "Ljava/lang/Object;";
JavaValue result(T_OBJECT);
JfrJavaArguments field_args(&result, klass, field, signature, thread);

View File

@ -52,6 +52,7 @@ class JfrIntrinsicSupport : AllStatic {
template(getEventWriter_signature, "()Ljdk/jfr/internal/event/EventWriter;") \
template(eventConfiguration_name, "eventConfiguration") \
template(commit_name, "commit") \
template(jfr_chunk_rotation_monitor, "jdk/jfr/internal/JVM$ChunkRotationMonitor") \
#define JFR_INTRINSICS(do_intrinsic, do_class, do_name, do_signature, do_alias) \
do_intrinsic(_counterTime, jdk_jfr_internal_JVM, counterTime_name, void_long_signature, F_SN) \

View File

@ -1416,6 +1416,12 @@ bool ObjectMonitor::check_owner(TRAPS) {
"current thread is not owner", false);
}
static inline bool is_excluded(const Klass* monitor_klass) {
assert(monitor_klass != nullptr, "invariant");
NOT_JFR_RETURN_(false);
JFR_ONLY(return vmSymbols::jfr_chunk_rotation_monitor() == monitor_klass->name());
}
static void post_monitor_wait_event(EventJavaMonitorWait* event,
ObjectMonitor* monitor,
uint64_t notifier_tid,
@ -1423,7 +1429,11 @@ static void post_monitor_wait_event(EventJavaMonitorWait* event,
bool timedout) {
assert(event != NULL, "invariant");
assert(monitor != NULL, "invariant");
event->set_monitorClass(monitor->object()->klass());
const Klass* monitor_klass = monitor->object()->klass();
if (is_excluded(monitor_klass)) {
return;
}
event->set_monitorClass(monitor_klass);
event->set_timeout(timeout);
// Set an address that is 'unique enough', such that events close in
// time and with the same address are likely (but not guaranteed) to

View File

@ -39,11 +39,17 @@ import jdk.jfr.internal.event.EventWriter;
public final class JVM {
private static final JVM jvm = new JVM();
// JVM signals file changes by doing Object#notify on this object
static final Object FILE_DELTA_CHANGE = new Object();
static final long RESERVED_CLASS_ID_LIMIT = 500;
private static class ChunkRotationMonitor {}
/*
* The JVM uses the chunk rotation monitor to notify Java that a rotation is warranted.
* The monitor type is used to exclude jdk.JavaMonitorWait events from being generated
* when Object.wait() is called on this monitor.
*/
static final Object CHUNK_ROTATION_MONITOR = new ChunkRotationMonitor();
private volatile boolean nativeOK;
private static native void registerNatives();

View File

@ -520,8 +520,8 @@ public final class PlatformRecorder {
private void takeNap(long duration) {
try {
synchronized (JVM.FILE_DELTA_CHANGE) {
JVM.FILE_DELTA_CHANGE.wait(duration < 10 ? 10 : duration);
synchronized (JVM.CHUNK_ROTATION_MONITOR) {
JVM.CHUNK_ROTATION_MONITOR.wait(duration < 10 ? 10 : duration);
}
} catch (InterruptedException e) {
// Ignore

View File

@ -302,8 +302,8 @@ public final class RequestEngine {
boolean needNotify = interval < flushInterval;
flushInterval = interval;
if (needNotify) {
synchronized (JVM.FILE_DELTA_CHANGE) {
JVM.FILE_DELTA_CHANGE.notifyAll();
synchronized (JVM.CHUNK_ROTATION_MONITOR) {
JVM.CHUNK_ROTATION_MONITOR.notifyAll();
}
}
}