8208499: NMT: Missing memory tag for Safepoint polling page
Added missing memory tag and cleanup memory type enum Reviewed-by: shade, coleenp
This commit is contained in:
parent
c277f9ed8e
commit
c9d506055c
@ -113,28 +113,29 @@ class AllocatedObj {
|
||||
*/
|
||||
enum MemoryType {
|
||||
// Memory type by sub systems. It occupies lower byte.
|
||||
mtJavaHeap = 0x00, // Java heap
|
||||
mtClass = 0x01, // memory class for Java classes
|
||||
mtThread = 0x02, // memory for thread objects
|
||||
mtThreadStack = 0x03,
|
||||
mtCode = 0x04, // memory for generated code
|
||||
mtGC = 0x05, // memory for GC
|
||||
mtCompiler = 0x06, // memory for compiler
|
||||
mtInternal = 0x07, // memory used by VM, but does not belong to
|
||||
mtJavaHeap, // Java heap
|
||||
mtClass, // memory class for Java classes
|
||||
mtThread, // memory for thread objects
|
||||
mtThreadStack,
|
||||
mtCode, // memory for generated code
|
||||
mtGC, // memory for GC
|
||||
mtCompiler, // memory for compiler
|
||||
mtInternal, // memory used by VM, but does not belong to
|
||||
// any of above categories, and not used for
|
||||
// native memory tracking
|
||||
mtOther = 0x08, // memory not used by VM
|
||||
mtSymbol = 0x09, // symbol
|
||||
mtNMT = 0x0A, // memory used by native memory tracking
|
||||
mtClassShared = 0x0B, // class data sharing
|
||||
mtChunk = 0x0C, // chunk that holds content of arenas
|
||||
mtTest = 0x0D, // Test type for verifying NMT
|
||||
mtTracing = 0x0E, // memory used for Tracing
|
||||
mtLogging = 0x0F, // memory for logging
|
||||
mtArguments = 0x10, // memory for argument processing
|
||||
mtModule = 0x11, // memory for module processing
|
||||
mtNone = 0x12, // undefined
|
||||
mt_number_of_types = 0x13 // number of memory types (mtDontTrack
|
||||
mtOther, // memory not used by VM
|
||||
mtSymbol, // symbol
|
||||
mtNMT, // memory used by native memory tracking
|
||||
mtClassShared, // class data sharing
|
||||
mtChunk, // chunk that holds content of arenas
|
||||
mtTest, // Test type for verifying NMT
|
||||
mtTracing, // memory used for Tracing
|
||||
mtLogging, // memory for logging
|
||||
mtArguments, // memory for argument processing
|
||||
mtModule, // memory for module processing
|
||||
mtSafepoint, // memory for safepoint support
|
||||
mtNone, // undefined
|
||||
mt_number_of_types // number of memory types (mtDontTrack
|
||||
// is not included as validate type)
|
||||
};
|
||||
|
||||
|
@ -51,7 +51,7 @@ void SafepointMechanism::default_initialize() {
|
||||
const size_t allocation_size = 2 * page_size;
|
||||
char* polling_page = os::reserve_memory(allocation_size, NULL, page_size);
|
||||
os::commit_memory_or_exit(polling_page, allocation_size, false, "Unable to commit Safepoint polling page");
|
||||
MemTracker::record_virtual_memory_type((address)polling_page, mtInternal);
|
||||
MemTracker::record_virtual_memory_type((address)polling_page, mtSafepoint);
|
||||
|
||||
char* bad_page = polling_page;
|
||||
char* good_page = polling_page + page_size;
|
||||
@ -76,6 +76,7 @@ void SafepointMechanism::default_initialize() {
|
||||
char* polling_page = os::reserve_memory(page_size, NULL, page_size);
|
||||
os::commit_memory_or_exit(polling_page, page_size, false, "Unable to commit Safepoint polling page");
|
||||
os::protect_memory(polling_page, page_size, os::MEM_PROT_READ);
|
||||
MemTracker::record_virtual_memory_type((address)polling_page, mtSafepoint);
|
||||
|
||||
log_info(os)("SafePoint Polling address: " INTPTR_FORMAT, p2i(polling_page));
|
||||
os::set_polling_page((address)(polling_page));
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "services/memReporter.hpp"
|
||||
#include "services/mallocTracker.inline.hpp"
|
||||
#include "services/memTracker.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
#include "utilities/defaultStream.hpp"
|
||||
#include "utilities/vmError.hpp"
|
||||
|
||||
@ -50,6 +51,10 @@ bool MemTracker::_is_nmt_env_valid = true;
|
||||
|
||||
|
||||
NMT_TrackingLevel MemTracker::init_tracking_level() {
|
||||
// Memory type is encoded into tracking header as a byte field,
|
||||
// make sure that we don't overflow it.
|
||||
STATIC_ASSERT(mt_number_of_types <= max_jubyte);
|
||||
|
||||
NMT_TrackingLevel level = NMT_off;
|
||||
char buf[64];
|
||||
jio_snprintf(buf, sizeof(buf), "NMT_LEVEL_%d", os::current_process_id());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2016, 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
|
||||
@ -44,6 +44,7 @@ const char* NMTUtil::_memory_type_names[] = {
|
||||
"Logging",
|
||||
"Arguments",
|
||||
"Module",
|
||||
"Safepoint",
|
||||
"Unknown"
|
||||
};
|
||||
|
||||
|
55
test/hotspot/jtreg/runtime/NMT/SafepointPollingPages.java
Normal file
55
test/hotspot/jtreg/runtime/NMT/SafepointPollingPages.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8208499
|
||||
* @summary NMT should report safepoint polling page(s)
|
||||
* @key nmt jcmd
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:NativeMemoryTracking=summary -XX:+ThreadLocalHandshakes SafepointPollingPages
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:NativeMemoryTracking=summary -XX:-ThreadLocalHandshakes SafepointPollingPages
|
||||
*/
|
||||
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.JDKToolFinder;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
public class SafepointPollingPages {
|
||||
public static void main(String args[]) throws Exception {
|
||||
OutputAnalyzer output;
|
||||
|
||||
// Grab my own PID
|
||||
String pid = Long.toString(ProcessTools.getProcessId());
|
||||
ProcessBuilder pb = new ProcessBuilder();
|
||||
|
||||
// Run 'jcmd <pid> VM.native_memory summary'
|
||||
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
|
||||
output = new OutputAnalyzer(pb.start());
|
||||
output.shouldContain("Safepoint (reserved=");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user