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
8253332: ZGC: Make heap views reservation platform independent #236
8253332: ZGC: Make heap views reservation platform independent #236
Conversation
/label add hotspot-gc |
|
@stefank |
@stefank 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 |
Webrevs
|
// Failed to reserve memory at the requested address | ||
unmap((uintptr_t)res, size); | ||
return false; | ||
os_unreserve(res, 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.
A bit odd to see the assymetry here: mmap
is used above, so munmap
would be expected here? I see os_unreserve
does the same thing, but does it guaranteed to do so?
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.
Yes. I agree. Will fix.
} | ||
|
||
// Register address views with native memory tracker | ||
nmt_reserve(ZAddress::marked0(start), 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.
The first arguments are the same as locals marked0
, marked1
, remapped
above, right? Can be reused then?
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.
Yes. At one point I had this part extracted into a separate function and had to re-resolve those values.
This was meant to only be reviewed on hotspot-gc-dev. Removing hotspot-dev. |
/label remove hotspot |
@stefank |
// Failed to reserve memory at the requested address | ||
unmap((uintptr_t)res, size); | ||
return false; | ||
munmap((void*)res, 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.
No assert for munmap
result? I don't care either way, but it would probably be nice to capture 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.
Also, hold on a sec. Shouldn't this path return 0
too? Otherwise callers get the non-zero address that is effectively unusable.
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.
For this particular function, the calling code is responsible for dealing with that. That is, I adopted the style used by the windows reserve_contiguous_platform, instead of using the posix implementation. But it's probably nicer to not leak out that address unnecessarily. I'll change this to the posix version instead.
@stefank This change now passes all automated pre-integration checks. In addition to the automated checks, the change must also fulfill all project specific requirements After integration, the commit message will be:
Since the source branch of this PR was last updated there have been 26 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 automatic rebasing, please merge
|
Thanks @shipilev. I went ahead and updated the code to not leak out the bad address, fixed a parameter name, and added a windows assert. |
May I suggest that we instead just keep to the convention we have (here and in other classes) and use an _os suffix on these new functions? |
// Make the address range free | ||
_manager.free(start, 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.
I think we can just move these two lines to the end of reserve_contiguous_inner(), and remove this function.
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.
Good point.
There's no strong convention that we postfix with os. During the Windows port I introduced two usages, both named initialize_os. Now when more OS specific code is added, and I need to split initialize_os into two function, the postfix makes it less clear what the OS-specific API extension points are. Some of my motivations for going with a prefix instead:
I was considering splitting it out into a sub-interface, just to not have to deal with the *fix discussion/problem, but decided against it since the implementations needed member variables from ZVirtualMemoryManager. |
@stefank That convention actually goes back to when ZGC was first integrated, with *_platform. However some of those *_platform functions has been removed over time as they were no longer needed. When the Windows port came in we said we should move away from *_platform to *_os, *_cpu and *_os_cpu to be more explicit and cater for potential future needs. To me, the suffix-style reads a bit better, the relationship between e.g. initialize() and initialize_os() becomes a bit more obvious, and it maps well to the platform specific file name convention we have in HotSpot (e.g. *_linux_x86.hpp). Having said that, I'm ok with changing the convention to prefix-style. |
About the last point: HotSpot code uses suffix for the platform file names, but the pd part is mostly a prefix. Would you mind if I changed the few x_platform functions we have to pd_x functions? That way we don't invent our own way to mark platform-dependent code. |
@stefank That would work for me. |
/integrate |
@stefank Since your change was applied there have been 26 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit fbfb62d. |
ZVirtualMemoryManager::reserve_contiguous_platform tries to reserve three views of a given address range. The posix and windows versions are more or less duplicates, with calls to platform dependent versions of reserve/unreserve functions.
I'd like to clean this up in preparation of an alternative implementation for heap memory allocation on Windows.
I choose to prefix the OS dependent functions with os_. For consistency, initialize_os should have been renamed as well, but the plan is to change that in a separate patch that splits that function into two, so I skipped it for now.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/236/head:pull/236
$ git checkout pull/236