-
Notifications
You must be signed in to change notification settings - Fork 706
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
Read-acquire Class Unload Mutex for compilation before checkpoint #17136
Conversation
The following deadlock is possible: 1. Comp thread read-enters class unload mutex 2. Checkpointing thread acquires comp monitor 3. Comp thread blocks trying to acquire comp monitor 4. Checkpointing thread blocks trying to write-enter class unload mutex The reason the Checkpointing thread acquires the class unload mutex is to prevent class unloading while it collects methods. However, a read-acquire is sufficient for this task. Therefore, having the Checkpointing thread do a read-acquire will prevent the deadlock since it will not block waiting to enter. Signed-off-by: Irwin D'Souza <dsouzai.gh@gmail.com>
@mpirvu could you please review? |
This will need to be backported to 0.38 since this issue was seen in Liberty testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
In the future we may need to add some comments for these methods regarding the monitors they already hold when entered and the monitors they acquire internally.
Can the same effect of blocking GC be achieved by acquiring VM access?
jenkins test sanity xlinux jdk17 |
If the hook |
The checkpointing thread releases VM access because of #15202. However, at this point we're not actually waiting for comp threads so it may be that we can actually acquire and release VM Access at this point. I will have to look into the code paths to double check, but for 0.38 I think the change in this PR is the safest solution. |
This change doesn't compile everywhere. I spotted the following failure so far, there may be more later. This is gcc 11.2
|
The following deadlock is possible:
The reason the Checkpointing thread acquires the class unload mutex is to prevent class unloading while it collects methods. However, a read-acquire is sufficient for this task.
Therefore, having the Checkpointing thread do a read-acquire will prevent the deadlock since it will not block waiting to enter.