From e7cfe60a32a8ee3e1f02aefe8ccb462473047f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Lid=C3=A9n?= Date: Mon, 18 Mar 2019 11:50:39 +0100 Subject: [PATCH] 8220590: ZGC: Remove ZPages from ZPageTable when freed Reviewed-by: stefank, eosterlund --- src/hotspot/share/gc/z/zHeap.cpp | 9 +++++---- src/hotspot/share/gc/z/zPageTable.cpp | 14 +++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/hotspot/share/gc/z/zHeap.cpp b/src/hotspot/share/gc/z/zHeap.cpp index a95fc5bd5c2..658f2a40598 100644 --- a/src/hotspot/share/gc/z/zHeap.cpp +++ b/src/hotspot/share/gc/z/zHeap.cpp @@ -221,7 +221,7 @@ void ZHeap::out_of_memory() { 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::undo_alloc_page(ZPage* page) { } 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 @@ void ZHeap::destroy_detached_pages() { _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); } diff --git a/src/hotspot/share/gc/z/zPageTable.cpp b/src/hotspot/share/gc/z/zPageTable.cpp index 9608ef4eba0..025ae6abd63 100644 --- a/src/hotspot/share/gc/z/zPageTable.cpp +++ b/src/hotspot/share/gc/z/zPageTable.cpp @@ -36,16 +36,12 @@ void ZPageTable::insert(ZPage* page) { 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) {