diff options
Diffstat (limited to 'runtime/thread_list.cc')
-rw-r--r-- | runtime/thread_list.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc index 5e63b27b20..02e3f5475a 100644 --- a/runtime/thread_list.cc +++ b/runtime/thread_list.cc @@ -1089,6 +1089,8 @@ bool ThreadList::SuspendThread(Thread* self, if (thread->IsSuspended()) { // See the discussion in mutator_gc_coord.md and SuspendAllInternal for the race here. thread->RemoveFirstSuspend1Barrier(&wrapped_barrier); + // PassActiveSuspendBarriers couldn't have seen our barrier, since it also acquires + // 'thread_suspend_count_lock_'. `wrapped_barrier` will not be accessed. if (!thread->HasActiveSuspendBarrier()) { thread->AtomicClearFlag(ThreadFlag::kActiveSuspendBarrier); } @@ -1127,9 +1129,6 @@ bool ThreadList::SuspendThread(Thread* self, // Now wait for target to decrement suspend barrier. std::optional<std::string> failure_info; if (!is_suspended) { - // As an experiment, redundantly trigger suspension. TODO: Remove this. - std::atomic_thread_fence(std::memory_order_seq_cst); - thread->TriggerSuspend(); failure_info = WaitForSuspendBarrier(&wrapped_barrier.barrier_, tid, attempt_of_4); if (!failure_info.has_value()) { is_suspended = true; @@ -1188,7 +1187,7 @@ bool ThreadList::SuspendThread(Thread* self, } is_suspended = true; } - // wrapped_barrier.barrier_ has been decremented and will no longer be accessed. + // wrapped_barrier.barrier_ will no longer be accessed. VLOG(threads) << func_name << " suspended: " << *thread; if (ATraceEnabled()) { std::string name; @@ -1197,7 +1196,11 @@ bool ThreadList::SuspendThread(Thread* self, StringPrintf("%s suspended %s for tid=%d", func_name, name.c_str(), thread->GetTid()) .c_str()); } - DCHECK(thread->IsSuspended()); + if (kIsDebugBuild) { + CHECK(thread->IsSuspended()); + MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); + thread->CheckBarrierInactive(&wrapped_barrier); + } return true; } |