diff --git a/src/hotspot/share/utilities/events.cpp b/src/hotspot/share/utilities/events.cpp index 6adb5311cb5..d2b8e7ba5da 100644 --- a/src/hotspot/share/utilities/events.cpp +++ b/src/hotspot/share/utilities/events.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,14 +26,15 @@ #include "memory/allocation.inline.hpp" #include "oops/instanceKlass.hpp" #include "oops/symbol.hpp" -#include "runtime/atomicAccess.hpp" +#include "runtime/atomic.hpp" #include "runtime/javaThread.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/osThread.hpp" #include "runtime/timer.hpp" #include "utilities/events.hpp" -EventLog* Events::_logs = nullptr; +static Atomic event_logs_list{}; + StringEventLog* Events::_messages = nullptr; StringEventLog* Events::_memprotect_messages = nullptr; StringEventLog* Events::_nmethod_flush_messages = nullptr; @@ -51,15 +52,15 @@ EventLog::EventLog() { // but use lock free add because there are some events that are created later. EventLog* old_head; do { - old_head = AtomicAccess::load(&Events::_logs); + old_head = event_logs_list.load_relaxed(); _next = old_head; - } while (AtomicAccess::cmpxchg(&Events::_logs, old_head, this) != old_head); + } while (!event_logs_list.compare_set(old_head, this)); } // For each registered event logger, print out the current contents of // the buffer. void Events::print_all(outputStream* out, int max) { - EventLog* log = AtomicAccess::load(&Events::_logs); + EventLog* log = event_logs_list.load_relaxed(); while (log != nullptr) { log->print_log_on(out, max); log = log->next(); @@ -68,7 +69,7 @@ void Events::print_all(outputStream* out, int max) { // Print a single event log specified by name. void Events::print_one(outputStream* out, const char* log_name, int max) { - EventLog* log = AtomicAccess::load(&Events::_logs); + EventLog* log = event_logs_list.load_relaxed(); int num_printed = 0; while (log != nullptr) { if (log->matches_name_or_handle(log_name)) { @@ -81,7 +82,7 @@ void Events::print_one(outputStream* out, const char* log_name, int max) { if (num_printed == 0) { out->print_cr("The name \"%s\" did not match any known event log. " "Valid event log names are:", log_name); - EventLog* log = AtomicAccess::load(&Events::_logs); + EventLog* log = event_logs_list.load_relaxed(); while (log != nullptr) { log->print_names(out); out->cr(); diff --git a/src/hotspot/share/utilities/events.hpp b/src/hotspot/share/utilities/events.hpp index cbbed7232fb..0d1c08548ff 100644 --- a/src/hotspot/share/utilities/events.hpp +++ b/src/hotspot/share/utilities/events.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -214,10 +214,7 @@ class ExceptionsEventLog : public ExtendedStringEventLog { class Events : AllStatic { - friend class EventLog; - private: - static EventLog* _logs; // A log for generic messages that aren't well categorized. static StringEventLog* _messages;