Thu, 07 Feb 2019 14:29:17 -0500
8218558: NMT stack traces in output should show mt component for virtual memory allocations
Reviewed-by: shade, stuefe, coleenp
1.1 --- a/src/share/vm/services/allocationSite.hpp Tue Oct 08 15:38:35 2019 +0200 1.2 +++ b/src/share/vm/services/allocationSite.hpp Thu Feb 07 14:29:17 2019 -0500 1.3 @@ -34,8 +34,9 @@ 1.4 private: 1.5 NativeCallStack _call_stack; 1.6 E e; 1.7 + MEMFLAGS _flag; 1.8 public: 1.9 - AllocationSite(const NativeCallStack& stack) : _call_stack(stack) { } 1.10 + AllocationSite(const NativeCallStack& stack, MEMFLAGS flag) : _call_stack(stack), _flag(flag) { } 1.11 int hash() const { return _call_stack.hash(); } 1.12 bool equals(const NativeCallStack& stack) const { 1.13 return _call_stack.equals(stack); 1.14 @@ -52,6 +53,8 @@ 1.15 // Information regarding this allocation 1.16 E* data() { return &e; } 1.17 const E* peek() const { return &e; } 1.18 + 1.19 + MEMFLAGS flag() const { return _flag; } 1.20 }; 1.21 1.22 #endif // SHARE_VM_SERVICES_ALLOCATION_SITE_HPP
2.1 --- a/src/share/vm/services/mallocSiteTable.cpp Tue Oct 08 15:38:35 2019 +0200 2.2 +++ b/src/share/vm/services/mallocSiteTable.cpp Thu Feb 07 14:29:17 2019 -0500 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -158,7 +158,7 @@ 2.11 MallocSiteHashtableEntry* head = _table[index]; 2.12 while (head != NULL && (*pos_idx) <= MAX_BUCKET_LENGTH) { 2.13 MallocSite* site = head->data(); 2.14 - if (site->flags() == flags && site->equals(key)) { 2.15 + if (site->flag() == flags && site->equals(key)) { 2.16 return head->data(); 2.17 } 2.18
3.1 --- a/src/share/vm/services/mallocSiteTable.hpp Tue Oct 08 15:38:35 2019 +0200 3.2 +++ b/src/share/vm/services/mallocSiteTable.hpp Thu Feb 07 14:29:17 2019 -0500 3.3 @@ -37,15 +37,12 @@ 3.4 // MallocSite represents a code path that eventually calls 3.5 // os::malloc() to allocate memory 3.6 class MallocSite : public AllocationSite<MemoryCounter> { 3.7 - private: 3.8 - MEMFLAGS _flags; 3.9 - 3.10 public: 3.11 MallocSite() : 3.12 - AllocationSite<MemoryCounter>(NativeCallStack::empty_stack()), _flags(mtNone) {} 3.13 + AllocationSite<MemoryCounter>(NativeCallStack::empty_stack(), mtNone) {} 3.14 3.15 MallocSite(const NativeCallStack& stack, MEMFLAGS flags) : 3.16 - AllocationSite<MemoryCounter>(stack), _flags(flags) {} 3.17 + AllocationSite<MemoryCounter>(stack, flags) {} 3.18 3.19 3.20 void allocate(size_t size) { data()->allocate(size); } 3.21 @@ -55,7 +52,6 @@ 3.22 size_t size() const { return peek()->size(); } 3.23 // The number of calls were made 3.24 size_t count() const { return peek()->count(); } 3.25 - MEMFLAGS flags() const { return (MEMFLAGS)_flags; } 3.26 }; 3.27 3.28 // Malloc site hashtable entry
4.1 --- a/src/share/vm/services/memBaseline.cpp Tue Oct 08 15:38:35 2019 +0200 4.2 +++ b/src/share/vm/services/memBaseline.cpp Thu Feb 07 14:29:17 2019 -0500 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -63,7 +63,7 @@ 4.11 int compare_malloc_site_and_type(const MallocSite& s1, const MallocSite& s2) { 4.12 int res = compare_malloc_site(s1, s2); 4.13 if (res == 0) { 4.14 - res = (int)(s1.flags() - s2.flags()); 4.15 + res = (int)(s1.flag() - s2.flag()); 4.16 } 4.17 4.18 return res; 4.19 @@ -209,7 +209,7 @@ 4.20 const ReservedMemoryRegion* rgn; 4.21 VirtualMemoryAllocationSite* site; 4.22 while ((rgn = itr.next()) != NULL) { 4.23 - VirtualMemoryAllocationSite tmp(*rgn->call_stack()); 4.24 + VirtualMemoryAllocationSite tmp(*rgn->call_stack(), rgn->flag()); 4.25 site = allocation_sites.find(tmp); 4.26 if (site == NULL) { 4.27 LinkedListNode<VirtualMemoryAllocationSite>* node =
5.1 --- a/src/share/vm/services/memReporter.cpp Tue Oct 08 15:38:35 2019 +0200 5.2 +++ b/src/share/vm/services/memReporter.cpp Thu Feb 07 14:29:17 2019 -0500 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -205,7 +205,7 @@ 5.11 const NativeCallStack* stack = malloc_site->call_stack(); 5.12 stack->print_on(out); 5.13 out->print("%29s", " "); 5.14 - MEMFLAGS flag = malloc_site->flags(); 5.15 + MEMFLAGS flag = malloc_site->flag(); 5.16 assert((flag >= 0 && flag < (int)mt_number_of_types) && flag != mtNone, 5.17 "Must have a valid memory type"); 5.18 print_malloc(malloc_site->size(), malloc_site->count(),flag); 5.19 @@ -231,6 +231,10 @@ 5.20 stack->print_on(out); 5.21 out->print("%28s (", " "); 5.22 print_total(virtual_memory_site->reserved(), virtual_memory_site->committed()); 5.23 + MEMFLAGS flag = virtual_memory_site->flag(); 5.24 + if (flag != mtNone) { 5.25 + out->print(" Type=%s", NMTUtil::flag_to_name(flag)); 5.26 + } 5.27 out->print_cr(")\n"); 5.28 } 5.29 } 5.30 @@ -562,24 +566,24 @@ 5.31 5.32 void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const { 5.33 diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(), 5.34 - 0, 0, malloc_site->flags()); 5.35 + 0, 0, malloc_site->flag()); 5.36 } 5.37 5.38 void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const { 5.39 diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(), 5.40 - malloc_site->count(), malloc_site->flags()); 5.41 + malloc_site->count(), malloc_site->flag()); 5.42 } 5.43 5.44 void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, 5.45 const MallocSite* current) const { 5.46 - if (early->flags() != current->flags()) { 5.47 + if (early->flag() != current->flag()) { 5.48 // If malloc site type changed, treat it as deallocation of old type and 5.49 // allocation of new type. 5.50 old_malloc_site(early); 5.51 new_malloc_site(current); 5.52 } else { 5.53 diff_malloc_site(current->call_stack(), current->size(), current->count(), 5.54 - early->size(), early->count(), early->flags()); 5.55 + early->size(), early->count(), early->flag()); 5.56 } 5.57 } 5.58 5.59 @@ -603,21 +607,22 @@ 5.60 5.61 5.62 void MemDetailDiffReporter::new_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { 5.63 - diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0); 5.64 + diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0, site->flag()); 5.65 } 5.66 5.67 void MemDetailDiffReporter::old_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { 5.68 - diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed()); 5.69 + diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed(), site->flag()); 5.70 } 5.71 5.72 void MemDetailDiffReporter::diff_virtual_memory_site(const VirtualMemoryAllocationSite* early, 5.73 const VirtualMemoryAllocationSite* current) const { 5.74 + assert(early->flag() == current->flag(), "Should be the same"); 5.75 diff_virtual_memory_site(current->call_stack(), current->reserved(), current->committed(), 5.76 - early->reserved(), early->committed()); 5.77 + early->reserved(), early->committed(), current->flag()); 5.78 } 5.79 5.80 void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, 5.81 - size_t current_committed, size_t early_reserved, size_t early_committed) const { 5.82 + size_t current_committed, size_t early_reserved, size_t early_committed, MEMFLAGS flag) const { 5.83 outputStream* out = output(); 5.84 5.85 // no change 5.86 @@ -631,6 +636,10 @@ 5.87 print_virtual_memory_diff(current_reserved, current_committed, 5.88 early_reserved, early_committed); 5.89 5.90 + if (flag != mtNone) { 5.91 + out->print(" Type=%s", NMTUtil::flag_to_name(flag)); 5.92 + } 5.93 + 5.94 out->print_cr(")\n"); 5.95 } 5.96
6.1 --- a/src/share/vm/services/memReporter.hpp Tue Oct 08 15:38:35 2019 +0200 6.2 +++ b/src/share/vm/services/memReporter.hpp Thu Feb 07 14:29:17 2019 -0500 6.3 @@ -218,7 +218,7 @@ 6.4 void diff_malloc_site(const NativeCallStack* stack, size_t current_size, 6.5 size_t currrent_count, size_t early_size, size_t early_count, MEMFLAGS flags) const; 6.6 void diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, 6.7 - size_t current_committed, size_t early_reserved, size_t early_committed) const; 6.8 + size_t current_committed, size_t early_reserved, size_t early_committed, MEMFLAGS flag) const; 6.9 }; 6.10 6.11 #endif // INCLUDE_NMT
7.1 --- a/src/share/vm/services/virtualMemoryTracker.hpp Tue Oct 08 15:38:35 2019 +0200 7.2 +++ b/src/share/vm/services/virtualMemoryTracker.hpp Thu Feb 07 14:29:17 2019 -0500 7.3 @@ -69,8 +69,8 @@ 7.4 // Virtual memory allocation site, keeps track where the virtual memory is reserved. 7.5 class VirtualMemoryAllocationSite : public AllocationSite<VirtualMemory> { 7.6 public: 7.7 - VirtualMemoryAllocationSite(const NativeCallStack& stack) : 7.8 - AllocationSite<VirtualMemory>(stack) { } 7.9 + VirtualMemoryAllocationSite(const NativeCallStack& stack, MEMFLAGS flag) : 7.10 + AllocationSite<VirtualMemory>(stack, flag) { } 7.11 7.12 inline void reserve_memory(size_t sz) { data()->reserve_memory(sz); } 7.13 inline void commit_memory (size_t sz) { data()->commit_memory(sz); }