# HG changeset patch # User iveresov # Date 1325033029 28800 # Node ID 739e52129c843e705006efbc4739867e56500b07 # Parent d68bb6ceb0d7fe7680e8b3b6dfd2f1809a0359b9 7124829: NUMA: memory leak on Linux with large pages Summary: In os::free_memory() use mmap with the same attributes as for the heap space Reviewed-by: kvn Contributed-by: Aleksey Ignatenko diff -r d68bb6ceb0d7 -r 739e52129c84 hotspot/src/os/bsd/vm/os_bsd.cpp --- a/hotspot/src/os/bsd/vm/os_bsd.cpp Tue Dec 27 12:38:49 2011 -0800 +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp Tue Dec 27 16:43:49 2011 -0800 @@ -2835,7 +2835,7 @@ #endif } -void os::free_memory(char *addr, size_t bytes) { +void os::free_memory(char *addr, size_t bytes, size_t alignment_hint) { ::madvise(addr, bytes, MADV_DONTNEED); } diff -r d68bb6ceb0d7 -r 739e52129c84 hotspot/src/os/linux/vm/os_linux.cpp --- a/hotspot/src/os/linux/vm/os_linux.cpp Tue Dec 27 12:38:49 2011 -0800 +++ b/hotspot/src/os/linux/vm/os_linux.cpp Tue Dec 27 16:43:49 2011 -0800 @@ -2546,8 +2546,8 @@ } } -void os::free_memory(char *addr, size_t bytes) { - commit_memory(addr, bytes, false); +void os::free_memory(char *addr, size_t bytes, size_t alignment_hint) { + commit_memory(addr, bytes, alignment_hint, false); } void os::numa_make_global(char *addr, size_t bytes) { diff -r d68bb6ceb0d7 -r 739e52129c84 hotspot/src/os/solaris/vm/os_solaris.cpp --- a/hotspot/src/os/solaris/vm/os_solaris.cpp Tue Dec 27 12:38:49 2011 -0800 +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Tue Dec 27 16:43:49 2011 -0800 @@ -2821,7 +2821,7 @@ } // Uncommit the pages in a specified region. -void os::free_memory(char* addr, size_t bytes) { +void os::free_memory(char* addr, size_t bytes, size_t alignment_hint) { if (madvise(addr, bytes, MADV_FREE) < 0) { debug_only(warning("MADV_FREE failed.")); return; diff -r d68bb6ceb0d7 -r 739e52129c84 hotspot/src/os/windows/vm/os_windows.cpp --- a/hotspot/src/os/windows/vm/os_windows.cpp Tue Dec 27 12:38:49 2011 -0800 +++ b/hotspot/src/os/windows/vm/os_windows.cpp Tue Dec 27 16:43:49 2011 -0800 @@ -3130,7 +3130,7 @@ } void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) { } -void os::free_memory(char *addr, size_t bytes) { } +void os::free_memory(char *addr, size_t bytes, size_t alignment_hint) { } void os::numa_make_global(char *addr, size_t bytes) { } void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) { } bool os::numa_topology_changed() { return false; } diff -r d68bb6ceb0d7 -r 739e52129c84 hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp --- a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp Tue Dec 27 12:38:49 2011 -0800 +++ b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp Tue Dec 27 16:43:49 2011 -0800 @@ -282,7 +282,7 @@ // large page can be broken down if we require small pages. os::realign_memory((char*)aligned_region.start(), aligned_region.byte_size(), page_size()); // Then we uncommit the pages in the range. - os::free_memory((char*)aligned_region.start(), aligned_region.byte_size()); + os::free_memory((char*)aligned_region.start(), aligned_region.byte_size(), page_size()); // And make them local/first-touch biased. os::numa_make_local((char*)aligned_region.start(), aligned_region.byte_size(), lgrp_id); } @@ -297,7 +297,7 @@ assert((intptr_t)aligned_region.start() % page_size() == 0 && (intptr_t)aligned_region.byte_size() % page_size() == 0, "Bad alignment"); assert(region().contains(aligned_region), "Sanity"); - os::free_memory((char*)aligned_region.start(), aligned_region.byte_size()); + os::free_memory((char*)aligned_region.start(), aligned_region.byte_size(), page_size()); } } @@ -954,7 +954,7 @@ if (e != scan_end) { if ((page_expected.size != page_size || page_expected.lgrp_id != lgrp_id()) && page_expected.size != 0) { - os::free_memory(s, pointer_delta(e, s, sizeof(char))); + os::free_memory(s, pointer_delta(e, s, sizeof(char)), page_size); } page_expected = page_found; } diff -r d68bb6ceb0d7 -r 739e52129c84 hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp --- a/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp Tue Dec 27 12:38:49 2011 -0800 +++ b/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp Tue Dec 27 16:43:49 2011 -0800 @@ -51,7 +51,7 @@ size_t size = pointer_delta(end, start, sizeof(char)); if (clear_space) { // Prefer page reallocation to migration. - os::free_memory((char*)start, size); + os::free_memory((char*)start, size, page_size); } os::numa_make_global((char*)start, size); } diff -r d68bb6ceb0d7 -r 739e52129c84 hotspot/src/share/vm/runtime/os.hpp --- a/hotspot/src/share/vm/runtime/os.hpp Tue Dec 27 12:38:49 2011 -0800 +++ b/hotspot/src/share/vm/runtime/os.hpp Tue Dec 27 16:43:49 2011 -0800 @@ -256,7 +256,7 @@ char *addr, size_t bytes, bool read_only, bool allow_exec); static bool unmap_memory(char *addr, size_t bytes); - static void free_memory(char *addr, size_t bytes); + static void free_memory(char *addr, size_t bytes, size_t alignment_hint); static void realign_memory(char *addr, size_t bytes, size_t alignment_hint); // NUMA-specific interface