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

8286441: Remove mode parameter from jdk.internal.perf.Perf.attach() #8622

Closed

Conversation

iklam
Copy link
Member

@iklam iklam commented May 10, 2022

The mode parameter for jdk.internal.perf.Perf.attach() has never supported the value "rw" since the source code was imported to the openjdk repo more than 15 years ago. In fact HotSpot throws IllegalArgumentException when such a mode is specified.

It's unlikely such a mode will be required for future enhancements. Support for "rw" is removed. The "mode" parameter is also removed, since now "r" is the only supported mode.

I also cleaned up related code in the JDK and HotSpot.

Testing:

  • Passed tiers 1 ~ 5

Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (1 review required, with at least 1 reviewer)

Issue

  • JDK-8286441: Remove mode parameter from jdk.internal.perf.Perf.attach()

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/8622/head:pull/8622
$ git checkout pull/8622

Update a local copy of the PR:
$ git checkout pull/8622
$ git pull https://git.openjdk.java.net/jdk pull/8622/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 8622

View PR using the GUI difftool:
$ git pr show -t 8622

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/8622.diff

@bridgekeeper
Copy link

bridgekeeper bot commented May 10, 2022

👋 Welcome back iklam! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented May 10, 2022

@iklam The following labels will be automatically applied to this pull request:

  • core-libs
  • hotspot
  • jmx
  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org jmx jmx-dev@openjdk.org hotspot hotspot-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels May 10, 2022
@iklam iklam marked this pull request as ready for review May 10, 2022 04:04
@openjdk openjdk bot added the rfr Pull request is ready for review label May 10, 2022
@mlbridge
Copy link

mlbridge bot commented May 10, 2022

Webrevs

}

FileChannel fc = new RandomAccessFile(f, "r").getChannel();
ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0L, (int)fc.size());
fc.close(); // doesn't need to remain open
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can change this to:

        try (FileChannel fc = FileChannel.open(f.toPath())) {
            ByteBuffer bb = ...
            createPerfDataBuffer(bb, 0);
        }

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@AlanBateman
Copy link
Contributor

I skimmed through the changes and I think they look okay. In the distant past there were tools outside of the JDK that used the jvmstat API directly. It's possible that VisualVM still does but it would only compile/run if --add-exports is used to export the sun.jvmstat.* packages. So it might be that dropping the parameter from a method in RemoteHost is noticed and I think that is okay because this package is not exported and is not meant to be used by code outside of the JDK.

Copy link
Member

@cl4es cl4es left a comment

Choose a reason for hiding this comment

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

Nice cleanup!

(Some stylistic suggestions inline, feel free to ignore)

@@ -67,17 +67,13 @@ public RemoteHostImpl(int rmiPort) throws MonitorException {
monitoredHost.addHostListener(this);
}

public RemoteVm attachVm(int lvmid, String mode)
public RemoteVm attachVm(int lvmid)
throws RemoteException, MonitorException {
Integer v = lvmid;
RemoteVm stub = null;
StringBuilder sb = new StringBuilder();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
StringBuilder sb = new StringBuilder();
String vmidStr = "local://" + lvmid + "@localhost";

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@@ -148,7 +143,7 @@ class PerfMemory : AllStatic {

// methods for attaching to and detaching from the PerfData
// memory segment of another JVM process on the same system.
static void attach(const char* user, int vmid, PerfMemoryMode mode,
static void attach(const char* user, int vmid,
Copy link
Member

Choose a reason for hiding this comment

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

One line?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

// attach to the PerfData memory region for the specified VM
PerfMemory::attach(user_utf, vmid, (PerfMemory::PerfMemoryMode) mode,
PerfMemory::attach(user_utf, vmid,
Copy link
Member

Choose a reason for hiding this comment

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

One line?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@@ -1796,7 +1778,7 @@ void PerfMemory::delete_memory_region() {
// the indicated process's PerfData memory region into this JVMs
// address space.
//
void PerfMemory::attach(const char* user, int vmid, PerfMemoryMode mode,
void PerfMemory::attach(const char* user, int vmid,
Copy link
Member

Choose a reason for hiding this comment

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

One line?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@openjdk
Copy link

openjdk bot commented May 10, 2022

@iklam This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8286441: Remove mode parameter from jdk.internal.perf.Perf.attach()

Reviewed-by: redestad, alanb

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 48 new commits pushed to the master branch:

  • 46a775a: 8286540: Build failure caused by missing DefaultPollerProvider implementation on AIX
  • 4ad8cfa: 8286002: Add support for intel syntax to capstone hsdis
  • cec23b1: 8286556: Remove EagerInitialization develop option
  • 89de756: 8286387: Remove unused FreeListAllocator::reduce_free_list
  • ae695d6: 8286476: x86_32: Fix crashes with non-preview mode after JDK-8284161 (Virtual Threads)
  • 87f3d2b: 8286446: PPC64: fix crashes after JDK-8284161 (virtual threads preview)
  • 7a2bbbb: 8286396: Address possibly lossy conversions in jdk.management.jfr
  • 9ac52b0: 8286392: Address possibly lossy conversions in jdk.jfr
  • f628966: 8286541: JFR: RecordingFile.write is missing "since 19"
  • f1554fc: 8285872: JFR: Remove finalize() methods
  • ... and 38 more: https://git.openjdk.java.net/jdk/compare/54e33082105dcbcfc795839c954f6e63402edff1...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 10, 2022
@iklam
Copy link
Member Author

iklam commented May 11, 2022

I skimmed through the changes and I think they look okay. In the distant past there were tools outside of the JDK that used the jvmstat API directly. It's possible that VisualVM still does but it would only compile/run if --add-exports is used to export the sun.jvmstat.* packages. So it might be that dropping the parameter from a method in RemoteHost is noticed and I think that is okay because this package is not exported and is not meant to be used by code outside of the JDK.

The APIs changed by this PR are:

  • sun.jvmstat.monitor.remote.RemoteHost::attachVm
  • sun.jvmstat.monitor.VmIdentifier::getMode
  • sun.jvmstat.monitor.HostIdentifier::getMode
  • jdk.internal.perf.Perf::attach

I checked the latest VisualVM source code. Some of the above classes are referenced, but none of the affected APIs are called.

@iklam
Copy link
Member Author

iklam commented May 11, 2022

Thanks to @AlanBateman and @cl4es for the review.
/integrate

@openjdk
Copy link

openjdk bot commented May 11, 2022

Going to push as commit fcf49f4.
Since your change was applied there have been 48 commits pushed to the master branch:

  • 46a775a: 8286540: Build failure caused by missing DefaultPollerProvider implementation on AIX
  • 4ad8cfa: 8286002: Add support for intel syntax to capstone hsdis
  • cec23b1: 8286556: Remove EagerInitialization develop option
  • 89de756: 8286387: Remove unused FreeListAllocator::reduce_free_list
  • ae695d6: 8286476: x86_32: Fix crashes with non-preview mode after JDK-8284161 (Virtual Threads)
  • 87f3d2b: 8286446: PPC64: fix crashes after JDK-8284161 (virtual threads preview)
  • 7a2bbbb: 8286396: Address possibly lossy conversions in jdk.management.jfr
  • 9ac52b0: 8286392: Address possibly lossy conversions in jdk.jfr
  • f628966: 8286541: JFR: RecordingFile.write is missing "since 19"
  • f1554fc: 8285872: JFR: Remove finalize() methods
  • ... and 38 more: https://git.openjdk.java.net/jdk/compare/54e33082105dcbcfc795839c954f6e63402edff1...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 11, 2022
@openjdk openjdk bot closed this May 11, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 11, 2022
@openjdk
Copy link

openjdk bot commented May 11, 2022

@iklam Pushed as commit fcf49f4.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated jmx jmx-dev@openjdk.org serviceability serviceability-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

4 participants