mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
6995781: Native Memory Tracking (Phase 1)
7151532: DCmd for hotspot native memory tracking Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd Reviewed-by: acorn, coleenp, fparain
This commit is contained in:
parent
8e42425c92
commit
a39b17624a
315 changed files with 7245 additions and 1477 deletions
|
@ -371,7 +371,7 @@ void os::init_system_properties_values() {
|
|||
// code needs to be changed accordingly.
|
||||
|
||||
// The next few definitions allow the code to be verbatim:
|
||||
#define malloc(n) (char*)NEW_C_HEAP_ARRAY(char, (n))
|
||||
#define malloc(n) (char*)NEW_C_HEAP_ARRAY(char, (n), mtInternal)
|
||||
#define getenv(n) ::getenv(n)
|
||||
|
||||
/*
|
||||
|
@ -639,7 +639,7 @@ void os::Linux::libpthread_init() {
|
|||
|
||||
size_t n = confstr(_CS_GNU_LIBC_VERSION, NULL, 0);
|
||||
if (n > 0) {
|
||||
char *str = (char *)malloc(n);
|
||||
char *str = (char *)malloc(n, mtInternal);
|
||||
confstr(_CS_GNU_LIBC_VERSION, str, n);
|
||||
os::Linux::set_glibc_version(str);
|
||||
} else {
|
||||
|
@ -652,7 +652,7 @@ void os::Linux::libpthread_init() {
|
|||
|
||||
n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
|
||||
if (n > 0) {
|
||||
char *str = (char *)malloc(n);
|
||||
char *str = (char *)malloc(n, mtInternal);
|
||||
confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
|
||||
// Vanilla RH-9 (glibc 2.3.2) has a bug that confstr() always tells
|
||||
// us "NPTL-0.29" even we are running with LinuxThreads. Check if this
|
||||
|
@ -1685,11 +1685,11 @@ void os::dll_build_name(char* buffer, size_t buflen,
|
|||
// release the storage
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
if (pelements[i] != NULL) {
|
||||
FREE_C_HEAP_ARRAY(char, pelements[i]);
|
||||
FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal);
|
||||
}
|
||||
}
|
||||
if (pelements != NULL) {
|
||||
FREE_C_HEAP_ARRAY(char*, pelements);
|
||||
FREE_C_HEAP_ARRAY(char*, pelements, mtInternal);
|
||||
}
|
||||
} else {
|
||||
snprintf(buffer, buflen, "%s/lib%s.so", pname, fname);
|
||||
|
@ -2469,7 +2469,7 @@ void linux_wrap_code(char* base, size_t size) {
|
|||
// All it does is to check if there are enough free pages
|
||||
// left at the time of mmap(). This could be a potential
|
||||
// problem.
|
||||
bool os::commit_memory(char* addr, size_t size, bool exec) {
|
||||
bool os::pd_commit_memory(char* addr, size_t size, bool exec) {
|
||||
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
|
||||
uintptr_t res = (uintptr_t) ::mmap(addr, size, prot,
|
||||
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
|
||||
|
@ -2492,7 +2492,7 @@ bool os::commit_memory(char* addr, size_t size, bool exec) {
|
|||
#define MADV_HUGEPAGE 14
|
||||
#endif
|
||||
|
||||
bool os::commit_memory(char* addr, size_t size, size_t alignment_hint,
|
||||
bool os::pd_commit_memory(char* addr, size_t size, size_t alignment_hint,
|
||||
bool exec) {
|
||||
if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) {
|
||||
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
|
||||
|
@ -2516,7 +2516,7 @@ bool os::commit_memory(char* addr, size_t size, size_t alignment_hint,
|
|||
return false;
|
||||
}
|
||||
|
||||
void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
|
||||
void os::pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
|
||||
if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) {
|
||||
// We don't check the return value: madvise(MADV_HUGEPAGE) may not
|
||||
// be supported or the memory may already be backed by huge pages.
|
||||
|
@ -2524,7 +2524,7 @@ void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
|
|||
}
|
||||
}
|
||||
|
||||
void os::free_memory(char *addr, size_t bytes, size_t alignment_hint) {
|
||||
void os::pd_free_memory(char *addr, size_t bytes, size_t alignment_hint) {
|
||||
// This method works by doing an mmap over an existing mmaping and effectively discarding
|
||||
// the existing pages. However it won't work for SHM-based large pages that cannot be
|
||||
// uncommitted at all. We don't do anything in this case to avoid creating a segment with
|
||||
|
@ -2646,7 +2646,7 @@ bool os::Linux::libnuma_init() {
|
|||
if (numa_available() != -1) {
|
||||
set_numa_all_nodes((unsigned long*)libnuma_dlsym(handle, "numa_all_nodes"));
|
||||
// Create a cpu -> node mapping
|
||||
_cpu_to_node = new (ResourceObj::C_HEAP) GrowableArray<int>(0, true);
|
||||
_cpu_to_node = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<int>(0, true);
|
||||
rebuild_cpu_to_node_map();
|
||||
return true;
|
||||
}
|
||||
|
@ -2676,7 +2676,7 @@ void os::Linux::rebuild_cpu_to_node_map() {
|
|||
cpu_to_node()->at_grow(cpu_num - 1);
|
||||
size_t node_num = numa_get_groups_num();
|
||||
|
||||
unsigned long *cpu_map = NEW_C_HEAP_ARRAY(unsigned long, cpu_map_size);
|
||||
unsigned long *cpu_map = NEW_C_HEAP_ARRAY(unsigned long, cpu_map_size, mtInternal);
|
||||
for (size_t i = 0; i < node_num; i++) {
|
||||
if (numa_node_to_cpus(i, cpu_map, cpu_map_size * sizeof(unsigned long)) != -1) {
|
||||
for (size_t j = 0; j < cpu_map_valid_size; j++) {
|
||||
|
@ -2690,7 +2690,7 @@ void os::Linux::rebuild_cpu_to_node_map() {
|
|||
}
|
||||
}
|
||||
}
|
||||
FREE_C_HEAP_ARRAY(unsigned long, cpu_map);
|
||||
FREE_C_HEAP_ARRAY(unsigned long, cpu_map, mtInternal);
|
||||
}
|
||||
|
||||
int os::Linux::get_node_by_cpu(int cpu_id) {
|
||||
|
@ -2709,7 +2709,7 @@ os::Linux::numa_tonode_memory_func_t os::Linux::_numa_tonode_memory;
|
|||
os::Linux::numa_interleave_memory_func_t os::Linux::_numa_interleave_memory;
|
||||
unsigned long* os::Linux::_numa_all_nodes;
|
||||
|
||||
bool os::uncommit_memory(char* addr, size_t size) {
|
||||
bool os::pd_uncommit_memory(char* addr, size_t size) {
|
||||
uintptr_t res = (uintptr_t) ::mmap(addr, size, PROT_NONE,
|
||||
MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE|MAP_ANONYMOUS, -1, 0);
|
||||
return res != (uintptr_t) MAP_FAILED;
|
||||
|
@ -2774,7 +2774,7 @@ bool get_stack_bounds(uintptr_t *bottom, uintptr_t *top) {
|
|||
// munmap() the guard pages we don't leave a hole in the stack
|
||||
// mapping. This only affects the main/initial thread, but guard
|
||||
// against future OS changes
|
||||
bool os::create_stack_guard_pages(char* addr, size_t size) {
|
||||
bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
|
||||
uintptr_t stack_extent, stack_base;
|
||||
bool chk_bounds = NOT_DEBUG(os::Linux::is_initial_thread()) DEBUG_ONLY(true);
|
||||
if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) {
|
||||
|
@ -2847,12 +2847,12 @@ static int anon_munmap(char * addr, size_t size) {
|
|||
return ::munmap(addr, size) == 0;
|
||||
}
|
||||
|
||||
char* os::reserve_memory(size_t bytes, char* requested_addr,
|
||||
char* os::pd_reserve_memory(size_t bytes, char* requested_addr,
|
||||
size_t alignment_hint) {
|
||||
return anon_mmap(requested_addr, bytes, (requested_addr != NULL));
|
||||
}
|
||||
|
||||
bool os::release_memory(char* addr, size_t size) {
|
||||
bool os::pd_release_memory(char* addr, size_t size) {
|
||||
return anon_munmap(addr, size);
|
||||
}
|
||||
|
||||
|
@ -3149,7 +3149,7 @@ bool os::can_execute_large_page_memory() {
|
|||
// Reserve memory at an arbitrary address, only if that area is
|
||||
// available (and not reserved for something else).
|
||||
|
||||
char* os::attempt_reserve_memory_at(size_t bytes, char* requested_addr) {
|
||||
char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr) {
|
||||
const int max_tries = 10;
|
||||
char* base[max_tries];
|
||||
size_t size[max_tries];
|
||||
|
@ -4671,7 +4671,7 @@ int os::socket_available(int fd, jint *pbytes) {
|
|||
}
|
||||
|
||||
// Map a block of memory.
|
||||
char* os::map_memory(int fd, const char* file_name, size_t file_offset,
|
||||
char* os::pd_map_memory(int fd, const char* file_name, size_t file_offset,
|
||||
char *addr, size_t bytes, bool read_only,
|
||||
bool allow_exec) {
|
||||
int prot;
|
||||
|
@ -4701,7 +4701,7 @@ char* os::map_memory(int fd, const char* file_name, size_t file_offset,
|
|||
|
||||
|
||||
// Remap a block of memory.
|
||||
char* os::remap_memory(int fd, const char* file_name, size_t file_offset,
|
||||
char* os::pd_remap_memory(int fd, const char* file_name, size_t file_offset,
|
||||
char *addr, size_t bytes, bool read_only,
|
||||
bool allow_exec) {
|
||||
// same as map_memory() on this OS
|
||||
|
@ -4711,7 +4711,7 @@ char* os::remap_memory(int fd, const char* file_name, size_t file_offset,
|
|||
|
||||
|
||||
// Unmap a block of memory.
|
||||
bool os::unmap_memory(char* addr, size_t bytes) {
|
||||
bool os::pd_unmap_memory(char* addr, size_t bytes) {
|
||||
return munmap(addr, bytes) == 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue