[PATCH] D21604: [tsan] Add HB edges for GCD barrier blocks

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 22 05:36:36 PDT 2016


dvyukov added inline comments.

================
Comment at: lib/tsan/rtl/tsan_libdispatch_mac.cc:127
@@ -106,1 +126,3 @@
+
+  Release(thr, pc, barrier_sync_object1);
 
----------------
Shouldn't it be `if (!queue_serial && !context->is_barrier_block)`. Because serial blocks and barriers blocks are already synchronized by other means.

It is very difficult to understand serial/concurrent/barrier/non-barrier synchronization now.
First observation is that serial queues are equivalent to concurrent queue with all blocks being barriers.
Second observation is that barrier/non-barrier blocks are equivalent to reader-writer mutexes with barriers being writers and non-barriers being readers.
Reader-writer synchronization is handled with 2 sync objects as:

  uptr serial_sync = ((uptr)context->queue);
  uptr concurrent_sync = ((uptr)context->queue) + sizeof(uptr);
  bool serial_task = IsQueueSerial(context->queue) || context->is_barrier_block;

  Acquire(thr, pc, serial_sync);
  if (serial_task)
    Acquire(thr, pc, concurrent_sync);

  SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START();
  context->orig_work(context->orig_context);
  SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_END();

  Release(thr, pc, serial_task ? serial_sync : concurrent_sync);

This looks simpler than your new code. Please use it.


http://reviews.llvm.org/D21604





More information about the llvm-commits mailing list