From 897d22889965aa8db9705fddc1a98ed811971b94 Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Mon, 5 Feb 2018 13:23:26 -0500 Subject: [PATCH] 8194934: NMT: Remove MemTracker::get_virtual_memory_xxx_tracker(), create Tracker in place Create tracker in place to avoid additional locking Reviewed-by: coleenp --- src/hotspot/os/bsd/os_bsd.cpp | 2 +- src/hotspot/os/linux/os_linux.cpp | 2 +- src/hotspot/os/windows/perfMemory_windows.cpp | 4 ++-- src/hotspot/share/runtime/os.cpp | 6 +++--- src/hotspot/share/services/memTracker.hpp | 14 +------------- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index 76292e1975e..e87e2acef78 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -2206,7 +2206,7 @@ char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool os::release_memory_special(char* base, size_t bytes) { if (MemTracker::tracking_level() > NMT_minimal) { - Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); + Tracker tkr(Tracker::release); // detaching the SHM segment will also delete it, see reserve_memory_special() int rslt = shmdt(base); if (rslt == 0) { diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 45c9ea4c639..4544baa8f76 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -3862,7 +3862,7 @@ bool os::Linux::release_memory_special_huge_tlbfs(char* base, size_t bytes) { bool os::release_memory_special(char* base, size_t bytes) { bool res; if (MemTracker::tracking_level() > NMT_minimal) { - Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); + Tracker tkr(Tracker::release); res = os::Linux::release_memory_special_impl(base, bytes); if (res) { tkr.record((address)base, bytes); diff --git a/src/hotspot/os/windows/perfMemory_windows.cpp b/src/hotspot/os/windows/perfMemory_windows.cpp index 7eb311a690e..ef494992b7d 100644 --- a/src/hotspot/os/windows/perfMemory_windows.cpp +++ b/src/hotspot/os/windows/perfMemory_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1840,7 +1840,7 @@ void PerfMemory::detach(char* addr, size_t bytes, TRAPS) { if (MemTracker::tracking_level() > NMT_minimal) { // it does not go through os api, the operation has to record from here - Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); + Tracker tkr(Tracker::release); remove_file_mapping(addr); tkr.record((address)addr, bytes); } else { diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index ea5679bceff..b39a9601569 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -1749,7 +1749,7 @@ void os::commit_memory_or_exit(char* addr, size_t size, size_t alignment_hint, bool os::uncommit_memory(char* addr, size_t bytes) { bool res; if (MemTracker::tracking_level() > NMT_minimal) { - Tracker tkr = MemTracker::get_virtual_memory_uncommit_tracker(); + Tracker tkr(Tracker::uncommit); res = pd_uncommit_memory(addr, bytes); if (res) { tkr.record((address)addr, bytes); @@ -1763,7 +1763,7 @@ bool os::uncommit_memory(char* addr, size_t bytes) { bool os::release_memory(char* addr, size_t bytes) { bool res; if (MemTracker::tracking_level() > NMT_minimal) { - Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); + Tracker tkr(Tracker::release); res = pd_release_memory(addr, bytes); if (res) { tkr.record((address)addr, bytes); @@ -1800,7 +1800,7 @@ char* os::remap_memory(int fd, const char* file_name, size_t file_offset, bool os::unmap_memory(char *addr, size_t bytes) { bool result; if (MemTracker::tracking_level() > NMT_minimal) { - Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); + Tracker tkr(Tracker::release); result = pd_unmap_memory(addr, bytes); if (result) { tkr.record((address)addr, bytes); diff --git a/src/hotspot/share/services/memTracker.hpp b/src/hotspot/share/services/memTracker.hpp index a5d22cb6492..06d5a418b14 100644 --- a/src/hotspot/share/services/memTracker.hpp +++ b/src/hotspot/share/services/memTracker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,8 +63,6 @@ class MemTracker : AllStatic { static inline void record_virtual_memory_reserve_and_commit(void* addr, size_t size, const NativeCallStack& stack, MEMFLAGS flag = mtNone) { } static inline void record_virtual_memory_commit(void* addr, size_t size, const NativeCallStack& stack) { } - static inline Tracker get_virtual_memory_uncommit_tracker() { return Tracker(); } - static inline Tracker get_virtual_memory_release_tracker() { return Tracker(); } static inline void record_virtual_memory_type(void* addr, MEMFLAGS flag) { } static inline void record_thread_stack(void* addr, size_t size) { } static inline void release_thread_stack(void* addr, size_t size) { } @@ -227,16 +225,6 @@ class MemTracker : AllStatic { } } - static inline Tracker get_virtual_memory_uncommit_tracker() { - assert(tracking_level() >= NMT_summary, "Check by caller"); - return Tracker(Tracker::uncommit); - } - - static inline Tracker get_virtual_memory_release_tracker() { - assert(tracking_level() >= NMT_summary, "Check by caller"); - return Tracker(Tracker::release); - } - static inline void record_virtual_memory_type(void* addr, MEMFLAGS flag) { if (tracking_level() < NMT_summary) return; if (addr != NULL) {