8194934: NMT: Remove MemTracker::get_virtual_memory_xxx_tracker(), create Tracker in place

Create tracker in place to avoid additional locking

Reviewed-by: coleenp
This commit is contained in:
Zhengyu Gu 2018-02-05 13:23:26 -05:00
parent 9eb320a418
commit 897d228899
5 changed files with 8 additions and 20 deletions

View File

@ -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) { bool os::release_memory_special(char* base, size_t bytes) {
if (MemTracker::tracking_level() > NMT_minimal) { 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() // detaching the SHM segment will also delete it, see reserve_memory_special()
int rslt = shmdt(base); int rslt = shmdt(base);
if (rslt == 0) { if (rslt == 0) {

View File

@ -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 os::release_memory_special(char* base, size_t bytes) {
bool res; bool res;
if (MemTracker::tracking_level() > NMT_minimal) { 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); res = os::Linux::release_memory_special_impl(base, bytes);
if (res) { if (res) {
tkr.record((address)base, bytes); tkr.record((address)base, bytes);

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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) { if (MemTracker::tracking_level() > NMT_minimal) {
// it does not go through os api, the operation has to record from here // 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); remove_file_mapping(addr);
tkr.record((address)addr, bytes); tkr.record((address)addr, bytes);
} else { } else {

View File

@ -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 os::uncommit_memory(char* addr, size_t bytes) {
bool res; bool res;
if (MemTracker::tracking_level() > NMT_minimal) { if (MemTracker::tracking_level() > NMT_minimal) {
Tracker tkr = MemTracker::get_virtual_memory_uncommit_tracker(); Tracker tkr(Tracker::uncommit);
res = pd_uncommit_memory(addr, bytes); res = pd_uncommit_memory(addr, bytes);
if (res) { if (res) {
tkr.record((address)addr, bytes); 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 os::release_memory(char* addr, size_t bytes) {
bool res; bool res;
if (MemTracker::tracking_level() > NMT_minimal) { if (MemTracker::tracking_level() > NMT_minimal) {
Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); Tracker tkr(Tracker::release);
res = pd_release_memory(addr, bytes); res = pd_release_memory(addr, bytes);
if (res) { if (res) {
tkr.record((address)addr, bytes); 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 os::unmap_memory(char *addr, size_t bytes) {
bool result; bool result;
if (MemTracker::tracking_level() > NMT_minimal) { if (MemTracker::tracking_level() > NMT_minimal) {
Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); Tracker tkr(Tracker::release);
result = pd_unmap_memory(addr, bytes); result = pd_unmap_memory(addr, bytes);
if (result) { if (result) {
tkr.record((address)addr, bytes); tkr.record((address)addr, bytes);

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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, static inline void record_virtual_memory_reserve_and_commit(void* addr, size_t size,
const NativeCallStack& stack, MEMFLAGS flag = mtNone) { } const NativeCallStack& stack, MEMFLAGS flag = mtNone) { }
static inline void record_virtual_memory_commit(void* addr, size_t size, const NativeCallStack& stack) { } 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_virtual_memory_type(void* addr, MEMFLAGS flag) { }
static inline void record_thread_stack(void* addr, size_t size) { } static inline void record_thread_stack(void* addr, size_t size) { }
static inline void release_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) { static inline void record_virtual_memory_type(void* addr, MEMFLAGS flag) {
if (tracking_level() < NMT_summary) return; if (tracking_level() < NMT_summary) return;
if (addr != NULL) { if (addr != NULL) {