Skip to content

Commit

Permalink
8305819: LogConfigurationTest intermittently fails on AArch64
Browse files Browse the repository at this point in the history
Reviewed-by: aph, dholmes, xliu
  • Loading branch information
gaogao-mem authored and y1yang0 committed May 15, 2023
1 parent 8d49ba9 commit 911cc7c
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 @@ -127,17 +127,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] == nullptr || _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 != nullptr; 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 911cc7c

@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.