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

Thomas Stuefe stuefe at openjdk.java.net
Mon Aug 9 20:16:32 UTC 2021


On Mon, 9 Aug 2021 19:43:45 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> 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.
>
> 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) {

I agree.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4995


More information about the hotspot-runtime-dev mailing list