Skip to content

Fix data race (TSan report) on worker thread startup on macOS in iree_thread_request_affinity - #15534

Merged
benvanik merged 2 commits into
mainfrom
revert-15499-mach_task_self
Nov 10, 2023
Merged

benvanik merged 2 commits into
mainfrom
revert-15499-mach_task_self

Conversation

@benvanik

@benvanik benvanik commented Nov 10, 2023 •

Copy link
Copy Markdown
Collaborator

The thread having its affinity set is not the thread setting it; mach_task_self() != thread->mach_port. We'll want to fix the race while still having the same behavior when called from https://github.com/openxla/iree/blob/5b72c3908c8c216f3eee034ca74d61b8dbf37a12/runtime/src/iree/base/internal/threading_darwin.c#L141-L143

Reverts #15499 and rolls forward with fix.

… in `iree_thread_request_affinity` (#15499)"

This reverts commit 8633629.
@benvanik
benvanik requested a review from bjacob November 10, 2023 17:24
@benvanik
benvanik enabled auto-merge (squash) November 10, 2023 17:28
@benvanik
benvanik disabled auto-merge November 10, 2023 17:31
@benvanik

Copy link
Copy Markdown
Collaborator Author

@bjacob pushed a commit with your fix handling both cases - I think should solve the race - mind giving it a shot?

@benvanik benvanik changed the title Revert "Fix data race (TSan report) on worker thread startup on macOS in iree_thread_request_affinity" Fix data race (TSan report) on worker thread startup on macOS in iree_thread_request_affinity Nov 10, 2023
@bjacob

bjacob commented Nov 10, 2023

Copy link
Copy Markdown
Collaborator

ok, trying!

@bjacob

bjacob commented Nov 10, 2023 •

Copy link
Copy Markdown
Collaborator

@benvanik , this works (no TSan error in iree/task tests with this PR, while the TSan error reproduces consistently without the last commit).

@benvanik

Copy link
Copy Markdown
Collaborator Author

awesome, thanks for checking and for the fix!

@benvanik
benvanik enabled auto-merge (squash) November 10, 2023 17:42
@benvanik
benvanik merged commit 1e41cbf into main Nov 10, 2023
@benvanik
benvanik deleted the revert-15499-mach_task_self branch November 10, 2023 17:58
ramiro050 pushed a commit to ramiro050/iree that referenced this pull request Dec 19, 2023
…e_thread_request_affinity` (iree-org#15534)

The thread having its affinity set is not the thread setting it;
`mach_task_self()` != `thread->mach_port`. We'll want to fix the race
while still having the same behavior when called from
https://github.com/openxla/iree/blob/5b72c3908c8c216f3eee034ca74d61b8dbf37a12/runtime/src/iree/base/internal/threading_darwin.c#L141-L143

Reverts iree-org#15499 and rolls forward with fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants