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

Coleen Phillimore coleenp at openjdk.java.net
Mon Aug 9 19:47:32 UTC 2021

On Mon, 9 Aug 2021 17:37:45 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> src/hotspot/os/posix/perfMemory_posix.cpp line 1036:
>>> 1034:   }
>>> 1035: #else
>>> 1036:   os::release_memory(addr, bytes);
>> Why doesn't AIX call munmap with os::release_memory() and then do this NMT tracking?
> 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) {


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

More information about the hotspot-runtime-dev mailing list