-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8366658: Add missing locks when accessing the VirtualMemoryTracker instance in tests and MemMapPrinter #27038
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
Conversation
|
👋 Welcome back jsjolen! A progress list of the required criteria for merging this PR into |
|
@jdksjolen 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: 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 242 new commits pushed to the
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 |
|
@jdksjolen The following label will be automatically applied to this pull request:
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. |
43b7e19 to
6904d36
Compare
| class VirtualMemoryWalker : public StackObj { | ||
| public: | ||
| virtual bool do_allocation_site(const ReservedMemoryRegion* rgn) { return false; } | ||
| public: | ||
| virtual bool do_allocation_site(const ReservedMemoryRegion* rgn) { return false; } | ||
| }; |
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.
Indentation fix
| LOG("In reserved region " PTR_FORMAT ", size %X:", p2i(rmr.base()), rmr.size()); | ||
| VirtualMemoryTracker::Instance::tree()->visit_committed_regions(rmr, [&](CommittedMemoryRegion& region) { | ||
| vmt.tree()->visit_committed_regions(rmr, [&](CommittedMemoryRegion& region) { | ||
| LOG(" committed region: " PTR_FORMAT ", size %X", p2i(region.base()), region.size()); |
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.
Here the VMT was passed along but never actually used for printing
| bool VirtualMemoryTracker::walk_virtual_memory(VirtualMemoryWalker* walker) { | ||
| MemTracker::NmtVirtualMemoryLocker nvml; | ||
| bool ret = true; | ||
| tree()->visit_reserved_regions([&](ReservedMemoryRegion& rgn) { | ||
| if (!walker->do_allocation_site(&rgn)) { | ||
| ret = false; | ||
| return false; | ||
| } | ||
| return true; | ||
| }); | ||
| return true; | ||
| return ret; | ||
| } |
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.
A VirtualMemoryWalker returned true or false depending on whether or not its operation succeeded, and we are meant to pass that along as the return value of walk_virtual_memory. That was missing, now fixed.
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.
Nice catch!
| static inline bool walk_virtual_memory(VirtualMemoryWalker* walker) { | ||
| assert_post_init(); | ||
| if (!enabled()) return false; | ||
| MemTracker::NmtVirtualMemoryLocker nvml; | ||
| return VirtualMemoryTracker::Instance::walk_virtual_memory(walker); | ||
| } | ||
|
|
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.
Added this so that we can do the usual checks and lock taking in the place where we typically take the lock.
Webrevs
|
| { | ||
| MemTracker::NmtVirtualMemoryLocker nvml; | ||
| VirtualMemoryTracker::Instance::add_reserved_region(stack_end, stack_size, CALLER_PC, mtThreadStack); | ||
| } | ||
|
|
||
| // snapshot current stack usage | ||
| VirtualMemoryTracker::Instance::snapshot_thread_stacks(); | ||
| { | ||
| MemTracker::NmtVirtualMemoryLocker nvml; | ||
| VirtualMemoryTracker::Instance::snapshot_thread_stacks(); | ||
| } |
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.
Why two separate locking blocks?
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.
No reason, let's merge them.
| } | ||
| } | ||
|
|
||
| static inline bool walk_virtual_memory(VirtualMemoryWalker* walker) { |
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.
Nit: should probably be in memTracker.inline.hpp?
| return VirtualMemoryTracker::Instance::walk_virtual_memory(walker); | ||
| } | ||
|
|
||
| static inline MemoryFileTracker::MemoryFile* register_file(const char* descriptive_name) { |
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.
Same here. I wonder why we have the inline header when it only contains MemTracker::check_exceeds_limit...
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.
Hmm, so do I. I've never used the inline header myself. I think moving stuff over to the inline header is something we should think about in a separate PR.
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.
I'm okay with that.
| bool VirtualMemoryTracker::walk_virtual_memory(VirtualMemoryWalker* walker) { | ||
| MemTracker::NmtVirtualMemoryLocker nvml; | ||
| bool ret = true; | ||
| tree()->visit_reserved_regions([&](ReservedMemoryRegion& rgn) { | ||
| if (!walker->do_allocation_site(&rgn)) { | ||
| ret = false; | ||
| return false; | ||
| } | ||
| return true; | ||
| }); | ||
| return true; | ||
| return ret; | ||
| } |
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.
Nice catch!
Arraying
left a comment
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.
Happy to address the inline header refactoring separately.
Co-authored-by: David Holmes <62092539+dholmes-ora@users.noreply.github.com>
|
|
afshin-zafari
left a comment
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.
LGTM. Thanks.
|
/integrate Thanks! |
|
Going to push as commit a7dc011.
Your commit was automatically rebased without conflicts. |
|
@jdksjolen Pushed as commit a7dc011. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi,
This PR adds the missing locks for the tests and MemMapPrinter, also fixes a small bug in
walk_virtual_memory. See inline review comments.Passes tier1.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27038/head:pull/27038$ git checkout pull/27038Update a local copy of the PR:
$ git checkout pull/27038$ git pull https://git.openjdk.org/jdk.git pull/27038/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27038View PR using the GUI difftool:
$ git pr show -t 27038Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27038.diff
Using Webrev
Link to Webrev Comment