Skip to content

Conversation

@fengxue-IS
Copy link
Contributor

@fengxue-IS fengxue-IS commented Jan 30, 2025

Update thread status changes to j.l.Thread fields so getState() API
can be called without needing to halt the target thread.

Rework of #20550

Co-dependent extension repo changes:
JDK21: ibmruntimes/openj9-openjdk-jdk21#246
JDK25: ibmruntimes/openj9-openjdk-jdk25#43
JDKnext: ibmruntimes/openj9-openjdk-jdk#927

Fixes: #17251

Co-authored-by: Nathan Henderson nathan.henderson@ibm.com
Signed-off-by: Jack Lu Jack.S.Lu@ibm.com

@fengxue-IS fengxue-IS force-pushed the threadstate2 branch 2 times, most recently from 6528e33 to aa845d1 Compare January 30, 2025 21:57
@fengxue-IS
Copy link
Contributor Author

Personal test build on JDK 8 & 21

@fengxue-IS
Copy link
Contributor Author

@babsingh can you please take a look

Copy link
Contributor

@babsingh babsingh left a comment

Choose a reason for hiding this comment

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

Changes LGTM functionally. Minor nits.

For JDK21+, the j.l.Thread implementation is different. Have you opened the extension repo PRs? Will we need to coordinate the merge between this PR and the extension repo PRs?

Which JDK versions (11,17,21) and test suites (sanity.functional,sanity.openjdk) have you used to test these changes in your personal build?

@babsingh
Copy link
Contributor

Can you also squash the commits and link this PR to the following perf issue: #17251?

@babsingh
Copy link
Contributor

@gacholio Can you also review these changes?

@fengxue-IS
Copy link
Contributor Author

For JDK21+, the j.l.Thread implementation is different. Have you opened the extension repo PRs? Will we need to coordinate the merge between this PR and the extension repo PRs?

Yes, I've opened PR for 21 & JDK next, see PR referenced above. will also include the link in PR description.
And yes the PR's would require a coordinated merge with extension repo

Which JDK versions (11,17,21) and test suites (sanity.functional,sanity.openjdk) have you used to test these changes in your personal build?

Testing have been done for 8,11,21 with sanity.functional & sanity.openjdk on xlinux

Copy link
Contributor

@gacholio gacholio left a comment

Choose a reason for hiding this comment

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

Looks good as far as it goes. We should attempt to transition to using the state field everywhere instead of attempting to derive it from various other states and bits (in a future PR).

@gacholio
Copy link
Contributor

gacholio commented Feb 3, 2025

Please squash the commits.

@fengxue-IS
Copy link
Contributor Author

I've created the extension change for JDK24, will test removing the sync block in JDK21+ locally to see if it is still needed after the started check have been moved before checking eetop

@gacholio
Copy link
Contributor

gacholio commented Feb 4, 2025

Beware the possibility of out-of-order memory operations.

@fengxue-IS fengxue-IS force-pushed the threadstate2 branch 2 times, most recently from cd71984 to 09b5f25 Compare February 6, 2025 22:07
@fengxue-IS
Copy link
Contributor Author

squashed commits, updated extension changes

@babsingh
Copy link
Contributor

babsingh commented Feb 6, 2025

translateJ9VMThreadStateToThreadState feedback for the switch case statement and missing param[in] also needs to be applied to the extension repo PRs.

@fengxue-IS
Copy link
Contributor Author

translateJ9VMThreadStateToThreadState feedback for the switch case statement and missing param[in] also needs to be applied to the extension repo PRs.

done

@babsingh
Copy link
Contributor

jenkins test sanity.openjdk,sanity.functional plinux jdk11

@babsingh
Copy link
Contributor

jenkins test sanity.openjdk,sanity.functional zlinux jdk21 depends ibmruntimes/openj9-openjdk-jdk21#246

@babsingh
Copy link
Contributor

jenkins test sanity.openjdk,sanity.functional zlinux jdk24 depends ibmruntimes/openj9-openjdk-jdk24#18

@babsingh
Copy link
Contributor

Jenkins compile win jdk17

@fengxue-IS
Copy link
Contributor Author

windows failure due to U_64 / U_32 conversion, will update VM_VMHelpers::setThreadState to use U_32 with explicit cast to avoid warning on windows. waiting until the other platform passes before pushing change.

@fengxue-IS fengxue-IS force-pushed the threadstate2 branch 4 times, most recently from cf021b8 to 15e11f3 Compare September 3, 2025 18:58
@pshipton
Copy link
Member

@fengxue-IS what's happening with this?

@pshipton
Copy link
Member

This is blocking ibmruntimes/openj9-openjdk-jdk#927 which is needed to fix https://github.ibm.com/runtimes/openj9-openjdk-jdk21-zos/issues/522 which is marked as must fix.

@fengxue-IS
Copy link
Contributor Author

@fengxue-IS what's happening with this?

There is some test failures on JDK24+ due to the addition of yielding virtual threads with monitors where the monitors in transition may have an incorrect state, another case is pinned virtual thread doesn't behave correctly for wait/notify due to the use of native API which doesn't update the virtual thread status.

I've pushed my latest change which have passed the known failures in local build/test.
Running personal build to verify there isn't any regression: https://hyc-runtimes-jenkins.swg-devops.com/view/OpenJ9%20-%20Personal/job/Pipeline-Build-Test-Personal/29845/

@fengxue-IS fengxue-IS marked this pull request as ready for review September 11, 2025 17:56
@tajila
Copy link
Contributor

tajila commented Sep 11, 2025

jenkins test sanity alinux64 jdk25 depends ibmruntimes/openj9-openjdk-jdk25#43

@keithc-ca
Copy link
Contributor

Please add a comment in j9nonbuilder.h explaining that the values of J9VMTHREAD_STATE_* must not change because they are hard-coded in Thread.java.

@fengxue-IS fengxue-IS force-pushed the threadstate2 branch 3 times, most recently from 30dcc5d to 3b3a885 Compare September 16, 2025 19:33
@fengxue-IS fengxue-IS changed the title [WIP] Support using threadStatus field in JVM native Support using threadStatus field in JVM native Sep 16, 2025
@fengxue-IS
Copy link
Contributor Author

@keithc-ca can you please take another look

Copy link
Contributor

@keithc-ca keithc-ca left a comment

Choose a reason for hiding this comment

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

Please either squash, or arrange that changes to any given file are in a single commit. For example, VMHelpers.hpp should have the final change in the first (or only) commit.

fengxue-IS and others added 2 commits September 17, 2025 14:37
- Update thread status changes to j.l.Thread fields so getState() API
  can be called without needing to halt the target thread.
- Add support of virtual thread state for JDK24+

Co-authored-by: Nathan Henderson <nathan.henderson@ibm.com>
Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
@keithc-ca
Copy link
Contributor

Jenkins test sanity alinux64 jdk17

@keithc-ca keithc-ca merged commit 1ee805a into eclipse-openj9:master Sep 18, 2025
6 checks passed
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.

Thread::getState is a scalability issue

6 participants