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

8260262: Use common code in function unmap_shared() in perfMemory_posix.cpp #4995

Closed
wants to merge 1 commit into from

Conversation

hseigel
Copy link
Member

@hseigel hseigel commented Aug 4, 2021

Please review this change to use common code in function unmap_shared() in perfMemory_posix.cpp, to fix JDK-8260262. The change calls munmap() directly to deallocate the memory because functions mmap_create_shared() and mmap_attach_shared() call mmap() directly to allocate the memory.

The change was tested by running Mach5 tiers 1-2 on Linux, MacOS, and Windows, and Mach5 tiers 3-5 on Linux x64 and MacOS x64.

Note that testing on AIX is needed.

Thanks, Harold


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8260262: Use common code in function unmap_shared() in perfMemory_posix.cpp

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4995

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Aug 4, 2021

👋 Welcome back hseigel! 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 openjdk bot added the rfr label Aug 4, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 4, 2021

@hseigel The following label will be automatically applied to this pull request:

  • hotspot-runtime

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

@openjdk openjdk bot added the hotspot-runtime label Aug 4, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Aug 4, 2021

Webrevs

tstuefe
tstuefe approved these changes Aug 9, 2021
Copy link
Member

@tstuefe tstuefe left a comment

Hi Harold,

thank you for doing this. The patch looks fine to me.

About AIX testing, SAP started to withdraw from AIX development and IBM will take a bigger role in the long run. One of the effects of that decision is that we gave up our AIX CI for OpenJDK head. I still can build and test manually if necessary, but let's first see if IBM has their AIX test systems up yet.

@tellison, could you guys test this or should I do this?

Thank you!

@openjdk
Copy link

@openjdk openjdk bot commented Aug 9, 2021

@hseigel 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:

8260262: Use common code in function unmap_shared() in perfMemory_posix.cpp

Reviewed-by: stuefe, coleenp

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 56 new commits pushed to the master branch:

  • 7fc99cf: 8225488: Examine ExecutableType.getReceiverType behavior when source receiver parameter is absent
  • 4548677: 8268824: Remove unused jdk.accessibility APIs deprecated for removal in JDK 9
  • b53828b: 8272047: java/nio/channels/FileChannel/Transfer2GPlus.java failed with Unexpected transfer size: 2147418112
  • 41dc795: 8264792: The NumberFormat for locale sq_XK formats price incorrectly.
  • 9c6457f: 8267385: Create NSAccessibilityElement implementation for JavaComponentAccessibility
  • 0ac2be9: 8272123: Problem list 4 jtreg tests which regularly fail on macos-aarch64
  • 272fcb4: 8272113: Build compare script fails with differences in classlist
  • 2f7a469: 8271931: Make AbortVMOnVMOperationTimeout more resilient to OS scheduling
  • a86ac0d: 8271939: Clean up primitive raw accessors in oopDesc
  • b84a9c7: 8271956: AArch64: C1 build failed after JDK-8270947
  • ... and 46 more: https://git.openjdk.java.net/jdk/compare/452f7d764fc0112cabf0be944e4233173d63f933...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 label Aug 9, 2021
}
#else
os::release_memory(addr, bytes);
Copy link
Contributor

@coleenp coleenp Aug 9, 2021

Choose a reason for hiding this comment

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

Why doesn't AIX call munmap with os::release_memory() and then do this NMT tracking?

Copy link
Member

@tstuefe tstuefe Aug 9, 2021

Choose a reason for hiding this comment

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

I'm not sure I understand what you are proposing.

The old code was incorrect since it used raw ::mmap() to map perf memory, but used os::release_memory() to release it. This was asymmetric and assumed the underlying implementation for os::reserve/release... uses mmap, which is not always true. The patch corrects this by coupling raw ::mmap with raw ::munmap, and do NMT tracking accordingly.

Arguably, one could factor out mmap+NMT and munmap+NMT in os_posix.cpp. We probably have a number of places where this would be needed. E.g. polling pages and such. But I guess that was out of scope for this issue.

Copy link
Contributor

@coleenp coleenp Aug 9, 2021

Choose a reason for hiding this comment

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

I see, reading the code more ... The code to create the perf memory if PerfDisableSharedMemory=0 used mmap directly so it makes sense to use munmap directly too. This is definitely better.

Aside: This definition is the same on all the posix platforms so could be moved. Not with this RFE but definitely a trivial one.
bool os::pd_unmap_memory(char* addr, size_t bytes) {

Copy link
Member

@tstuefe tstuefe Aug 9, 2021

Choose a reason for hiding this comment

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

I agree.

coleenp
coleenp approved these changes Aug 9, 2021
Copy link
Contributor

@coleenp coleenp left a comment

Looks good.

}
#else
os::release_memory(addr, bytes);
Copy link
Contributor

@coleenp coleenp Aug 9, 2021

Choose a reason for hiding this comment

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

I see, reading the code more ... The code to create the perf memory if PerfDisableSharedMemory=0 used mmap directly so it makes sense to use munmap directly too. This is definitely better.

Aside: This definition is the same on all the posix platforms so could be moved. Not with this RFE but definitely a trivial one.
bool os::pd_unmap_memory(char* addr, size_t bytes) {

@hseigel
Copy link
Member Author

@hseigel hseigel commented Aug 10, 2021

Thanks Thomas and Coleen for reviewing this change.

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Aug 10, 2021

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

  • f2599ad: 8272196: Remove unused class ParStrongRootsScope
  • 1f88134: 8271869: AArch64: build errors with GCC11 in frame::saved_oop_result
  • 089e83b: 8266490: Extend the OSContainer API to support the pids controller of cgroups
  • 2384e12: 8270098: ZGC: ZBarrierSetC2::clone_at_expansion fails with "Guard against surprises" assert
  • d53d94b: 8271925: ZGC: Arraycopy stub passes invalid oop to load barrier
  • 3b899ef: 8272168: some hotspot runtime/logging tests don't check exit code
  • abdc107: 8270454: G1: Simplify region index comparison
  • eb6f3fe: 8272169: runtime/logging/LoaderConstraintsTest.java doesn't build test.Empty
  • 9654fd7: 8271892: mark hotspot runtime/PrintStringTableStats/PrintStringTableStatsTest.java test as ignoring external VM flags
  • 843943c: 8263567: gtests don't terminate the VM safely
  • ... and 56 more: https://git.openjdk.java.net/jdk/compare/452f7d764fc0112cabf0be944e4233173d63f933...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Aug 10, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Aug 10, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 10, 2021

@hseigel Pushed as commit 2b05fae.

💡 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
hotspot-runtime integrated
3 participants