Skip to content

Commit e4e941e

Browse files
author
Julian Lettner
committed
Move TSan release edge to swift_task_enqueueGlobal()
Move the TSan release edge from `swift_task_create_commonImpl()` to `swift_task_enqueueGlobalImpl()`. Task creation itself is not an event that needs synchronization, but rather that task creation "happens before" execution of that task on another thread. This edge is usually added when the task is scheduled via `swift_task_enqueue()` (which then usually calls `swift_task_enqueueGlobal()`). However, not all task scheduling goes through the `swift_task_enqueue()` funnel as some places call the more specific `swift_task_enqueueGlobal()` directly. So let's annotate this function (duplicate edges aren't harmful) to ensure we cover all schedule events, including newly-created tasks (our original problem here). rdar://78932849
1 parent 3c821de commit e4e941e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

stdlib/public/Concurrency/GlobalExecutor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ static void swift_task_enqueueGlobalImpl(Job *job) {
336336
}
337337

338338
void swift::swift_task_enqueueGlobal(Job *job) {
339+
_swift_tsan_release(job);
340+
339341
if (swift_task_enqueueGlobal_hook)
340342
swift_task_enqueueGlobal_hook(job, swift_task_enqueueGlobalImpl);
341343
else

stdlib/public/Concurrency/Task.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,6 @@ static AsyncTaskAndContext swift_task_create_commonImpl(
642642
swift_retain(task);
643643
swift_task_enqueue(task, executor);
644644
}
645-
646-
_swift_tsan_release(static_cast<Job *>(task));
647645

648646
return {task, initialContext};
649647
}

0 commit comments

Comments
 (0)