Add more info to who called SuspendAll

Helps diagnose related jank.

Change-Id: I38191cdda723c6f0355d0197c494a3dff2b6653c
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index be6c41a..3d3d5cb 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -932,7 +932,7 @@
     Runtime* current = Runtime::Current();
 
     // Suspend all threads.
-    current->GetThreadList()->SuspendAll();
+    current->GetThreadList()->SuspendAll(__FUNCTION__);
 
     std::string error_msg;
     std::unique_ptr<ClinitImageUpdate> update(ClinitImageUpdate::Create(image_classes_.get(),
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index 344d2b5..c27b3d4 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -1539,7 +1539,7 @@
       {
         self->TransitionFromRunnableToSuspended(kNative);
         ThreadList* thread_list = Runtime::Current()->GetThreadList();
-        thread_list->SuspendAll();
+        thread_list->SuspendAll(__FUNCTION__);
         heap->RevokeAllThreadLocalAllocationStacks(self);
         thread_list->ResumeAll();
         self->TransitionFromSuspendedToRunnable();
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 9f2a09b..6296cf5 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -644,7 +644,7 @@
   }
 
   Runtime* runtime = Runtime::Current();
-  runtime->GetThreadList()->SuspendAll();
+  runtime->GetThreadList()->SuspendAll(__FUNCTION__);
   Thread* self = Thread::Current();
   ThreadState old_state = self->SetStateUnsafe(kRunnable);
   CHECK_NE(old_state, kRunnable);
@@ -668,7 +668,7 @@
   // to kRunnable to avoid scoped object access transitions. Remove the debugger as a listener
   // and clear the object registry.
   Runtime* runtime = Runtime::Current();
-  runtime->GetThreadList()->SuspendAll();
+  runtime->GetThreadList()->SuspendAll(__FUNCTION__);
   Thread* self = Thread::Current();
   ThreadState old_state = self->SetStateUnsafe(kRunnable);
 
@@ -819,7 +819,7 @@
   Thread* self = Thread::Current();
   CHECK_EQ(self->GetState(), kRunnable);
   self->TransitionFromRunnableToSuspended(kSuspended);
-  Runtime::Current()->GetThreadList()->SuspendAll();
+  Runtime::Current()->GetThreadList()->SuspendAll(__FUNCTION__);
 
   MonitorInfo monitor_info(o);
 
@@ -3135,7 +3135,7 @@
   self->TransitionFromRunnableToSuspended(kWaitingForDeoptimization);
   // We need to suspend mutator threads first.
   Runtime* const runtime = Runtime::Current();
-  runtime->GetThreadList()->SuspendAll();
+  runtime->GetThreadList()->SuspendAll(__FUNCTION__);
   const ThreadState old_state = self->SetStateUnsafe(kRunnable);
   {
     MutexLock mu(self, *Locks::deoptimization_lock_);
@@ -4436,7 +4436,7 @@
         // RosAlloc's internal logic doesn't know to release and reacquire the heap bitmap lock.
         self->TransitionFromRunnableToSuspended(kSuspended);
         ThreadList* tl = Runtime::Current()->GetThreadList();
-        tl->SuspendAll();
+        tl->SuspendAll(__FUNCTION__);
         {
           ReaderMutexLock mu(self, *Locks::heap_bitmap_lock_);
           space->AsRosAllocSpace()->Walk(HeapChunkContext::HeapChunkJavaCallback, &context);
@@ -4452,7 +4452,7 @@
         heap->IncrementDisableMovingGC(self);
         self->TransitionFromRunnableToSuspended(kSuspended);
         ThreadList* tl = Runtime::Current()->GetThreadList();
-        tl->SuspendAll();
+        tl->SuspendAll(__FUNCTION__);
         ReaderMutexLock mu(self, *Locks::heap_bitmap_lock_);
         context.SetChunkOverhead(0);
         space->AsRegionSpace()->Walk(BumpPointerSpaceCallback, &context);
diff --git a/runtime/gc/collector/garbage_collector.cc b/runtime/gc/collector/garbage_collector.cc
index eafcc45..47d6ada 100644
--- a/runtime/gc/collector/garbage_collector.cc
+++ b/runtime/gc/collector/garbage_collector.cc
@@ -157,7 +157,7 @@
 
 GarbageCollector::ScopedPause::ScopedPause(GarbageCollector* collector)
     : start_time_(NanoTime()), collector_(collector) {
-  Runtime::Current()->GetThreadList()->SuspendAll();
+  Runtime::Current()->GetThreadList()->SuspendAll(__FUNCTION__);
 }
 
 GarbageCollector::ScopedPause::~ScopedPause() {
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 1298272..0cad11f 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -576,7 +576,7 @@
   ThreadList* tl = Runtime::Current()->GetThreadList();
   Thread* self = Thread::Current();
   ScopedThreadStateChange tsc(self, kSuspended);
-  tl->SuspendAll();
+  tl->SuspendAll(__FUNCTION__);
   // Something may have caused the transition to fail.
   if (!IsMovingGc(collector_type_) && non_moving_space_ != main_space_) {
     CHECK(main_space_ != nullptr);
@@ -758,7 +758,7 @@
     IncrementDisableMovingGC(self);
     self->TransitionFromRunnableToSuspended(kWaitingForVisitObjects);
     ThreadList* tl = Runtime::Current()->GetThreadList();
-    tl->SuspendAll();
+    tl->SuspendAll(__FUNCTION__);
     VisitObjectsInternalRegionSpace(callback, arg);
     VisitObjectsInternal(callback, arg);
     tl->ResumeAll();
@@ -1058,7 +1058,7 @@
     // Deflate the monitors, this can cause a pause but shouldn't matter since we don't care
     // about pauses.
     Runtime* runtime = Runtime::Current();
-    runtime->GetThreadList()->SuspendAll();
+    runtime->GetThreadList()->SuspendAll(__FUNCTION__);
     uint64_t start_time = NanoTime();
     size_t count = runtime->GetMonitorList()->DeflateMonitors();
     VLOG(heap) << "Deflating " << count << " monitors took "
@@ -1697,7 +1697,7 @@
     return HomogeneousSpaceCompactResult::kErrorVMShuttingDown;
   }
   // Suspend all threads.
-  tl->SuspendAll();
+  tl->SuspendAll(__FUNCTION__);
   uint64_t start_time = NanoTime();
   // Launch compaction.
   space::MallocSpace* to_space = main_space_backup_.release();
@@ -1779,7 +1779,7 @@
     return;
   }
   collector::GarbageCollector* collector = nullptr;
-  tl->SuspendAll();
+  tl->SuspendAll(__FUNCTION__);
   switch (collector_type) {
     case kCollectorTypeSS: {
       if (!IsMovingGc(collector_type_)) {
diff --git a/runtime/gc/space/rosalloc_space.cc b/runtime/gc/space/rosalloc_space.cc
index f140021..eb1d5f4 100644
--- a/runtime/gc/space/rosalloc_space.cc
+++ b/runtime/gc/space/rosalloc_space.cc
@@ -303,7 +303,7 @@
   // TODO: NO_THREAD_SAFETY_ANALYSIS.
   Thread* self = Thread::Current();
   ThreadList* tl = Runtime::Current()->GetThreadList();
-  tl->SuspendAll();
+  tl->SuspendAll(__FUNCTION__);
   {
     MutexLock mu(self, *Locks::runtime_shutdown_lock_);
     MutexLock mu2(self, *Locks::thread_list_lock_);
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc
index 5a7b7e1..b822613 100644
--- a/runtime/hprof/hprof.cc
+++ b/runtime/hprof/hprof.cc
@@ -1180,7 +1180,7 @@
     // comment in Heap::VisitObjects().
     heap->IncrementDisableMovingGC(self);
   }
-  Runtime::Current()->GetThreadList()->SuspendAll();
+  Runtime::Current()->GetThreadList()->SuspendAll(__FUNCTION__);
   Hprof hprof(filename, fd, direct_to_ddms);
   hprof.Dump();
   Runtime::Current()->GetThreadList()->ResumeAll();
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index 085062c..b53b8cd 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -607,7 +607,7 @@
   Locks::mutator_lock_->AssertNotHeld(self);
   Locks::instrument_entrypoints_lock_->AssertHeld(self);
   if (runtime->IsStarted()) {
-    tl->SuspendAll();
+    tl->SuspendAll(__FUNCTION__);
   }
   {
     MutexLock mu(self, *Locks::runtime_shutdown_lock_);
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 897287b..82b7ba7 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -167,7 +167,7 @@
 void Jit::CreateInstrumentationCache(size_t compile_threshold) {
   CHECK_GT(compile_threshold, 0U);
   Runtime* const runtime = Runtime::Current();
-  runtime->GetThreadList()->SuspendAll();
+  runtime->GetThreadList()->SuspendAll(__FUNCTION__);
   // Add Jit interpreter instrumentation, tells the interpreter when to notify the jit to compile
   // something.
   instrumentation_cache_.reset(new jit::JitInstrumentationCache(compile_threshold));
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index ddfbebd..1ab0093 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -448,13 +448,13 @@
   return runnable_threads.size() + other_threads.size() + 1;  // +1 for self.
 }
 
-void ThreadList::SuspendAll() {
+void ThreadList::SuspendAll(const char* cause) {
   Thread* self = Thread::Current();
 
   if (self != nullptr) {
-    VLOG(threads) << *self << " SuspendAll starting...";
+    VLOG(threads) << *self << " SuspendAll for " << cause << " starting...";
   } else {
-    VLOG(threads) << "Thread[null] SuspendAll starting...";
+    VLOG(threads) << "Thread[null] SuspendAll for " << cause << " starting...";
   }
   ATRACE_BEGIN("Suspending mutator threads");
   const uint64_t start_time = NanoTime();
@@ -503,7 +503,7 @@
   }
 
   ATRACE_END();
-  ATRACE_BEGIN("Mutator threads suspended");
+  ATRACE_BEGIN((std::string("Mutator threads suspended for ") + cause).c_str());
 
   if (self != nullptr) {
     VLOG(threads) << *self << " SuspendAll complete";
diff --git a/runtime/thread_list.h b/runtime/thread_list.h
index de0dd79..c18e285 100644
--- a/runtime/thread_list.h
+++ b/runtime/thread_list.h
@@ -61,7 +61,7 @@
       LOCKS_EXCLUDED(Locks::thread_suspend_count_lock_);
 
   // Suspends all threads and gets exclusive access to the mutator_lock_.
-  void SuspendAll()
+  void SuspendAll(const char* cause)
       EXCLUSIVE_LOCK_FUNCTION(Locks::mutator_lock_)
       LOCKS_EXCLUDED(Locks::thread_list_lock_,
                      Locks::thread_suspend_count_lock_);
diff --git a/runtime/trace.cc b/runtime/trace.cc
index 8833a85..88be23f 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -313,7 +313,7 @@
       }
     }
 
-    runtime->GetThreadList()->SuspendAll();
+    runtime->GetThreadList()->SuspendAll(__FUNCTION__);
     {
       MutexLock mu(self, *Locks::thread_list_lock_);
       runtime->GetThreadList()->ForEach(GetSample, the_trace);
@@ -367,7 +367,7 @@
   // Enable count of allocs if specified in the flags.
   bool enable_stats = false;
 
-  runtime->GetThreadList()->SuspendAll();
+  runtime->GetThreadList()->SuspendAll(__FUNCTION__);
 
   // Create Trace object.
   {
@@ -421,7 +421,7 @@
     CHECK_PTHREAD_CALL(pthread_join, (sampling_pthread, NULL), "sampling thread shutdown");
     sampling_pthread_ = 0U;
   }
-  runtime->GetThreadList()->SuspendAll();
+  runtime->GetThreadList()->SuspendAll(__FUNCTION__);
   if (the_trace != nullptr) {
     stop_alloc_counting = (the_trace->flags_ & kTraceCountAllocs) != 0;
     the_trace->FinishTracing();