Add per-thread closeScope queue for ScopedMemoryAccess close handling#23455
Open
babsingh wants to merge 1 commit intoeclipse-openj9:masterfrom
Open
Add per-thread closeScope queue for ScopedMemoryAccess close handling#23455babsingh wants to merge 1 commit intoeclipse-openj9:masterfrom
babsingh wants to merge 1 commit intoeclipse-openj9:masterfrom
Conversation
Replace the previous global closeScope notification mechanism with a per-thread close request list. Each thread maintains a queue of J9CloseScopeListNode entries representing pending MemorySessionImpl close requests. ScopedMemoryAccess.closeScope0 now walks all threads, identifies threads accessing the session via @Scoped methods, and enqueues a close request on the target thread. Global refs to the session and error are shared across all nodes and tracked via a hidden MemorySessionImpl.closeScopeCount field. javaCheckAsyncMessages processes the queued requests, delivers the ScopedAccessError when appropriate, decrements the session counter, and releases the global refs once the last thread processes the request. This removes the VM-global closeScopeMutex / notifyCount mechanism and avoids races when multiple sessions are closed concurrently. Related: eclipse-openj9#22934 Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
Contributor
Author
|
@gacholio Requesting your review. This PR alone should resolve #22934, since the wait logic at the end of The earlier proposed test and OpenJ9 fixes are no longer required:
The JIT issue was previously tracked here: #13211 (comment). With this PR, the JIT issue is no longer observed. The failure frequency has dropped to the point that we see 0 failures in 100 runs, so it is no longer a blocker for the Java 26 release. |
gacholio
reviewed
Mar 7, 2026
| } | ||
| omrthread_monitor_exit(vm->closeScopeMutex); | ||
|
|
||
| closeScopeCount = J9OBJECT_I64_LOAD(currentThread, closeScopeObj, vm->closeScopeCountOffset); |
Contributor
There was a problem hiding this comment.
Can this be derived from the loop above?
Contributor
There was a problem hiding this comment.
The use of the mutex seems inconsistent (value here is read outside the mutex).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the previous global
closeScopenotification mechanism with aper-thread close request list. Each thread maintains a queue of
J9CloseScopeListNodeentries representing pendingMemorySessionImplclose requests.
ScopedMemoryAccess.closeScope0now walks all threads, identifiesthreads accessing the session via
@Scopedmethods, and enqueues aclose request on the target thread. Global refs to the session and
error are shared across all nodes and tracked via a hidden
MemorySessionImpl.closeScopeCountfield.javaCheckAsyncMessagesprocesses the queued requests, delivers theScopedAccessErrorwhen appropriate, decrements the session counter,and releases the global refs once the last thread processes the
request.
This removes the VM-global
closeScopeMutex/notifyCountmechanismand avoids races when multiple sessions are closed concurrently.
Related: #22934
Signed-off-by: Babneet Singh sbabneet@ca.ibm.com