Skip to content

Conversation

qinsoon
Copy link
Member

@qinsoon qinsoon commented Aug 15, 2025

This PR changes how we acquire Heap_lock for GC. With the changes, we acquire the lock in VM_MMTkSTWOperation::doit_prologue(), and release the lock in epilogue. We hold the lock during the entire STW. This is the same behavior as OpenJDK's GCs.

We used to acquire the lock during reference enqueueing before swap_reference_pending_list() (which requires the lock to be locked), and acquire the lock before notifying the reference handler. This causes deadlock as seen in #315 .
The has_reference_pending_list call used for an assertion in reference enqueueing is removed, as it requires the current thread to hold the lock which cannot be satisfied.

This PR should fix #315.

@qinsoon qinsoon requested a review from wks August 15, 2025 05:23
@qinsoon qinsoon marked this pull request as ready for review August 15, 2025 05:24
Copy link
Contributor

@wks wks left a comment

Choose a reason for hiding this comment

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

LGTM. If all other GC operations in OpenJDK hold the Heap_lock during the entire GC, we should do the same.

@qinsoon qinsoon merged commit dc3a9b4 into mmtk:master Aug 15, 2025
55 of 56 checks passed
qinsoon added a commit to qinsoon/mmtk-openjdk that referenced this pull request Aug 16, 2025
qinsoon added a commit to qinsoon/mmtk-openjdk that referenced this pull request Aug 18, 2025
qinsoon added a commit to qinsoon/mmtk-openjdk that referenced this pull request Aug 18, 2025
qinsoon added a commit to qinsoon/mmtk-openjdk that referenced this pull request Aug 18, 2025
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.

Stuck in lusearch

2 participants