Skip to content

Ignore VirtualThreads in jvmtiGetAllThreads and Thread.getThreads - #15635

Merged
tajila merged 1 commit into
eclipse-openj9:masterfrom
babsingh:loom_jvmti_1
Aug 3, 2022
Merged

Ignore VirtualThreads in jvmtiGetAllThreads and Thread.getThreads #15635
tajila merged 1 commit into
eclipse-openj9:masterfrom
babsingh:loom_jvmti_1

Conversation

@babsingh

@babsingh babsingh commented Jul 27, 2022

Copy link
Copy Markdown
Contributor

This change impacts the following methods in JDK19+:

  • private static native Thread[] getThreads()
  • jvmtiGetAllThreads

Virtual threads are ignored by looking at J9VMThread->carrierThreadObject
instead of J9VMThread->threadObject.

Related: #15183

Signed-off-by: Babneet Singh sbabneet@ca.ibm.com

@babsingh

Copy link
Copy Markdown
Contributor Author

@tajila can you please review this PR?

@tajila

tajila commented Jul 27, 2022

Copy link
Copy Markdown
Contributor

jenkins test sanity amac jdk19

@tajila

tajila commented Jul 27, 2022

Copy link
Copy Markdown
Contributor

jenkins compile win jdk19

@tajila

tajila commented Jul 28, 2022

Copy link
Copy Markdown
Contributor

@babsingh youll need to rebase your changes on #15619

@babsingh

Copy link
Copy Markdown
Contributor Author

need to rebase your changes on #15619

jvmtiGetAllThreads and Thread.getThreads are different. jvmtiGetAllThreads already uses j9jni_createLocalRef and returns the thread array and number of threads under exclusive VM access. I believe that we do not need to further update it; unless, we want to reduce the thread array size to exactly match the number of live threads during return.

@babsingh

Copy link
Copy Markdown
Contributor Author

native Thread.getThreads will need to be updated to use carrierThreadObject since it excludes VirtualThreads and only targets platform threads: https://github.com/ibmruntimes/openj9-openjdk-jdk19/blob/4e70209d76774bab04fd17073e88c0109f3ab280/src/java.base/share/classes/java/lang/Thread.java#L2701-L2706.

This change impacts the following methods in JDK19+:
- private static native Thread[] getThreads()
- jvmtiGetAllThreads

Virtual threads are ignored by looking at J9VMThread->carrierThreadObject
instead of J9VMThread->threadObject.

Related: eclipse-openj9#15183

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
@babsingh babsingh changed the title [JDK19] Ignore VirtualThreads in jvmtiGetAllThreads Ignore VirtualThreads in jvmtiGetAllThreads and Thread.getThreads Jul 28, 2022
@babsingh

Copy link
Copy Markdown
Contributor Author

Updated PR to cover native Thread.getThreads. @tajila Let me know if anything was missed.

@tajila

tajila commented Aug 1, 2022

Copy link
Copy Markdown
Contributor

can you also update Java_java_lang_Thread_getThreads to return carrier threads

@babsingh

babsingh commented Aug 2, 2022

Copy link
Copy Markdown
Contributor Author

can you also update Java_java_lang_Thread_getThreads to return carrier threads

Last Thursday's update included the carrierThreadObject changes for Java_java_lang_Thread_getThreads.

@tajila

tajila commented Aug 2, 2022

Copy link
Copy Markdown
Contributor

jenkins compile win jdk19

@tajila

tajila commented Aug 2, 2022

Copy link
Copy Markdown
Contributor

jenkins test sanity amac jdk19

@tajila
tajila merged commit 6262c89 into eclipse-openj9:master Aug 3, 2022
@babsingh babsingh mentioned this pull request Aug 11, 2022
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.

2 participants