[PATCH] D40583: Defer StartBackgroundThread() and StopBackgroundThread() in TSan

Dmitry Vyukov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 23:51:30 PST 2017


dvyukov accepted this revision.
dvyukov added a comment.
This revision is now accepted and ready to land.

LGTM with a nit



================
Comment at: lib/tsan/rtl/tsan_rtl.cc:423
+  if (cond == 0) {
+    if (atomic_compare_exchange_strong(&bg_thread, &cond, 1,
+                                       memory_order_acq_rel)) {
----------------
atomic_exchange will be slightly simpler than CAS:
```
  static atomic_uint32_t bg_thread = {};
  if (atomic_load(&bg_thread, memory_order_relaxed) == 0 &&
      atomic_exchange(&bg_thread, 1, memory_order_relaxed) == 0) {
    StartBackgroundThread();
    SetSandboxingCallback(StopBackgroundThread);
  }
```


Repository:
  rL LLVM

https://reviews.llvm.org/D40583





More information about the llvm-commits mailing list