changeset 55422:84295bd6d359

8220590: ZGC: Remove ZPages from ZPageTable when freed Reviewed-by: stefank, eosterlund
author pliden
date Mon, 18 Mar 2019 11:50:39 +0100
parents c585ef187216
children b9f030844be4
files src/hotspot/share/gc/z/zHeap.cpp src/hotspot/share/gc/z/zPageTable.cpp
diffstat 2 files changed, 10 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/z/zHeap.cpp	Mon Mar 18 11:50:39 2019 +0100
+++ b/src/hotspot/share/gc/z/zHeap.cpp	Mon Mar 18 11:50:39 2019 +0100
@@ -221,7 +221,7 @@
 ZPage* ZHeap::alloc_page(uint8_t type, size_t size, ZAllocationFlags flags) {
   ZPage* const page = _page_allocator.alloc_page(type, size, flags);
   if (page != NULL) {
-    // Update page table
+    // Insert page table entry
     _page_table.insert(page);
   }
 
@@ -239,6 +239,10 @@
 }
 
 void ZHeap::free_page(ZPage* page, bool reclaimed) {
+  // Remove page table entry
+  _page_table.remove(page);
+
+  // Free page
   _page_allocator.free_page(page, reclaimed);
 }
 
@@ -406,9 +410,6 @@
   _page_allocator.flush_detached_pages(&list);
 
   for (ZPage* page = list.remove_first(); page != NULL; page = list.remove_first()) {
-    // Remove page table entry
-    _page_table.remove(page);
-
     // Delete the page
     _page_allocator.destroy_page(page);
   }
--- a/src/hotspot/share/gc/z/zPageTable.cpp	Mon Mar 18 11:50:39 2019 +0100
+++ b/src/hotspot/share/gc/z/zPageTable.cpp	Mon Mar 18 11:50:39 2019 +0100
@@ -36,16 +36,12 @@
   const uintptr_t addr = ZAddress::good(page->start());
   const size_t size = page->size();
 
-  // Cached pages stays in the page table.
-  // Don't re-insert if it's already present.
-  if (get(addr) == NULL) {
-    // Make sure a newly created page is
-    // visible before updating the page table.
-    OrderAccess::storestore();
-    _map.put(addr, size, page);
-  }
+  // Make sure a newly created page is
+  // visible before updating the page table.
+  OrderAccess::storestore();
 
-  assert(get(addr) == page, "Invalid entry");
+  assert(get(addr) == NULL, "Invalid entry");
+  _map.put(addr, size, page);
 }
 
 void ZPageTable::remove(ZPage* page) {