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.h | |
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.h')
-rw-r--r-- | runtime/base/mutex.h | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h index dc9b885bf7..87e9525557 100644 --- a/runtime/base/mutex.h +++ b/runtime/base/mutex.h @@ -103,11 +103,10 @@ class BaseMutex { BaseMutex(const char* name, LockLevel level); virtual ~BaseMutex(); - // Add this mutex to those owned by self, and optionally perform lock order checking. Caller - // may wish to disable checking for trylock calls that cannot result in deadlock. For this call - // only, self may also be another suspended thread. - void RegisterAsLocked(Thread* self, bool check = kDebugLocking); - void RegisterAsLockedImpl(Thread* self, LockLevel level, bool check); + // Add this mutex to those owned by self, and perform appropriate checking. + // For this call only, self may also be another suspended thread. + void RegisterAsLocked(Thread* self); + void RegisterAsLockedImpl(Thread* self, LockLevel level); void RegisterAsUnlocked(Thread* self); void RegisterAsUnlockedImpl(Thread* self, LockLevel level); @@ -184,10 +183,7 @@ class LOCKABLE Mutex : public BaseMutex { void ExclusiveLock(Thread* self) ACQUIRE(); void Lock(Thread* self) ACQUIRE() { ExclusiveLock(self); } - // Returns true if acquires exclusive access, false otherwise. The `check` argument specifies - // whether lock level checking should be performed. Should be defaulted unless we are using - // TryLock instead of Lock for deadlock avoidance. - template <bool kCheck = kDebugLocking> + // Returns true if acquires exclusive access, false otherwise. bool ExclusiveTryLock(Thread* self) TRY_ACQUIRE(true); bool TryLock(Thread* self) TRY_ACQUIRE(true) { return ExclusiveTryLock(self); } // Equivalent to ExclusiveTryLock, but retry for a short period before giving up. @@ -346,7 +342,7 @@ class SHARED_LOCKABLE ReaderWriterMutex : public BaseMutex { void ReaderLock(Thread* self) ACQUIRE_SHARED() { SharedLock(self); } // Try to acquire share of ReaderWriterMutex. - bool SharedTryLock(Thread* self, bool check = kDebugLocking) SHARED_TRYLOCK_FUNCTION(true); + bool SharedTryLock(Thread* self) SHARED_TRYLOCK_FUNCTION(true); // Release a share of the access. void SharedUnlock(Thread* self) RELEASE_SHARED() ALWAYS_INLINE; @@ -524,18 +520,6 @@ class SCOPED_CAPABILITY MutexLock { DISALLOW_COPY_AND_ASSIGN(MutexLock); }; -// Pretend to acquire a mutex for checking purposes, without actually doing so. Use with -// extreme caution when it is known the condition that the mutex would guard against cannot arise. -class SCOPED_CAPABILITY FakeMutexLock { - public: - explicit FakeMutexLock(Mutex& mu) ACQUIRE(mu) NO_THREAD_SAFETY_ANALYSIS {} - - ~FakeMutexLock() RELEASE() NO_THREAD_SAFETY_ANALYSIS {} - - private: - DISALLOW_COPY_AND_ASSIGN(FakeMutexLock); -}; - // Scoped locker/unlocker for a ReaderWriterMutex that acquires read access to mu upon // construction and releases it upon destruction. class SCOPED_CAPABILITY ReaderMutexLock { |