Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable TLS on linux/arm64 only for static resolver #106052

Merged
merged 8 commits into from
Aug 7, 2024

Conversation

davidwrighton
Copy link
Member

Fix arm64 behavior around assuming that a static resolver is possible for Arm64 TLS at all times.

Instead, detect whether the static resolver path was taken, and if it was, use the static path.

In addition, this change adds a new config variable DOTNET_DisableOptimizedThreadStaticAccess which can be used to mitigate this issue in case issues are found in other optimized thread static access paths.

Finally, the test for this relies on adding a new switch to the corerun utility, which can pre-load a set of .so files into the process.

This is an evolution of PR #104408.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 6, 2024
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have the same problem on native aot too. It can be looked at in separate PR.

Also, the new test may need disabling for native aot.

src/coreclr/hosts/corerun/corerun.cpp Outdated Show resolved Hide resolved
src/coreclr/hosts/corerun/corerun.cpp Outdated Show resolved Hide resolved
src/coreclr/inc/clrconfigvalues.h Outdated Show resolved Hide resolved
thread_local int tls16;

extern "C" DLLEXPORT void initializeTLS() {
tls0=0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the unused thread locals get optimized out? Do we need to access them to prevent them from being optimized out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, I didn't see them getting optimized out with a chk build, which is where this test really works, but setting every value is trivial to add to the test, so I'll do that.

@davidwrighton davidwrighton merged commit ade568b into dotnet:main Aug 7, 2024
96 checks passed
@davidwrighton
Copy link
Member Author

/backport to release/8.0-staging

Copy link
Contributor

github-actions bot commented Aug 7, 2024

Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/10292791888

Copy link
Contributor

github-actions bot commented Aug 7, 2024

@davidwrighton backporting to release/8.0-staging failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Enable TLS on linux/arm64 only for static resolver
Using index info to reconstruct a base tree...
M	src/coreclr/vm/arm64/asmhelpers.S
M	src/coreclr/vm/threadstatics.cpp
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/vm/threadstatics.cpp
CONFLICT (content): Merge conflict in src/coreclr/vm/threadstatics.cpp
Auto-merging src/coreclr/vm/arm64/asmhelpers.S
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Enable TLS on linux/arm64 only for static resolver
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Copy link
Contributor

github-actions bot commented Aug 7, 2024

@davidwrighton an error occurred while backporting to release/8.0-staging, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

@jkotas
Copy link
Member

jkotas commented Aug 8, 2024

I think we have the same problem on native aot too. It can be looked at in separate PR.

I have checked the native aot code and it seems to be fine (details of what we generate are at
#97910).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants