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
Pass threadObject to walkContinuationStackFrames #18180
Pass threadObject to walkContinuationStackFrames #18180
Conversation
0e50d8b
to
c3263e5
Compare
There are VM, GC and JIT changes in this PR. @fengxue-IS @0xdaryl @dmitripivkine Requesting your review. fyi @tajila |
e7daeb7
to
3e67460
Compare
@fengxue-IS I have addressed all of your feedback. |
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
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.
JIT changes look fine.
threadObject is required in jvmtiFollowReferences to get thread specific details such as the TID. So, threadObject needs to be passed via walkContinuationStackFrames so that it is accessible in jvmtiFollowReferences. walkContinuationStackFrames is invoked either for a [1] J9VMContinuation in the Continuation object or [2] J9VMThread->currentContinuation In [1], if the Continuation is fully mounted, then it stores the state of the CarrierThread. Otherwise, it stores the state of the VirtualThread. In [2], if J9VMThread->currentContinuation is not NULL, then it stores the state of the CarrierThread because the VirtualThread is mounted on the J9VMThread. The CarrierThread is retrieved from J9VMThread->carrierThreadObject. We have assumed that the state of the Continuation or J9VMContinuation doesn't change while walkContinuationStackFrames is invoked i.e. the VirtualThread shouldn't be mounted or unmounted. Otherwise, the values of the VirtualThread and CarrierThread objects accessed via the Continuation object and J9VMThread->carrierThreadObject can vary and cause a crash during walkContinuationStackFrames. Related: eclipse-openj9#17712 Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
3e67460
to
618c2f4
Compare
The last push just updated the commit message to reflect the latest changes. Also, the PR description was updated. |
jenkins test sanity zlinux jdk11,jdk21 |
jenkins compile win jdk11,jdk21 |
While I see an improvement, isn't there still a problem JVMTI walking stack frames while they are potentially changing (of a mounted VT)? |
re #18180 (comment): There is synchronization code which prevents virtual threads to be mounted or unmounted while they are being inspected via JVMTI. |
The PR builds look good except the known failure (more details below).
|
This is good, but my original concern was more about the other way around - walking even if VT is already mounted. This change makes sure that a proper threadObject was snapshotted ahead of walk, but seems like JVMTI proceeds with the walk (of a stack that is potentially changing). Another thing I'm curios about is the details of that synchronization - is there something we can share with Concurrent GC synchronization. It is outside of scope of these change - something we can talk about later, in person. |
In this case, JVMTI will either halt the thread or acquire exclusive VM access to prevent the thread stack from changing. In
@LinHu2016 and @fengxue-IS had a discussion about this in the past. JVMTI synchronization increments a counter or spins until the counter conditions are met. JVMTI synchronization is blocking and heavily dependent on spinning. The GC took a passive (non-blocking) approach to skip. |
@amicic @dmitripivkine @0xdaryl Can I ask one of you to merge this PR if everything looks good? |
Failure in s390 build is unrelated (CRIU issue) |
This PR is needed to enable the Skynet benchmark. The changes in eclipse-openj9#18180 pass threadObject to walkContinuationStackFrames. The GC can walk the continuations until the associated native J9VMContinuation structure is freed. Since we rely on Continuation.vthread in walkContinuationStackFrames, Continuation.vthread can only be unset once the native continuation structure is freed. Now, we set Continuation.vthread to NULL after the continuation is freed. This will prevent a segfault which can occur due to eclipse-openj9#18180. Continuation.vthread is also used in JVMTI to not suspend virtual threads once they enter the last unmount phase. This won't work anymore because Continuation.vthread is no longer set to NULL at the start of the last unmount phase. To address this issue, another continuation state has been added to indicate that a virtual thread's continuation has entered the last unmount phase. Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
This PR is needed to enable the Skynet benchmark. The changes in eclipse-openj9#18180 pass threadObject to walkContinuationStackFrames. The GC can walk the continuations until the associated native J9VMContinuation structure is freed. Since we rely on Continuation.vthread in walkContinuationStackFrames, Continuation.vthread can only be unset once the native continuation structure is freed. Now, we set Continuation.vthread to NULL after the continuation is freed. This will prevent a segfault which can occur due to eclipse-openj9#18180. Continuation.vthread is also used in JVMTI to not suspend virtual threads once they enter the last unmount phase. This won't work anymore because Continuation.vthread is no longer set to NULL at the start of the last unmount phase. To address this issue, another continuation state has been added to indicate that a virtual thread's continuation has entered the last unmount phase. Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
threadObject
is required injvmtiFollowReferences
to get threadspecific details such as the
TID
.So,
threadObject
needs to be passed viawalkContinuationStackFrames
so that it is accessible in
jvmtiFollowReferences
.walkContinuationStackFrames
is invoked either for a[1]
J9VMContinuation
in theContinuation
object or[2]
J9VMThread->currentContinuation
.In [1], if the
Continuation
is fully mounted, then it stores the stateof the
CarrierThread
. Otherwise, it stores the state of theVirtualThread
.In [2], if
J9VMThread->currentContinuation
is not NULL, then it storesthe state of the
CarrierThread
because theVirtualThread
is mounted onthe
J9VMThread
. TheCarrierThread
is retrieved fromJ9VMThread->carrierThreadObject
.We have assumed that the state of the
Continuation
orJ9VMContinuation
doesn't change while
walkContinuationStackFrames
is invoked i.e. theVirtualThread
shouldn't be mounted or unmounted. Otherwise, the valuesof the
VirtualThread
andCarrierThread
objects accessed via theContinuation
object andJ9VMThread->carrierThreadObject
can vary andcause a crash during
walkContinuationStackFrames
.Related: #17712