Skip to content

Add DDR command continuationstack - #15779

Merged
keithc-ca merged 1 commit into
eclipse-openj9:masterfrom
thallium:continuation_stackwalk
Aug 15, 2023
Merged

Add DDR command continuationstack#15779
keithc-ca merged 1 commit into
eclipse-openj9:masterfrom
thallium:continuation_stackwalk

Conversation

@thallium

Copy link
Copy Markdown
Contributor

continuationstackslots should also work

Signed-off-by: Gengchen Tuo gengchen.tuo@ibm.com

Related: #15181

@thallium
thallium force-pushed the continuation_stackwalk branch 2 times, most recently from d469672 to 9d8450a Compare August 25, 2022 15:58
@thallium

Copy link
Copy Markdown
Contributor Author

@fengxue-IS FYI

@fengxue-IS
fengxue-IS self-requested a review August 25, 2022 16:56
@fengxue-IS fengxue-IS added the project:loom Used to track Project Loom related work label Aug 25, 2022
Comment on lines 100 to 103

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we still need this if all callers have to specify either a walkThread or ContinuationAddress?

Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/StackWalker.java Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

stubELS is not defined as a pointer, you will have to either update the definition in j9nonbuilder to make it a pointer and allocate it in stdinit.c or jclcinit.c. Or get the actual address here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You mean change to entryLocalStorageEA instead? I remember entryLocalStorage and entryLocalStorageEA actually do the same thing if ELS is not a pointer, otherwise I'll have a runtime error.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

something similar to jitGPRs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Could you elaborate? I still think entryLocalStorage() returns the address of the ELS after went through some code in dtfj. What I did on jitGPRs is just one extra casting due to different type in J9VMContinuation and in J9VMEntryLocalStorage

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nvm, you are right, I was looking at the generated code for non-struct fields which directly return values, for struct fields nonNullFieldEA is used to return the address

Comment on lines 239 to 242

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would prefer if you can set these fields in the wrapper's constructor, this avoid caller code having to modify the wrapper field directly, so future changes to the wrapper behaviour will be easier.

Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/StackWalker.java Outdated
Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/StackWalker.java Outdated
@thallium
thallium force-pushed the continuation_stackwalk branch from 9d8450a to d3a3c61 Compare August 26, 2022 14:06

@fengxue-IS fengxue-IS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@fengxue-IS
fengxue-IS requested a review from keithc-ca August 26, 2022 17:04
@fengxue-IS

Copy link
Copy Markdown
Contributor

@keithc-ca can you please take a look

Comment thread runtime/oti/j9nonbuilder.h Outdated
@thallium
thallium force-pushed the continuation_stackwalk branch from d3a3c61 to cbec19b Compare August 30, 2022 22:03
@fengxue-IS

Copy link
Copy Markdown
Contributor

@thallium can you fix the line ending

@thallium
thallium force-pushed the continuation_stackwalk branch from cbec19b to 73842dd Compare September 13, 2022 02:34
@thallium

Copy link
Copy Markdown
Contributor Author

fixed

@thallium
thallium force-pushed the continuation_stackwalk branch 2 times, most recently from 586077f to b0d4b22 Compare October 3, 2022 22:22
@fengxue-IS

Copy link
Copy Markdown
Contributor

@keithc-ca This PR is ready for final review, can you take a look

Comment on lines 213 to 230

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should use J9VMContinuationPointer directly by adding in AuxFieldInfo29.dat declarations of the fields we need:

J9VMContinuation.arg0EA = UDATA*
J9VMContinuation.decompilationStack = J9JITDecompilationInfo*
J9VMContinuation.j2iFrame = UDATA*
J9VMContinuation.jitGPRs = UDATA[] /* actually: J9JITGPRSpillArea */
J9VMContinuation.literals = J9Method*
J9VMContinuation.oldEntryLocalStorage = J9VMEntryLocalStorage*
J9VMContinuation.pc = U8*
J9VMContinuation.sp = UDATA*

Use of that class may throw NoClassDefFoundError and uses of the related field accessor functions may throw NoSuchFieldException, both of which will need to be handled. ContinuationStackWalkCommand checks that the core is from a VM that should support continuations, so those exceptions signal an inconsistent dump.

