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

libnss_tcb: Allow for local-dynamic TLS-model optimizations. #29

Closed
wants to merge 1 commit into from

Conversation

besser82
Copy link
Contributor

@besser82 besser82 commented Dec 19, 2024

Since we dropped the conditionalized use of readdir_r(3) in commit 557818c, the dirstream object for use with readdir(3) can now get adapted easily in a way the compiler (and/or the linker) is able to apply global-dynamic to local-dynamic optimizations for the used thread-local storage model.

@besser82 besser82 force-pushed the topic/besser82/ld_tls_opt branch from 4cc53ba to 6bf0011 Compare December 19, 2024 18:22
@besser82
Copy link
Contributor Author

Ready for review. Let's do #28 after this one.

Since we dropped the conditionalized use of readdir_r(3) in commit
557818c, the dirstream object for
use with readdir(3) can now get adapted easily in a way the compiler
(and/or the linker) is able to apply global-dynamic to local-dynamic
optimizations for the used thread-local storage model.

Signed-off-by: Björn Esser <[email protected]>
@besser82 besser82 force-pushed the topic/besser82/ld_tls_opt branch from 6bf0011 to 70122df Compare December 19, 2024 18:28
@solardiz solardiz requested a review from ldv-alt December 19, 2024 18:32
Copy link
Member

@solardiz solardiz left a comment

Choose a reason for hiding this comment

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

I doubt those potential optimizations outweigh the complexity added here, and besides Ulrich's https://www.akkadia.org/drepper/tls.pdf says local-dynamic is only more optimal when there's more than one variable. But I don't mind.

@solardiz
Copy link
Member

Ready for review. Let's do #28 after this one.

I could do #28 now, but if you prefer to do them in this order, then let's wait for @ldv-alt's review here and maybe your comments on the optimizations.

@ldv-alt
Copy link
Collaborator

ldv-alt commented Dec 20, 2024

According to Ulrich Drepper, "The local dynamic TLS model is an optimization of the general dynamic TLS model. The compiler can generate code following this model if it can recognize that the thread-local variable is defined in the same object it is referenced in. This includes, for instance, thread-local variables with file scope".

Given that tcbdir is the only __thread variable and it has file scope, I'd expect gcc to use the local dynamic TLS model already. Can we verify this somehow?

@besser82
Copy link
Contributor Author

Can we verify this somehow?

Well, yes, one would need to check the relocs in asm ouput of the file.

Anyways, I've verified that we in fact don't need this. Closing here.

@besser82 besser82 closed this Dec 20, 2024
@besser82 besser82 deleted the topic/besser82/ld_tls_opt branch December 20, 2024 15:20
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.

3 participants