[llvm] [compiler-rt] [ci] Set timeout for individual tests and report slowest tests (PR #76300)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 23 15:37:25 PST 2023


https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/76300

>From dcf64907d99281b80a3405d7b34e3836fd021819 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Sat, 23 Dec 2023 12:50:52 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 .../lib/dfsan/dfsan_chained_origin_depot.cpp       |  6 +++++-
 compiler-rt/lib/msan/msan_chained_origin_depot.cpp |  9 +++++++--
 .../lib/sanitizer_common/sanitizer_stackdepot.cpp  | 14 ++++++++++++--
 .../sanitizer_common/sanitizer_stackdepotbase.h    |  3 ++-
 4 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/compiler-rt/lib/dfsan/dfsan_chained_origin_depot.cpp b/compiler-rt/lib/dfsan/dfsan_chained_origin_depot.cpp
index 6644bd6a7c6c0c..d078265258ca14 100644
--- a/compiler-rt/lib/dfsan/dfsan_chained_origin_depot.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_chained_origin_depot.cpp
@@ -19,9 +19,13 @@ static ChainedOriginDepot chainedOriginDepot;
 
 ChainedOriginDepot* GetChainedOriginDepot() { return &chainedOriginDepot; }
 
-void ChainedOriginDepotLockBeforeFork() { chainedOriginDepot.LockAll(); }
+void ChainedOriginDepotLockBeforeFork() {
+  // TODO: Consider same optimization as `StackDepotLockBeforeFork`.
+  chainedOriginDepot.LockAll();
+}
 
 void ChainedOriginDepotUnlockAfterFork(bool fork_child) {
+  // TODO: Consider same optimization as `StackDepotUnlockAfterFork`.
   chainedOriginDepot.UnlockAll();
 }
 
diff --git a/compiler-rt/lib/msan/msan_chained_origin_depot.cpp b/compiler-rt/lib/msan/msan_chained_origin_depot.cpp
index c3bd54141e6c38..66c80708669373 100644
--- a/compiler-rt/lib/msan/msan_chained_origin_depot.cpp
+++ b/compiler-rt/lib/msan/msan_chained_origin_depot.cpp
@@ -31,10 +31,15 @@ u32 ChainedOriginDepotGet(u32 id, u32 *other) {
   return chainedOriginDepot.Get(id, other);
 }
 
-void ChainedOriginDepotBeforeFork() { chainedOriginDepot.LockAll(); }
+void ChainedOriginDepotBeforeFork() {
+  // Don't `chainedOriginDepot.LockAll()`, see `StackDepotLockBeforeFork`.
+}
 
 void ChainedOriginDepotAfterFork(bool fork_child) {
-  chainedOriginDepot.UnlockAll();
+  // See `StackDepotUnlockAfterFork`.
+  if (fork_child) {
+    chainedOriginDepot.UnlockAll();
+  }
 }
 
 } // namespace __msan
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
index ce21f3c178bce0..8d134ca5a41aee 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
@@ -216,7 +216,13 @@ StackTrace StackDepotGet(u32 id) {
 }
 
 void StackDepotLockBeforeFork() {
-  theDepot.LockAll();
+  // Do not `theDepot.LockAll()`. It's very slow, but not rely needed. The
+  // parent process will neither lock nor unlock. Child process risks to be
+  // deadlocked on already locked buckets. To avoid deadlock we will unlock
+  // every locked buckets. This may affect consistency of the hash table, but
+  // the only possible issue is a few items inserted by parent process will be
+  // not found by child, and the child may insert them again, wasting some space
+  // in `stackStore`.
   compress_thread.LockAndStop();
   stackStore.LockAll();
 }
@@ -224,7 +230,11 @@ void StackDepotLockBeforeFork() {
 void StackDepotUnlockAfterFork(bool fork_child) {
   stackStore.UnlockAll();
   compress_thread.Unlock();
-  theDepot.UnlockAll();
+  if (fork_child) {
+    // Only child process needs to unlock to avoid deadlock. See
+    // `StackDepotLockAll`.
+    theDepot.UnlockAll();
+  }
 }
 
 void StackDepotPrintAll() {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
index 96d1ddc87fd032..3440a8f628e971 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
@@ -171,7 +171,8 @@ void StackDepotBase<Node, kReservedBits, kTabSizeLog>::UnlockAll() {
   for (int i = 0; i < kTabSize; ++i) {
     atomic_uint32_t *p = &tab[i];
     uptr s = atomic_load(p, memory_order_relaxed);
-    unlock(p, s & kUnlockMask);
+    if (s & kLockMask)
+      unlock(p, s & kUnlockMask);
   }
 }
 

>From dc7a0b30656fd520a32c61882a284ec866c08bb1 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Sat, 23 Dec 2023 15:37:10 -0800
Subject: [PATCH 2/2] rebase

Created using spr 1.3.4
---
 .../lib/dfsan/dfsan_chained_origin_depot.cpp       |  6 +-----
 compiler-rt/lib/msan/msan_chained_origin_depot.cpp |  9 ++-------
 .../lib/sanitizer_common/sanitizer_stackdepot.cpp  | 14 ++------------
 .../sanitizer_common/sanitizer_stackdepotbase.h    |  3 +--
 4 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/compiler-rt/lib/dfsan/dfsan_chained_origin_depot.cpp b/compiler-rt/lib/dfsan/dfsan_chained_origin_depot.cpp
index d078265258ca14..6644bd6a7c6c0c 100644
--- a/compiler-rt/lib/dfsan/dfsan_chained_origin_depot.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_chained_origin_depot.cpp
@@ -19,13 +19,9 @@ static ChainedOriginDepot chainedOriginDepot;
 
 ChainedOriginDepot* GetChainedOriginDepot() { return &chainedOriginDepot; }
 
-void ChainedOriginDepotLockBeforeFork() {
-  // TODO: Consider same optimization as `StackDepotLockBeforeFork`.
-  chainedOriginDepot.LockAll();
-}
+void ChainedOriginDepotLockBeforeFork() { chainedOriginDepot.LockAll(); }
 
 void ChainedOriginDepotUnlockAfterFork(bool fork_child) {
-  // TODO: Consider same optimization as `StackDepotUnlockAfterFork`.
   chainedOriginDepot.UnlockAll();
 }
 
diff --git a/compiler-rt/lib/msan/msan_chained_origin_depot.cpp b/compiler-rt/lib/msan/msan_chained_origin_depot.cpp
index 66c80708669373..c3bd54141e6c38 100644
--- a/compiler-rt/lib/msan/msan_chained_origin_depot.cpp
+++ b/compiler-rt/lib/msan/msan_chained_origin_depot.cpp
@@ -31,15 +31,10 @@ u32 ChainedOriginDepotGet(u32 id, u32 *other) {
   return chainedOriginDepot.Get(id, other);
 }
 
-void ChainedOriginDepotBeforeFork() {
-  // Don't `chainedOriginDepot.LockAll()`, see `StackDepotLockBeforeFork`.
-}
+void ChainedOriginDepotBeforeFork() { chainedOriginDepot.LockAll(); }
 
 void ChainedOriginDepotAfterFork(bool fork_child) {
-  // See `StackDepotUnlockAfterFork`.
-  if (fork_child) {
-    chainedOriginDepot.UnlockAll();
-  }
+  chainedOriginDepot.UnlockAll();
 }
 
 } // namespace __msan
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
index 8d134ca5a41aee..ce21f3c178bce0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
@@ -216,13 +216,7 @@ StackTrace StackDepotGet(u32 id) {
 }
 
 void StackDepotLockBeforeFork() {
-  // Do not `theDepot.LockAll()`. It's very slow, but not rely needed. The
-  // parent process will neither lock nor unlock. Child process risks to be
-  // deadlocked on already locked buckets. To avoid deadlock we will unlock
-  // every locked buckets. This may affect consistency of the hash table, but
-  // the only possible issue is a few items inserted by parent process will be
-  // not found by child, and the child may insert them again, wasting some space
-  // in `stackStore`.
+  theDepot.LockAll();
   compress_thread.LockAndStop();
   stackStore.LockAll();
 }
@@ -230,11 +224,7 @@ void StackDepotLockBeforeFork() {
 void StackDepotUnlockAfterFork(bool fork_child) {
   stackStore.UnlockAll();
   compress_thread.Unlock();
-  if (fork_child) {
-    // Only child process needs to unlock to avoid deadlock. See
-    // `StackDepotLockAll`.
-    theDepot.UnlockAll();
-  }
+  theDepot.UnlockAll();
 }
 
 void StackDepotPrintAll() {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
index 3440a8f628e971..96d1ddc87fd032 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
@@ -171,8 +171,7 @@ void StackDepotBase<Node, kReservedBits, kTabSizeLog>::UnlockAll() {
   for (int i = 0; i < kTabSize; ++i) {
     atomic_uint32_t *p = &tab[i];
     uptr s = atomic_load(p, memory_order_relaxed);
-    if (s & kLockMask)
-      unlock(p, s & kUnlockMask);
+    unlock(p, s & kUnlockMask);
   }
 }
 



More information about the llvm-commits mailing list