Skip to content

Commit

Permalink
8305819: LogConfigurationTest intermittently fails on AArch64
Browse files Browse the repository at this point in the history
Reviewed-by: mdoerr
Backport-of: 911cc7cb07ed44b24b4c20977d7d6e475bd1b234
  • Loading branch information
Liang Mao authored and TheRealMDoerr committed May 16, 2024
1 parent 0a3445e commit 18bb8da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/hotspot/share/logging/logOutputList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,22 @@ void LogOutputList::add_output(LogOutput* output, LogLevelType level) {
node->_next = node->_next->_next) {
}

// To allow lock-free iteration of the output list the updates in the loops
// below require release semantics.
OrderAccess::release();

// Update the _level_start index
for (int l = LogLevel::Last; l >= level; l--) {
if (_level_start[l] == NULL || _level_start[l]->_level < level) {
_level_start[l] = node;
LogOutputNode* lnode = Atomic::load(&_level_start[l]);
if (lnode == nullptr || lnode->_level < level) {
Atomic::store(&_level_start[l], node);
}
}

// Add the node the list
for (LogOutputNode* cur = _level_start[LogLevel::Last]; cur != NULL; cur = cur->_next) {
if (cur != node && cur->_next == node->_next) {
cur->_next = node;
for (LogOutputNode* cur = Atomic::load(&_level_start[LogLevel::Last]); cur != nullptr; cur = Atomic::load(&cur->_next)) {
if (cur != node && Atomic::load(&cur->_next) == node->_next) {
Atomic::store(&cur->_next, node);
break;
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/hotspot/share/logging/logOutputList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "logging/logLevel.hpp"
#include "memory/allocation.hpp"
#include "runtime/atomic.hpp"
#include "utilities/globalDefinitions.hpp"

class LogOutput;
Expand All @@ -48,11 +49,11 @@ class LogOutputList {
private:
struct LogOutputNode : public CHeapObj<mtLogging> {
LogOutput* _value;
LogOutputNode* _next;
LogOutputNode* volatile _next;
LogLevelType _level;
};

LogOutputNode* _level_start[LogLevel::Count];
LogOutputNode* volatile _level_start[LogLevel::Count];
volatile jint _active_readers;

LogOutputNode* find(const LogOutput* output) const;
Expand Down Expand Up @@ -124,7 +125,9 @@ class LogOutputList {
}

void operator++(int) {
_current = _current->_next;
// FIXME: memory_order_consume could be used here.
// Atomic access on the reading side for LogOutputList.
_current = Atomic::load_acquire(&_current->_next);
}

bool operator!=(const LogOutputNode *ref) const {
Expand All @@ -138,7 +141,9 @@ class LogOutputList {

Iterator iterator(LogLevelType level = LogLevel::Last) {
increase_readers();
return Iterator(this, _level_start[level]);
// FIXME: memory_order_consume could be used here.
// Atomic access on the reading side for LogOutputList.
return Iterator(this, Atomic::load_acquire(&_level_start[level]));
}

LogOutputNode* end() const {
Expand Down

1 comment on commit 18bb8da

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.