I'd actually prefer that we don't introduce J9VMEntryLocalStoragePointerWrapper: can we replace the field

	public J9VMEntryLocalStoragePointer walkedEntryLocalStorage;

in WalkState with the necessary components instead?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should use J9VMContinuationPointer directly by adding in AuxFieldInfo29.dat declarations of the fields

The VM structure struct J9VMContinuation is only defined for Java 19+, including it directly will cause compile issues for Java 8/11/17

can we replace the field in WalkState with the necessary components instead?

The J9VMEntryLocalStoragePointer is using a linked-list structure, we would not be able to directly place the fields into WalkState without heavily modifying the existing code to account for how to iterate the list

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The additions I listed for AuxFieldInfo29.dat will make that type available to DDR_VM code.

The approach using J9VMEntryLocalStoragePointerWrapper just seems wrong to me. Perhaps Supplier<J9VMEntryLocalStoragePointer> is the interface we should use. The variant for a thread reads the field from the thread, and the variant for a continuation gets it via a J9VMContinuationPointer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The additions I listed for AuxFieldInfo29.dat will make that type available to DDR_VM code.

I wasn't sure if adding type after field declarations would make them available to DDR, if that is the case, we can switch to direct access under a try/catch block when reading the fields.

The approach using J9VMEntryLocalStoragePointerWrapper just seems wrong to me. Perhaps Supplier<J9VMEntryLocalStoragePointer> is the interface we should use. The variant for a thread reads the field from the thread, and the variant for a continuation gets it via a J9VMContinuationPointer.

The reasoning behind using J9VMEntryLocalStoragePointerWrapper is to minimize the code changes on existing stack walker code and to keep it as similar to the VM's walkStackFrames() API as possible to make future maintenance easier. Changing to use Supplier<T> interface would require refactor on all code access to ELS right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't see that J9VMEntryLocalStoragePointerWrapper is needed at all (nor is using Supplier<?>).

StackWalker can simply use this for a continuation:

    walkState.walkedEntryLocalStorage = continuation.oldEntryLocalStorage();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps the right container is WalkState: we either initialize that state from a thread or a continuation. Advancing from one stack frame to the next is something that should be associated with that state.

@fengxue-IS fengxue-IS Oct 24, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought we have agreed on moving the ELS data to an interface that have a different impl for J9VMEntryLocalStorage and J9VMContinuation as per #15181 (comment).

also for the linked list of oldEntryLocalStorage, putting states inside WalkState will cause complication when iterating through the linked list

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, I suggested an interface that would allow access to ELS and whatever other information needed to walk stacks. That interface is not ELS, but it seems reasonable to me to adjust WalkState to capture what is needed so navigation from one stack frame to the next can occur. Rather than require two pieces of information (WalkState and something else), the stack walker would use one (WalkState). I think part of the difficulty is that the fields of WalkState are public and modified all over the place - a mistake in my opinion. Rather than perpetuate and expand on that mistake, I'm suggesting we take the time to improve the situation (perhaps even the native implementation as well).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should try to have this version merged as a baseline on meeting functional expectation.

Refactoring WalkState to an improved design of how stack walking is done should be pursued as a new issue. I don't want to delay the loom features due to redesign / test on a rework of DDR stack walker (potentially even the native impl in swalk.c).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I disagree. From my perspective, this is not ready, and I don't think this DDR portion interferes with meeting functional expectations. It can wait until we have an appropriate implementation.

@fengxue-IS fengxue-IS mentioned this pull request Oct 13, 2022
@thallium
thallium force-pushed the continuation_stackwalk branch 2 times, most recently from fa32723 to 0a4ccfb Compare October 19, 2022 19:00
@thallium
thallium force-pushed the continuation_stackwalk branch 3 times, most recently from 095b80b to 2230c28 Compare November 28, 2022 17:23
@thallium

Copy link
Copy Markdown
Contributor Author

Reworked using the API from #16356.

@thallium

thallium commented Jul 6, 2023

Copy link
Copy Markdown
Contributor Author

@fengxue-IS @keithc-ca your comments have been addressed.

Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/WalkState.java Outdated
@thallium
thallium force-pushed the continuation_stackwalk branch from 415337a to 635dbba Compare July 7, 2023 14:23
Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/JITStackWalker.java Outdated
Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/StackWalker.java Outdated
Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/StackWalker.java Outdated
Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/StackWalker.java Outdated
Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/StackWalker.java Outdated
Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/view/dtfj/java/DTFJJavaThread.java Outdated
@thallium
thallium force-pushed the continuation_stackwalk branch from 635dbba to fde12b6 Compare August 4, 2023 21:29
@thallium

thallium commented Aug 4, 2023

Copy link
Copy Markdown
Contributor Author

@keithc-ca All your concerns have been addressed.

Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/StackWalker.java Outdated
Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/StackWalker.java Outdated
Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/WalkState.java Outdated
@thallium
thallium force-pushed the continuation_stackwalk branch from fde12b6 to 907fdac Compare August 9, 2023 19:09
Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/StackWalker.java Outdated
Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackwalker/StackWalker.java Outdated
@thallium
thallium force-pushed the continuation_stackwalk branch from 907fdac to 8a886e5 Compare August 10, 2023 14:18
Comment thread debugtools/DDR_VM/src/com/ibm/j9ddr/AuxFieldInfo29.dat Outdated
@thallium
thallium force-pushed the continuation_stackwalk branch 3 times, most recently from d696ff9 to b52d4d1 Compare August 10, 2023 22:49
Signed-off-by: Gengchen Tuo <gengchen.tuo@ibm.com>
@thallium
thallium force-pushed the continuation_stackwalk branch from b52d4d1 to e6da6c3 Compare August 14, 2023 17:55
@keithc-ca

Copy link
Copy Markdown
Contributor

Jenkins test sanity zlinux jdk21

@pshipton

Copy link
Copy Markdown
Member

Seems this change has caused a test problem #17962
Unless it can be fixed today I'll revert so we don't get all platform all version test failures in the nightly builds.

@keithc-ca @thallium

@thallium

Copy link
Copy Markdown
Contributor Author

@pshipton We're not storing walkedEntryLocalStorage in the walk state anymore so the logging part was removed. I could add the field back to the walk state so the failure should be fixed.

@pshipton

Copy link
Copy Markdown
Member

The other option is to remove the test. @TobiAjila @gacholio which do you prefer?

@keithc-ca

keithc-ca commented Aug 15, 2023

Copy link
Copy Markdown
Contributor

I don't think it makes sense to put back walkedEntryLocalStorage, so I think the test needs to be either updated or removed.

@pshipton

pshipton commented Aug 15, 2023

Copy link
Copy Markdown
Member

Doesn't seem we'll fix it in time today so I'm temp reverting this to avoid the large number of failures that will occur.

Reverted in #17963

@tajila

tajila commented Aug 24, 2023

Copy link
Copy Markdown
Contributor

Im in favour of removing parts that refer to ELS in the walkstate

@thallium I think we only need to remove this part from the test in /openj9/test/functional/DDR_Test/src/j9vm/test/ddrext/junit/TestThread.java

		/* test !stackslots thread,sp,a0,pc,literals,els */
		String paramSet2 = getStackSlotsParamSet(stackSlotsOutput,
				threadAddress, true);
		if (paramSet2 == null) {
			fail("Failed to construct parameter list for command : !stackslots thread,sp,a0,pc,literals,els\nStackSlots Output being used : \n"
					+ stackSlotsOutput);
		} else {
			String stackSlotsOutputParam2 = exec(Constants.STACKSLOTS_CMD,
					new String[] { paramSet2 });
			assertTrue(validate(stackSlotsOutputParam2,
					Constants.STACKSLOTS_SUCCESS_KEY,
					Constants.STACKSLOTS_FAILURE_KEY, true));
		}

@gacholio

Copy link
Copy Markdown
Contributor

Agreed, as long as we still print the new ELS value when we cross the call-in boundary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

project:loom Used to track Project Loom related work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants