-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8356228: NMT does not record reserved memory base address correctly #25719
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
Open
afshin-zafari
wants to merge
1
commit into
openjdk:master
Choose a base branch
from
afshin-zafari:_8356228_nmt_false_pos_on_overlapped_rgns
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to capture this logic in a test, so we can always check for this behavior?
Where in the code do we release and check for the special case of
mtClassShared
?I'm not 100% sure I understand why we have to first reserve with
mtNone
and only then change it tomtClassShared
. Why can't we reserve withmtClassShared
right from the start?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Work on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
virtualMemoryTracker.cpp, remove_released_region(adddress, size)
in anif
block as this:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sequence is as follows:
All the reserve/release operations here are from
os::
namespace and therefore will call NMT tracking API1- CDS requests for reserving
S
bytes at addressBase
with alignmentA
and memTagM
.2- Due to OS alignment limitations regarding
A
, new baseXBase
to be used with new sizeXS
. Read X as extra here.3- Do instead, reserve
XS
bytes atXBase
.4- If succeeds, memory would be like
<--s1---><----S----><----s2--->
, whereXS = s1 + S + s2
andXBase + s1 == Base
5- Release extra parts
s1
ands2
.6- request at step 1 above is fulfilled now.
If at step 1, the memTag
M
ismtClassShared
, the releases at step 5 will be ignored by NMT. Which means that there are regions in NMT lists that are actually released (at os level) but NMT takes them still as reserved. Therefore, further reservations by os at those regions (e.g., for stack) will intersect with existing NMT regions and the NMT assertions fail. So the memTag is to bemtNone
to bypass/avoid the NMT ignore branch.If we want to track the new memory region as belongs to CDS, we need to set the memTag of the region to
mtClassShared
with the correspondingMemTracker
API.(as is done here in this PR)