changeset 2928:20bfb6d15a94

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 <aleksey.v.ignatenko@intel.com>
author iveresov
date Tue, 27 Dec 2011 16:43:49 -0800
parents 7faca6dfa2ed
children 776173fc2df9
files src/os/bsd/vm/os_bsd.cpp src/os/linux/vm/os_linux.cpp src/os/solaris/vm/os_solaris.cpp src/os/windows/vm/os_windows.cpp src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp src/share/vm/gc_implementation/shared/mutableSpace.cpp src/share/vm/runtime/os.hpp
diffstat 7 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/bsd/vm/os_bsd.cpp	Tue Dec 27 12:38:49 2011 -0800
+++ b/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);
 }
 
--- a/src/os/linux/vm/os_linux.cpp	Tue Dec 27 12:38:49 2011 -0800
+++ b/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) {
--- a/src/os/solaris/vm/os_solaris.cpp	Tue Dec 27 12:38:49 2011 -0800
+++ b/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;
--- a/src/os/windows/vm/os_windows.cpp	Tue Dec 27 12:38:49 2011 -0800
+++ b/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; }
--- a/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp	Tue Dec 27 12:38:49 2011 -0800
+++ b/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;
     }
--- a/src/share/vm/gc_implementation/shared/mutableSpace.cpp	Tue Dec 27 12:38:49 2011 -0800
+++ b/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);
     }
--- a/src/share/vm/runtime/os.hpp	Tue Dec 27 12:38:49 2011 -0800
+++ b/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