Mon, 12 Mar 2012 14:59:00 -0700
7147724: G1: hang in SurrogateLockerThread::manipulatePLL
Summary: Attempting to initiate a marking cycle when allocating a humongous object can, if a marking cycle is successfully initiated by another thread, result in the allocating thread spinning until the marking cycle is complete. Eliminate a deadlock between the main ConcurrentMarkThread, the SurrogateLocker thread, the VM thread, and a mutator thread waiting on the SecondaryFreeList_lock (while free regions are going to become available) by not manipulating the pending list lock during the prologue and epilogue of the cleanup pause.
Reviewed-by: brutisso, jcoomes, tonyp
tonyp@2975 | 1 | /* |
tonyp@2975 | 2 | * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
tonyp@2975 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
tonyp@2975 | 4 | * |
tonyp@2975 | 5 | * This code is free software; you can redistribute it and/or modify it |
tonyp@2975 | 6 | * under the terms of the GNU General Public License version 2 only, as |
tonyp@2975 | 7 | * published by the Free Software Foundation. |
tonyp@2975 | 8 | * |
tonyp@2975 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
tonyp@2975 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
tonyp@2975 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
tonyp@2975 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
tonyp@2975 | 13 | * accompanied this code). |
tonyp@2975 | 14 | * |
tonyp@2975 | 15 | * You should have received a copy of the GNU General Public License version |
tonyp@2975 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
tonyp@2975 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
tonyp@2975 | 18 | * |
tonyp@2975 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
tonyp@2975 | 20 | * or visit www.oracle.com if you need additional information or have any |
tonyp@2975 | 21 | * questions. |
tonyp@2975 | 22 | * |
tonyp@2975 | 23 | */ |
tonyp@2975 | 24 | |
tonyp@2975 | 25 | #include "precompiled.hpp" |
tonyp@2975 | 26 | #include "gc_implementation/g1/g1HRPrinter.hpp" |
tonyp@2975 | 27 | #include "gc_implementation/g1/heapRegion.hpp" |
tonyp@2975 | 28 | #include "utilities/ostream.hpp" |
tonyp@2975 | 29 | |
tonyp@2975 | 30 | const char* G1HRPrinter::action_name(ActionType action) { |
tonyp@2975 | 31 | switch(action) { |
tonyp@2975 | 32 | case Alloc: return "ALLOC"; |
tonyp@2975 | 33 | case AllocForce: return "ALLOC-FORCE"; |
tonyp@2975 | 34 | case Retire: return "RETIRE"; |
tonyp@2975 | 35 | case Reuse: return "REUSE"; |
tonyp@2975 | 36 | case CSet: return "CSET"; |
tonyp@2975 | 37 | case EvacFailure: return "EVAC-FAILURE"; |
tonyp@2975 | 38 | case Cleanup: return "CLEANUP"; |
tonyp@2975 | 39 | case PostCompaction: return "POST-COMPACTION"; |
tonyp@2975 | 40 | case Commit: return "COMMIT"; |
tonyp@2975 | 41 | case Uncommit: return "UNCOMMIT"; |
tonyp@2975 | 42 | default: ShouldNotReachHere(); |
tonyp@2975 | 43 | } |
tonyp@2975 | 44 | // trying to keep the Windows compiler happy |
tonyp@2975 | 45 | return NULL; |
tonyp@2975 | 46 | } |
tonyp@2975 | 47 | |
tonyp@2975 | 48 | const char* G1HRPrinter::region_type_name(RegionType type) { |
tonyp@2975 | 49 | switch (type) { |
tonyp@2975 | 50 | case Unset: return NULL; |
tonyp@2975 | 51 | case Eden: return "Eden"; |
tonyp@2975 | 52 | case Survivor: return "Survivor"; |
tonyp@2975 | 53 | case Old: return "Old"; |
tonyp@2975 | 54 | case SingleHumongous: return "SingleH"; |
tonyp@2975 | 55 | case StartsHumongous: return "StartsH"; |
tonyp@2975 | 56 | case ContinuesHumongous: return "ContinuesH"; |
tonyp@2975 | 57 | default: ShouldNotReachHere(); |
tonyp@2975 | 58 | } |
tonyp@2975 | 59 | // trying to keep the Windows compiler happy |
tonyp@2975 | 60 | return NULL; |
tonyp@2975 | 61 | } |
tonyp@2975 | 62 | |
tonyp@2975 | 63 | const char* G1HRPrinter::phase_name(PhaseType phase) { |
tonyp@2975 | 64 | switch (phase) { |
tonyp@2975 | 65 | case StartGC: return "StartGC"; |
tonyp@2975 | 66 | case EndGC: return "EndGC"; |
tonyp@2975 | 67 | case StartFullGC: return "StartFullGC"; |
tonyp@2975 | 68 | case EndFullGC: return "EndFullGC"; |
tonyp@2975 | 69 | default: ShouldNotReachHere(); |
tonyp@2975 | 70 | } |
tonyp@2975 | 71 | // trying to keep the Windows compiler happy |
tonyp@2975 | 72 | return NULL; |
tonyp@2975 | 73 | } |
tonyp@2975 | 74 | |
tonyp@2975 | 75 | #define G1HR_PREFIX " G1HR" |
tonyp@2975 | 76 | |
tonyp@2975 | 77 | void G1HRPrinter::print(ActionType action, RegionType type, |
tonyp@2975 | 78 | HeapRegion* hr, HeapWord* top) { |
tonyp@2975 | 79 | const char* action_str = action_name(action); |
tonyp@2975 | 80 | const char* type_str = region_type_name(type); |
tonyp@2975 | 81 | HeapWord* bottom = hr->bottom(); |
tonyp@2975 | 82 | |
tonyp@2975 | 83 | if (type_str != NULL) { |
tonyp@2975 | 84 | if (top != NULL) { |
tonyp@2975 | 85 | gclog_or_tty->print_cr(G1HR_PREFIX" %s(%s) "PTR_FORMAT" "PTR_FORMAT, |
tonyp@2975 | 86 | action_str, type_str, bottom, top); |
tonyp@2975 | 87 | } else { |
tonyp@2975 | 88 | gclog_or_tty->print_cr(G1HR_PREFIX" %s(%s) "PTR_FORMAT, |
tonyp@2975 | 89 | action_str, type_str, bottom); |
tonyp@2975 | 90 | } |
tonyp@2975 | 91 | } else { |
tonyp@2975 | 92 | if (top != NULL) { |
tonyp@2975 | 93 | gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT" "PTR_FORMAT, |
tonyp@2975 | 94 | action_str, bottom, top); |
tonyp@2975 | 95 | } else { |
tonyp@2975 | 96 | gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT, |
tonyp@2975 | 97 | action_str, bottom); |
tonyp@2975 | 98 | } |
tonyp@2975 | 99 | } |
tonyp@2975 | 100 | } |
tonyp@2975 | 101 | |
tonyp@2975 | 102 | void G1HRPrinter::print(ActionType action, HeapWord* bottom, HeapWord* end) { |
tonyp@2975 | 103 | const char* action_str = action_name(action); |
tonyp@2975 | 104 | |
tonyp@2975 | 105 | gclog_or_tty->print_cr(G1HR_PREFIX" %s ["PTR_FORMAT","PTR_FORMAT"]", |
tonyp@2975 | 106 | action_str, bottom, end); |
tonyp@2975 | 107 | } |
tonyp@2975 | 108 | |
tonyp@2975 | 109 | void G1HRPrinter::print(PhaseType phase, size_t phase_num) { |
tonyp@2975 | 110 | const char* phase_str = phase_name(phase); |
tonyp@2975 | 111 | gclog_or_tty->print_cr(G1HR_PREFIX" #%s "SIZE_FORMAT, phase_str, phase_num); |
tonyp@2975 | 112 | } |