[NFC][TSan] Remove redundant Context::report_mtx (#228605)

Context::report_mtx was only ever acquired immediately alongside
ScopedErrorReportLock (in ScopedReport and BackgroundThread). Remove
report_mtx and MutexTypeReport and rely on ScopedErrorReportLock.

Assisted-by: Gemini
GitOrigin-RevId: 04203a045b4cfb18e2b22764744249cba171eb30
diff --git a/lib/tsan/rtl/tsan_defs.h b/lib/tsan/rtl/tsan_defs.h
index 270d441..0396486 100644
--- a/lib/tsan/rtl/tsan_defs.h
+++ b/lib/tsan/rtl/tsan_defs.h
@@ -199,8 +199,7 @@
 };
 
 enum {
-  MutexTypeReport = MutexLastCommon,
-  MutexTypeSyncVar,
+  MutexTypeSyncVar = MutexLastCommon,
   MutexTypeAnnotations,
   MutexTypeAtExit,
   MutexTypeFired,
diff --git a/lib/tsan/rtl/tsan_rtl.cpp b/lib/tsan/rtl/tsan_rtl.cpp
index e00f2ab..c6e7dce 100644
--- a/lib/tsan/rtl/tsan_rtl.cpp
+++ b/lib/tsan/rtl/tsan_rtl.cpp
@@ -390,7 +390,6 @@
 
 Context::Context()
     : initialized(),
-      report_mtx(MutexTypeReport),
       nreported(),
       thread_registry([](Tid tid) -> ThreadContextBase* {
         return new (Alloc(sizeof(ThreadContext))) ThreadContext(tid);
@@ -515,8 +514,7 @@
       u64 last = atomic_load(&ctx->last_symbolize_time_ns,
                              memory_order_relaxed);
       if (last != 0 && last + flags()->flush_symbolizer_ms * kMs2Ns < now) {
-        Lock l(&ctx->report_mtx);
-        ScopedErrorReportLock l2;
+        ScopedErrorReportLock l;
         SymbolizeFlush();
         atomic_store(&ctx->last_symbolize_time_ns, 0, memory_order_relaxed);
       }
@@ -849,7 +847,7 @@
   ScopedErrorReportLock::Lock();
   AllocatorLockBeforeFork();
   // Suppress all reports in the pthread_atfork callbacks.
-  // Reports will deadlock on the report_mtx.
+  // Reports may deadlock.
   // We could ignore sync operations as well,
   // but so far it's unclear if it will do more good or harm.
   // Unnecessarily ignoring things can lead to false positives later.
@@ -1142,11 +1140,8 @@
 using namespace __tsan;
 MutexMeta mutex_meta[] = {
     {MutexInvalid, "Invalid", {}},
-    {MutexThreadRegistry,
-     "ThreadRegistry",
-     {MutexTypeSlots, MutexTypeTrace, MutexTypeReport}},
-    {MutexTypeReport, "Report", {MutexTypeTrace}},
-    {MutexTypeSyncVar, "SyncVar", {MutexTypeReport, MutexTypeTrace}},
+    {MutexThreadRegistry, "ThreadRegistry", {MutexTypeSlots, MutexTypeTrace}},
+    {MutexTypeSyncVar, "SyncVar", {MutexTypeTrace}},
     {MutexTypeAnnotations, "Annotations", {}},
     {MutexTypeAtExit, "AtExit", {}},
     {MutexTypeFired, "Fired", {MutexLeaf}},
@@ -1158,7 +1153,7 @@
      "Slot",
      {MutexMulti, MutexTypeTrace, MutexTypeSyncVar, MutexThreadRegistry,
       MutexTypeSlots}},
-    {MutexTypeSlots, "Slots", {MutexTypeTrace, MutexTypeReport}},
+    {MutexTypeSlots, "Slots", {MutexTypeTrace}},
     {},
 };
 
diff --git a/lib/tsan/rtl/tsan_rtl.h b/lib/tsan/rtl/tsan_rtl.h
index db3c879..fcfbf2f 100644
--- a/lib/tsan/rtl/tsan_rtl.h
+++ b/lib/tsan/rtl/tsan_rtl.h
@@ -317,7 +317,6 @@
 
   MetaMap metamap;
 
-  Mutex report_mtx;
   atomic_uint32_t nreported;
   atomic_uint64_t last_symbolize_time_ns;
 
diff --git a/lib/tsan/rtl/tsan_rtl_report.cpp b/lib/tsan/rtl/tsan_rtl_report.cpp
index d527ba4..8fd1471 100644
--- a/lib/tsan/rtl/tsan_rtl_report.cpp
+++ b/lib/tsan/rtl/tsan_rtl_report.cpp
@@ -168,13 +168,9 @@
   rep_ = New<ReportDesc>();
   rep_->typ = typ;
   rep_->tag = tag;
-  ctx->report_mtx.Lock();
 }
 
-ScopedReportBase::~ScopedReportBase() {
-  ctx->report_mtx.Unlock();
-  DestroyAndFree(rep_);
-}
+ScopedReportBase::~ScopedReportBase() { DestroyAndFree(rep_); }
 
 void ScopedReportBase::AddStack(StackTrace stack, bool suppressable) {
   ReportStack **rs = rep_->stacks.PushBack();