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

[mini] Use atomics, instead of loader lock, for JIT wrappers #100925

Closed
wants to merge 2 commits into from

Conversation

lambdageek
Copy link
Member

Related to #93686

While this doesn't eliminate all deadlocks related to the global loader lock and managed locks, it removes one unneeded use of the loader lock.

The wrapper (and trampoline) of a JIT icall are only ever set from NULL to non-NULL. We can use atomics to deal with races instad of double checked locking. This was not the case historically, because the JIT info was dynamically allocated - so we used the loader lock to protect the integrity of the hash table

@lambdageek

This comment was marked as outdated.

This comment was marked as outdated.

Comment on lines +590 to +591
gconstpointer wrapper__;
gconstpointer trampoline__;
Copy link
Member Author

Choose a reason for hiding this comment

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

Ignore the renamed fields. I will remove this. Just want to see the build fail if there's any #ifdef uses of these that I missed

@lambdageek lambdageek force-pushed the cas-jitinfo-wrapper branch 2 times, most recently from 7f6152f to 9084c33 Compare April 11, 2024 17:18
@lambdageek lambdageek marked this pull request as draft April 11, 2024 18:16
@lambdageek
Copy link
Member Author

/azp run runtime-extra-platforms, runtime-community

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@@ -7243,6 +7243,8 @@ mono_create_icall_signatures (void)
}
}

/* LOCKING: does not take locks. does not use an atomic write to info->wrapper
Copy link
Member

Choose a reason for hiding this comment

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

Why not?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add to the comment. Because it's called single-threaded early during startup.

Related to dotnet#93686

While this doesn't eliminate all deadlocks related to the global
loader lock and managed locks, it removes one unneeded use of the
loader lock.

The wrapper (and trampoline) of a JIT icall are only ever set from
NULL to non-NULL.  We can use atomics to deal with races instad of
double checked locking.  This was not the case historically, because
the JIT info was dynamically allocated - so we used the loader lock to
protect the integrity of the hash table
Copy link
Contributor

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants