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

Add support for -XX:[+/-]EnableDynamicAgentLoading flag #17215

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

dnakamura
Copy link
Contributor

@dnakamura dnakamura commented Apr 18, 2023

Flag controls runtime loading of dynamic agents

  • When EnableDynamicAgentLoading is enabled, OSR/HCR flags are enabled and dynamic agent loading is also enabled.
  • When EnableDynamicAgentLoading is disabled, OSR/HCR flags default to off, and are enabled if/when agents are attached at startup. Dynamic loading of agents is disabled.

Issue #17085

vm->extendedRuntimeFlags &= ~(UDATA)(J9_EXTENDED_RUNTIME_OSR_SAFE_POINT | (UDATA) J9_EXTENDED_RUNTIME_ENABLE_HCR);
} else {
vm->extendedRuntimeFlags |= (J9_EXTENDED_RUNTIME_OSR_SAFE_POINT | (UDATA)J9_EXTENDED_RUNTIME_ENABLE_HCR);
}
Copy link
Member

Choose a reason for hiding this comment

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

A couple of comments:

  1. -XX:[+|-]EnableDynamicAgentLoading is a new option introduced since Java 9, and should not be applied to Java 8;
  2. Is -XX:[+|-]EnableDynamicAgentLoading going to take precedence over -XX:[+|-]EnableHCR or -XX:[+|-]OSRSafePoint? if so, this code block needs to be after processing of VMOPT_XXENABLEOSRSAFEPOINT and VMOPT_XXENABLEHCR.

Copy link
Member

Choose a reason for hiding this comment

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

We should consider if it can apply to Java 8. As long as it doesn't change the default behaviour I don't see why it can't apply.

Copy link
Member

@JasonFengJ9 JasonFengJ9 Apr 18, 2023

Choose a reason for hiding this comment

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

-XX:[+|-]EnableHCR and -XX:[+|-]OSRSafePoint are Java 8 compatible, if there is a need to disable such capabilities for Java 8, existing flags can be applied.
If a new flag is introduced, we can apply it to Java 8 if required w/o changing default behaviours.

@tajila tajila added this to the Java 21 milestone Apr 24, 2023
@tajila
Copy link
Contributor

tajila commented May 8, 2023

I've updated the wording in the issue, #17085.

This PR is a good starting point. Additionally, we need to add the OSR/HCR flags whenever an agentlib is attached. We should also add a vm->extendedRuntimeFlag to toggles whether dynamic enablement of agents is possible or not.

@fengxue-IS
Copy link
Contributor

Is this change ready for merge? #17508 will need to use this option to determine if skipping jvmti notify can be skipped

@JasonFengJ9
Copy link
Member

Is this change ready for merge? #17508 will need to use this option to determine if skipping jvmti notify can be skipped

I guess this PR can be cherry-pick by

@dnakamura dnakamura marked this pull request as ready for review June 9, 2023 17:37
@dnakamura
Copy link
Contributor Author

Should be ready now.

runtime/jvmti/j9jvmti.tdf Outdated Show resolved Hide resolved
runtime/jvmti/jvmtiStartup.c Outdated Show resolved Hide resolved
runtime/vm/jvminit.c Outdated Show resolved Hide resolved
@dnakamura dnakamura force-pushed the dynamic_agent branch 2 times, most recently from a023106 to e724073 Compare June 13, 2023 18:18
@dnakamura
Copy link
Contributor Author

Issues should be fixed

@pshipton pshipton requested a review from keithc-ca June 14, 2023 17:13
@pshipton
Copy link
Member

@JasonFengJ9 do you have any further concerns?

runtime/jvmti/jvmtiStartup.c Outdated Show resolved Hide resolved
runtime/jvmti/jvmtiStartup.c Outdated Show resolved Hide resolved
runtime/vm/jvminit.c Outdated Show resolved Hide resolved
@dnakamura dnakamura force-pushed the dynamic_agent branch 3 times, most recently from d6bcdfd to 591c814 Compare June 27, 2023 17:56
@tajila
Copy link
Contributor

tajila commented Jul 5, 2023

@keithc-ca Any more concerns with this PR?

@tajila
Copy link
Contributor

tajila commented Jul 11, 2023

@dnakamura can you address Keiths comment

I think improving the comment on line 710 would solve my remaining concerns; yes, those flags were cleared earlier, but explaining why we want to set them now would help.

@dnakamura
Copy link
Contributor Author

@tajila should be fixed

@tajila
Copy link
Contributor

tajila commented Jul 11, 2023

@keithc-ca any further concerns?

runtime/jvmti/jvmtiStartup.c Outdated Show resolved Hide resolved
@dnakamura
Copy link
Contributor Author

@keithc-ca fixed

@keithc-ca
Copy link
Contributor

The description and the commit summary could be improved; the option is for enabling or disabling dynamic agents. The reference to the issue helps, but people reviewing the commit history shouldn't need to consult the internet.

@dnakamura dnakamura changed the title Add command line option for dynamic agent loading Add support for -XX:[+/-]EnableDynamicAgentLoading flag Jul 11, 2023
Flag controls runtime loading of dynamic agents

- When EnableDynamicAgentLoading is enabled, OSR/HCR flags are
enabled and dynamic agent loading is also enabled.
- When EnableDynamicAgentLoading is disabled, OSR/HCR  flags default
to off, and are enabled if/when agents are attached at startup.
Dynamic loading of agents is disabled.

Issue eclipse-openj9#17085

Signed-off-by: Devin Nakamura <[email protected]>
@tajila
Copy link
Contributor

tajila commented Jul 11, 2023

jenkins test sanity xlinux jdk20

@tajila
Copy link
Contributor

tajila commented Jul 11, 2023

jenkins compile win jdk11

@tajila tajila merged commit f7d246a into eclipse-openj9:master Jul 12, 2023
@pshipton
Copy link
Member

pshipton commented Jul 12, 2023

Pls create a doc issue for the new option at https://github.com/eclipse-openj9/openj9-docs/issues/

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

Successfully merging this pull request may close these issues.

6 participants