Skip to content

Conversation

@xmas92
Copy link
Member

@xmas92 xmas92 commented Jun 30, 2023

JDK-8309675 tried to solve the issue of NMT reporting to much committed memory by faking the virtual addresses registered when committing physical memory. This mapping was simply the virtual address = physical offset in backing file + heap base. This works when ZGC gets a contiguous heap which starts at the heap base. However fails if it does not start at the heap base or is discontiguous.

This proposal fixes this by keeping track of all the reserved virtual address ranges and by creating a mapping from the physical offsets to the actual reserved virtual address ranges. If the physical offsets committed maps to multiple reserved ranges, it is processed as multiple commits.

The develop flag ZForceDiscontiguousHeapReservations is introduced to test the discontiguous heap feature and interactions.

Testing:

  • Added test on all Oracle platforms
  • GHA
  • Running tier1-3

Progress

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

Issue

  • JDK-8310743: assert(reserved_rgn != nullptr) failed: Add committed region, No reserved region found (Bug - P2)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14730/head:pull/14730
$ git checkout pull/14730

Update a local copy of the PR:
$ git checkout pull/14730
$ git pull https://git.openjdk.org/jdk.git pull/14730/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14730

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14730.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 30, 2023

👋 Welcome back aboldtch! 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 Pull request is ready for review label Jun 30, 2023
@openjdk
Copy link

openjdk bot commented Jun 30, 2023

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

  • hotspot-gc

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-gc hotspot-gc-dev@openjdk.org label Jun 30, 2023
@openjdk
Copy link

openjdk bot commented Jun 30, 2023

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

8310743: assert(reserved_rgn != nullptr) failed: Add committed region, No reserved region found

Reviewed-by: stefank, ayang

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

  • ba974d5: 8310661: JFR: Replace JVM.getJVM() with JVM
  • 496f94b: 8311086: Remove jtreg/gc/startup_warnings
  • 9d2e0b2: 8307934: JRobot.moveMouseTo must access component on EDT
  • 87c79c0: 8309302: java/net/Socket/Timeouts.java fails with AssertionError on test temporal post condition
  • 8e0ca8e: 8310331: JitTester: Exclude java.lang.Math.random
  • 055b4b4: 8310948: Fix ignored-qualifiers warning in Hotspot
  • 2c29705: 8309660: C2: failed: XMM register should be 0-15 (UseKNLSetting and ConvF2HF)
  • 52ee570: 8309209: C2 failed "assert(_stack_guard_state == stack_guard_reserved_disabled) failed: inconsistent state"
  • faf1b82: 8310656: RISC-V: __builtin___clear_cache can fail silently.
  • 0e3d91d: 8311215: [BACKOUT] JDK-8047998 Abort the vm if MaxNewSize is not the same as NewSize when MaxHeapSize is the same as InitialHeapSize
  • ... and 24 more: https://git.openjdk.org/jdk/compare/07734f6dde2b29574b6ef98eeb9e007d8801a3ea...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 Jun 30, 2023
@mlbridge
Copy link

mlbridge bot commented Jun 30, 2023

Webrevs

for (; index < _num_reservations; ++index) {
const size_t reservation_size = _reservations[index]._size;
if (*offset_in_reservation < reservation_size) {
break;
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if one can return index here. Then, after the for-loop, one can write fatal(...).

Copy link
Member Author

Choose a reason for hiding this comment

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

It was purposely written like this avoiding a fatal/guarantee/ShouldNotReachHere, the intent is to have bugs only be caught in debug. If we return _num_reservations as an index all that happens is that we do not register some commit with nmt. Which seems more favourable than crashing if some bug were to slip through into production.

offset_in_reservation = 0;
}

assert(left_to_process == 0, "everything was not commited");
Copy link
Member

Choose a reason for hiding this comment

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

When will this be reachable? I'd expect the if-check inside the for-loop to handle exit-condition.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we run out of reservations. That is the virtual memory reservations range is less than the physical memory offset we are committing. Such a thing should not be reachable and is a bug. But if it does happen it should be caught here.

Comment on lines +76 to +79
if (MemTracker::enabled()) {
Tracker tracker(Tracker::uncommit);
tracker.record((address)sub_range_addr, sub_range_size);
}
Copy link
Member

Choose a reason for hiding this comment

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

Sth like record_virtual_memory_uncommit would make this more symmetric. (Better be done in a followup PR though.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. Purposely kept this minimal as it needs to be backported to 21.

Copy link
Member

@albertnetymk albertnetymk left a comment

Choose a reason for hiding this comment

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

I think it's better to fail-early when sth unexpected occurs, so both places warrant a should-not-reach-here; subjective though.

@xmas92
Copy link
Member Author

xmas92 commented Jul 3, 2023

I generally agree with the fail early strategy. My personal ILW assessment of the two approaches made me favour this one. But maybe I'll reassess this in the future.

Thanks for all reviews.

/integrate

@openjdk
Copy link

openjdk bot commented Jul 3, 2023

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

  • ba974d5: 8310661: JFR: Replace JVM.getJVM() with JVM
  • 496f94b: 8311086: Remove jtreg/gc/startup_warnings
  • 9d2e0b2: 8307934: JRobot.moveMouseTo must access component on EDT
  • 87c79c0: 8309302: java/net/Socket/Timeouts.java fails with AssertionError on test temporal post condition
  • 8e0ca8e: 8310331: JitTester: Exclude java.lang.Math.random
  • 055b4b4: 8310948: Fix ignored-qualifiers warning in Hotspot
  • 2c29705: 8309660: C2: failed: XMM register should be 0-15 (UseKNLSetting and ConvF2HF)
  • 52ee570: 8309209: C2 failed "assert(_stack_guard_state == stack_guard_reserved_disabled) failed: inconsistent state"
  • faf1b82: 8310656: RISC-V: __builtin___clear_cache can fail silently.
  • 0e3d91d: 8311215: [BACKOUT] JDK-8047998 Abort the vm if MaxNewSize is not the same as NewSize when MaxHeapSize is the same as InitialHeapSize
  • ... and 24 more: https://git.openjdk.org/jdk/compare/07734f6dde2b29574b6ef98eeb9e007d8801a3ea...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jul 3, 2023

@xmas92 Pushed as commit f393975.

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

@xmas92 xmas92 deleted the JDK-8310743 branch January 5, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants