This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Add release+acquire semantics for serial dispatch queues
ClosedPublic

Authored by kubamracek on Nov 26 2015, 4:54 AM.

Details

Summary

Serial queues need extra happens-before between individual tasks executed in the same queue. This patch adds Acquire(queue) before the executed task and Release(queue) just after it (for serial queues only). Added a test case.

Diff Detail

Event Timeline

kubamracek updated this revision to Diff 41227.Nov 26 2015, 4:54 AM
kubamracek retitled this revision from to [tsan] Add release+acquire semantics for serial dispatch queues.
kubamracek updated this object.
kubamracek added reviewers: dvyukov, kcc, glider, samsonov.
dvyukov added inline comments.Nov 28 2015, 1:30 AM
lib/tsan/rtl/tsan_libdispatch_mac.cc
81

Do you mean that work items can be executed on different threads for serial queues? If so, add a comment here, because it is not completely obvious.

Also, please move Acquire call to a separate line.

83

same here

kubamracek updated this revision to Diff 41328.Nov 28 2015, 1:36 AM

Do you mean that work items can be executed on different threads for serial queues? If so, add a comment here, because it is not completely obvious.

Updated patch.

Also, please move Acquire call to a separate line.

It's clang-format (Google style) doing this. Is there some extra setting I should be using? Should we add it to the .clang-format file we have in lib/tsan?

dvyukov accepted this revision.Nov 28 2015, 2:46 AM
dvyukov edited edge metadata.

It's clang-format (Google style) doing this. Is there some extra setting I should be using? Should we add it to the .clang-format file we have in lib/tsan?

Ah, OK, I am more than happy with any automatic formatting. Please format it back. Sorry.
I've looked at other .clang-format files, they all are just "BasedOnStyle: Google". It does not make sense to have different rules for tsan.
At some point we need to reformat all tsan sources. I don't want to step on your work, so I can do it later, or you can do it now.

This revision is now accepted and ready to land.Nov 28 2015, 2:46 AM
This revision was automatically updated to reflect the committed changes.