This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Add support for GCD target queues
ClosedPublic

Authored by kubamracek on Oct 20 2016, 11:24 AM.

Details

Summary

GCD (libdispatch) has a concept of “target queues”: Each queue has either an implicit or explicit target queue, where the task is handed over to when it’s time to execute it. For example, a concurrent queue can have a serial target queue (effectively making the first queue serial), or multiple queues can have the same serial target queue (which means tasks in all the queues are mutually excluded). Thus we need to acquire-release semantics on the full “chain” of target queues.

This patch changes the way we Acquire() and Release() when executing tasks in queues. Now we’ll walk the chain of target queues and synchronize on each queue that is serial (or when dealing with a barrier block). This should avoid false positives when using dispatch_set_target_queue().

Diff Detail

Repository
rL LLVM

Event Timeline

kubamracek retitled this revision from to [tsan] Add support for GCD target queues.
kubamracek updated this object.
kubamracek added a reviewer: dvyukov.
kubamracek set the repository for this revision to rL LLVM.
kubamracek added a project: Restricted Project.
kubamracek added subscribers: llvm-commits, zaks.anna.
dvyukov accepted this revision.Oct 30 2016, 5:43 PM
dvyukov edited edge metadata.

LGTM with nits

lib/tsan/rtl/tsan_libdispatch_mac.cc
112 ↗(On Diff #75323)

Move this out of the loop, no need to execute acquire on the same addr for each queue.

126 ↗(On Diff #75323)

Move this out of the loop, no need to execute release on the same addr for each queue.

This revision is now accepted and ready to land.Oct 30 2016, 5:43 PM
This revision was automatically updated to reflect the committed changes.