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

Reviewed-by: stuefe, coleenp
This commit is contained in:
Harold Seigel 2021-08-10 12:17:08 +00:00
parent f2599ad867
commit 2b05fae155

View File

@ -1023,18 +1023,23 @@ static char* mmap_create_shared(size_t size) {
return mapAddress; return mapAddress;
} }
// release a named shared memory region // release a named shared memory region that was mmap-ed.
// //
static void unmap_shared(char* addr, size_t bytes) { static void unmap_shared(char* addr, size_t bytes) {
#if defined(_AIX) int res;
// Do not rely on os::reserve_memory/os::release_memory to use mmap. if (MemTracker::tracking_level() > NMT_minimal) {
// Use os::reserve_memory/os::release_memory for PerfDisableSharedMem=1, mmap/munmap for PerfDisableSharedMem=0 // Note: Tracker contains a ThreadCritical.
if (::munmap(addr, bytes) == -1) { Tracker tkr(Tracker::release);
warning("perfmemory: munmap failed (%d)\n", errno); res = ::munmap(addr, bytes);
if (res == 0) {
tkr.record((address)addr, bytes);
}
} else {
res = ::munmap(addr, bytes);
}
if (res != 0) {
log_info(os)("os::release_memory failed (" PTR_FORMAT ", " SIZE_FORMAT ")", p2i(addr), bytes);
} }
#else
os::release_memory(addr, bytes);
#endif
} }
// create the PerfData memory region in shared memory. // create the PerfData memory region in shared memory.