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

[Loom] Implement JVM_VirtualThreadDisableSuspend #18671

Closed
babsingh opened this issue Dec 22, 2023 · 3 comments
Closed

[Loom] Implement JVM_VirtualThreadDisableSuspend #18671

babsingh opened this issue Dec 22, 2023 · 3 comments
Labels
comp:jvmti comp:vm jdk22 jdk23 project:loom Used to track Project Loom related work

Comments

@babsingh
Copy link
Contributor

babsingh commented Dec 22, 2023

A stub was added for JVM_VirtualThreadDisableSuspend (JDK23 only) in #18667.

As per https://bugs.openjdk.org/browse/JDK-8311218, JVM_VirtualThreadDisableSuspend will eventually be ported to JDK22.

Also, the assertion in the stub will be triggered because notifyJvmtiDisableSuspend -> JVM_VirtualThreadDisableSuspend is used in VirtualThread methods such as unpark, interrupt, getAndClearInterrupt, threadState, and toString: https://github.com/ibmruntimes/openj9-openjdk-jdk/blob/openj9/src/java.base/share/classes/java/lang/VirtualThread.java

To avoid triggering the assertion, the stub needs to be empty.

As for the implementation, this method notifies JVMTI to disable JVMTI suspend operations for a VirtualThread by toggling a field on/off. The intent is to ignore JVMTI suspend operations when a VirtualThread is performing certain synchronized blocks related to its carrier thread.

Next steps

  • Verify if the bug exists in OpenJ9 using the test case (Repro8311218.java) from https://bugs.openjdk.org/browse/JDK-8311218.
  • If it doesn't exist, then let JVM_VirtualThreadDisableSuspend stay emtpy.
  • If the bug exists in OpenJ9, then implement JVM_VirtualThreadDisableSuspend using the above description after verifying if the JVMTI operations are skipped or delayed (wait) until the VirtualThread completes the synchronized block.
@babsingh babsingh added project:loom Used to track Project Loom related work jdk22 labels Dec 22, 2023
babsingh added a commit to babsingh/openj9 that referenced this issue Dec 22, 2023
Enable JVM_VirtualThreadDisableSuspend in JDK22. A PR has been
opened to move it to JDK22 in the RI. Eventually, we will see this
method in JDK22.

The above method is invoked in the VirtualThread class. So, the
assertion in the stub will trigger and cause failures in the builds.

Leaving the stub empty should be fine. See eclipse-openj9#18671 for more details.

Related:
- eclipse-openj9#18671
- eclipse-openj9#18667
- eclipse-openj9#18663

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
@pshipton pshipton added this to the Java 22 milestone Dec 22, 2023
@tajila
Copy link
Contributor

tajila commented Jan 23, 2024

@babsingh what is the status of this?

@babsingh
Copy link
Contributor Author

Verify if the bug exists in OpenJ9 using the test case (Repro8311218.java) from https://bugs.openjdk.org/browse/JDK-8311218.

Repro8311218.java has been added as SuspendWithInterruptLock.java in the openj9-openjdk-jdk22 extension repo. I have been unable to reproduce the bug after running the SuspendWithInterruptLock test 200 times. I plan to leave JVM_VirtualThreadDisableSuspend empty (no implementation needed) since the bug doesn't exist in OpenJ9.

@babsingh
Copy link
Contributor Author

Closed as per #18671 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:jvmti comp:vm jdk22 jdk23 project:loom Used to track Project Loom related work
Projects
None yet
Development

No branches or pull requests

3 participants