8214315: G1: fatal error: acquiring lock SATB_Q_FL_lock/1 out of order with lock tty_lock/0

Add new 'tty' lock rank.

Reviewed-by: eosterlund, tschatzl
This commit is contained in:
Kim Barrett 2018-12-08 18:52:57 -05:00
parent 5c30297045
commit b80d335354
3 changed files with 9 additions and 6 deletions

View File

@ -1076,9 +1076,9 @@ bool Monitor::wait(bool no_safepoint_check, long timeout,
Monitor * least = get_least_ranked_lock_besides_this(Self->owned_locks());
assert(least != this, "Specification of get_least_... call above");
if (least != NULL && least->rank() <= special) {
tty->print("Attempting to wait on monitor %s/%d while holding"
" lock %s/%d -- possible deadlock",
name(), rank(), least->name(), least->rank());
::tty->print("Attempting to wait on monitor %s/%d while holding"
" lock %s/%d -- possible deadlock",
name(), rank(), least->name(), least->rank());
assert(false, "Shouldn't block(wait) while holding a lock of rank special");
}
#endif // ASSERT

View File

@ -87,6 +87,8 @@ class Monitor : public CHeapObj<mtInternal> {
// The rank 'access' is similar to 'special' and has the same restrictions on usage.
// It is reserved for locks that may be required in order to perform memory accesses
// that require special barriers, e.g. SATB GC barriers, that in turn uses locks.
// The rank 'tty' is also similar to 'special' and has the same restrictions.
// It is reserved for the tty_lock.
// Since memory accesses should be able to be performed pretty much anywhere
// in the code, that requires locks required for performing accesses being
// inherently a bit more special than even locks of the 'special' rank.
@ -104,7 +106,8 @@ class Monitor : public CHeapObj<mtInternal> {
enum lock_types {
event,
access = event + 1,
special = access + 2,
tty = access + 2,
special = tty + 1,
suspend_resume = special + 1,
vmweak = suspend_resume + 2,
leaf = vmweak + 2,
@ -236,7 +239,7 @@ class Monitor : public CHeapObj<mtInternal> {
#ifndef PRODUCT
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void print() const { print_on(::tty); }
DEBUG_ONLY(int rank() const { return _rank; })
bool allow_vm_block() { return _allow_vm_block; }

View File

@ -199,7 +199,7 @@ void assert_lock_strong(const Monitor * lock) {
// Using Padded subclasses to prevent false sharing of these global monitors and mutexes.
void mutex_init() {
def(tty_lock , PaddedMutex , event, true, Monitor::_safepoint_check_never); // allow to lock in VM
def(tty_lock , PaddedMutex , tty, true, Monitor::_safepoint_check_never); // allow to lock in VM
def(CGC_lock , PaddedMonitor, special, true, Monitor::_safepoint_check_never); // coordinate between fore- and background GC
def(STS_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_never);