diff options
author | 2023-12-19 18:48:15 +0000 | |
---|---|---|
committer | 2023-12-19 20:32:27 +0000 | |
commit | 8bc6a58df7046b4d6f4b51eb274c7e60fea396ff (patch) | |
tree | ac6aa639279f5cf2048cb147a91cbea98c8088a4 /runtime/base/mutex.cc | |
parent | ee7471ec0a7aba338c3ac90de0f2ef0be9a35fed (diff) |
Revert^17 "Thread suspension cleanup and deadlock fix"
This reverts commit c6371b52df0da31acc174a3526274417b7aac0a7.
Reason for revert: This seems to have two remaining issues:
1. The second DCHECK in WaitForFlipFunction is not completely guaranteed to hold, resulting in failures for 658-fp-read-barrier.
2. WaitForSuspendBarrier seems to time out occasionally, possibly spuriously so. We fail when the futex times out once. That's probably incompatible with the app freezer. We should retry a few times.
Change-Id: Ibd8909b31083fc29e6d4f1fcde003d08eb16fc0a
Diffstat (limited to 'runtime/base/mutex.cc')
-rw-r--r-- | runtime/base/mutex.cc | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc index 5b74bee279..728dc842c2 100644 --- a/runtime/base/mutex.cc +++ b/runtime/base/mutex.cc @@ -246,12 +246,11 @@ void BaseMutex::DumpAll(std::ostream& os) { } void BaseMutex::CheckSafeToWait(Thread* self) { - if (!kDebugLocking) { - return; - } if (self == nullptr) { CheckUnattachedThread(level_); - } else { + return; + } + if (kDebugLocking) { CHECK(self->GetHeldMutex(level_) == this || level_ == kMonitorLock) << "Waiting on unacquired mutex: " << name_; bool bad_mutexes_held = false; @@ -571,7 +570,6 @@ bool Mutex::IsDumpFrequent(Thread* thread, uint64_t try_times) { } } -template <bool kCheck> bool Mutex::ExclusiveTryLock(Thread* self) { DCHECK(self == nullptr || self == Thread::Current()); if (kDebugLocking && !recursive_) { @@ -602,7 +600,7 @@ bool Mutex::ExclusiveTryLock(Thread* self) { #endif DCHECK_EQ(GetExclusiveOwnerTid(), 0); exclusive_owner_.store(SafeGetTid(self), std::memory_order_relaxed); - RegisterAsLocked(self, kCheck); + RegisterAsLocked(self); } recursion_count_++; if (kDebugLocking) { @@ -613,9 +611,6 @@ bool Mutex::ExclusiveTryLock(Thread* self) { return true; } -template bool Mutex::ExclusiveTryLock<false>(Thread* self); -template bool Mutex::ExclusiveTryLock<true>(Thread* self); - bool Mutex::ExclusiveTryLockWithSpinning(Thread* self) { // Spin a small number of times, since this affects our ability to respond to suspension // requests. We spin repeatedly only if the mutex repeatedly becomes available and unavailable @@ -722,12 +717,11 @@ void Mutex::ExclusiveUnlock(Thread* self) { } void Mutex::Dump(std::ostream& os) const { - os << (recursive_ ? "recursive " : "non-recursive ") << name_ - << " level=" << static_cast<int>(level_) << " rec=" << recursion_count_ -#if ART_USE_FUTEXES - << " state_and_contenders = " << std::hex << state_and_contenders_ << std::dec -#endif - << " owner=" << GetExclusiveOwnerTid() << " "; + os << (recursive_ ? "recursive " : "non-recursive ") + << name_ + << " level=" << static_cast<int>(level_) + << " rec=" << recursion_count_ + << " owner=" << GetExclusiveOwnerTid() << " "; DumpContention(os); } @@ -929,7 +923,7 @@ void ReaderWriterMutex::HandleSharedLockContention(Thread* self, int32_t cur_sta } #endif -bool ReaderWriterMutex::SharedTryLock(Thread* self, bool check) { +bool ReaderWriterMutex::SharedTryLock(Thread* self) { DCHECK(self == nullptr || self == Thread::Current()); #if ART_USE_FUTEXES bool done = false; @@ -953,7 +947,7 @@ bool ReaderWriterMutex::SharedTryLock(Thread* self, bool check) { PLOG(FATAL) << "pthread_mutex_trylock failed for " << name_; } #endif - RegisterAsLocked(self, check); + RegisterAsLocked(self); AssertSharedHeld(self); return true; } |