Mercurial > hg > graal-jvmci-8
comparison src/share/vm/services/memBaseline.cpp @ 10148:fbca7eaeac2e
8011218: Kitchensink hanged, likely NMT is to blame
Summary: Made NMT query safepoint aware.
Reviewed-by: dholmes, coleenp
author | zgu |
---|---|
date | Wed, 24 Apr 2013 14:55:04 -0400 |
parents | 4102b59539ce |
children | ed5a590835a4 |
comparison
equal
deleted
inserted
replaced
10147:cc70cbbd422e | 10148:fbca7eaeac2e |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
21 * questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 #include "precompiled.hpp" | 24 #include "precompiled.hpp" |
25 #include "memory/allocation.hpp" | 25 #include "memory/allocation.hpp" |
26 #include "runtime/safepoint.hpp" | |
27 #include "runtime/thread.inline.hpp" | |
26 #include "services/memBaseline.hpp" | 28 #include "services/memBaseline.hpp" |
27 #include "services/memTracker.hpp" | 29 #include "services/memTracker.hpp" |
30 | |
28 | 31 |
29 MemType2Name MemBaseline::MemType2NameMap[NUMBER_OF_MEMORY_TYPE] = { | 32 MemType2Name MemBaseline::MemType2NameMap[NUMBER_OF_MEMORY_TYPE] = { |
30 {mtJavaHeap, "Java Heap"}, | 33 {mtJavaHeap, "Java Heap"}, |
31 {mtClass, "Class"}, | 34 {mtClass, "Class"}, |
32 {mtThreadStack,"Thread Stack"}, | 35 {mtThreadStack,"Thread Stack"}, |
147 _malloc_data[index].overwrite_counter(0); | 150 _malloc_data[index].overwrite_counter(0); |
148 | 151 |
149 return true; | 152 return true; |
150 } | 153 } |
151 | 154 |
155 // check if there is a safepoint in progress, if so, block the thread | |
156 // for the safepoint | |
157 void MemBaseline::check_safepoint(JavaThread* thr) { | |
158 if (SafepointSynchronize::is_synchronizing()) { | |
159 SafepointSynchronize::block(thr); | |
160 } | |
161 } | |
162 | |
152 // baseline mmap'd memory records, generate overall summary and summaries by | 163 // baseline mmap'd memory records, generate overall summary and summaries by |
153 // memory types | 164 // memory types |
154 bool MemBaseline::baseline_vm_summary(const MemPointerArray* vm_records) { | 165 bool MemBaseline::baseline_vm_summary(const MemPointerArray* vm_records) { |
155 MemPointerArrayIteratorImpl vm_itr((MemPointerArray*)vm_records); | 166 MemPointerArrayIteratorImpl vm_itr((MemPointerArray*)vm_records); |
156 VMMemRegion* vm_ptr = (VMMemRegion*)vm_itr.current(); | 167 VMMemRegion* vm_ptr = (VMMemRegion*)vm_itr.current(); |
304 if (committed_rec == NULL || | 315 if (committed_rec == NULL || |
305 committed_rec->base() + committed_rec->size() != vm_ptr->addr() || | 316 committed_rec->base() + committed_rec->size() != vm_ptr->addr() || |
306 committed_rec->pc() != vm_ptr->pc()) { | 317 committed_rec->pc() != vm_ptr->pc()) { |
307 if (!_vm_map->append(vm_ptr)) { | 318 if (!_vm_map->append(vm_ptr)) { |
308 return false; | 319 return false; |
309 } | 320 } |
310 committed_rec = (VMMemRegionEx*)_vm_map->at(_vm_map->length() - 1); | 321 committed_rec = (VMMemRegionEx*)_vm_map->at(_vm_map->length() - 1); |
311 } else { | 322 } else { |
312 committed_rec->expand_region(vm_ptr->addr(), vm_ptr->size()); | 323 committed_rec->expand_region(vm_ptr->addr(), vm_ptr->size()); |
313 } | 324 } |
314 vm_callsite.inc(0, vm_ptr->size()); | 325 vm_callsite.inc(0, vm_ptr->size()); |
342 return true; | 353 return true; |
343 } | 354 } |
344 | 355 |
345 // baseline a snapshot. If summary_only = false, memory usages aggregated by | 356 // baseline a snapshot. If summary_only = false, memory usages aggregated by |
346 // callsites are also baselined. | 357 // callsites are also baselined. |
358 // The method call can be lengthy, especially when detail tracking info is | |
359 // requested. So the method checks for safepoint explicitly. | |
347 bool MemBaseline::baseline(MemSnapshot& snapshot, bool summary_only) { | 360 bool MemBaseline::baseline(MemSnapshot& snapshot, bool summary_only) { |
348 MutexLockerEx snapshot_locker(snapshot._lock, true); | 361 Thread* THREAD = Thread::current(); |
362 assert(THREAD->is_Java_thread(), "must be a JavaThread"); | |
363 MutexLocker snapshot_locker(snapshot._lock); | |
349 reset(); | 364 reset(); |
350 _baselined = baseline_malloc_summary(snapshot._alloc_ptrs) && | 365 _baselined = baseline_malloc_summary(snapshot._alloc_ptrs); |
351 baseline_vm_summary(snapshot._vm_ptrs); | 366 if (_baselined) { |
367 check_safepoint((JavaThread*)THREAD); | |
368 _baselined = baseline_vm_summary(snapshot._vm_ptrs); | |
369 } | |
352 _number_of_classes = snapshot.number_of_classes(); | 370 _number_of_classes = snapshot.number_of_classes(); |
353 | 371 |
354 if (!summary_only && MemTracker::track_callsite() && _baselined) { | 372 if (!summary_only && MemTracker::track_callsite() && _baselined) { |
355 _baselined = baseline_malloc_details(snapshot._alloc_ptrs) && | 373 check_safepoint((JavaThread*)THREAD); |
356 baseline_vm_details(snapshot._vm_ptrs); | 374 _baselined = baseline_malloc_details(snapshot._alloc_ptrs); |
375 if (_baselined) { | |
376 check_safepoint((JavaThread*)THREAD); | |
377 _baselined = baseline_vm_details(snapshot._vm_ptrs); | |
378 } | |
357 } | 379 } |
358 return _baselined; | 380 return _baselined; |
359 } | 381 } |
360 | 382 |
361 | 383 |