Fri, 29 Apr 2011 14:59:04 -0400
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
Summary: We should only undirty cards after we decide that they are not on a young region, not before. The fix also includes improvements to the verify_dirty_region() method which print out which cards were not found dirty.
Reviewed-by: johnc, brutisso
jmasa@2821 | 1 | /* |
jmasa@2821 | 2 | * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
jmasa@2821 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jmasa@2821 | 4 | * |
jmasa@2821 | 5 | * This code is free software; you can redistribute it and/or modify it |
jmasa@2821 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jmasa@2821 | 7 | * published by the Free Software Foundation. |
jmasa@2821 | 8 | * |
jmasa@2821 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jmasa@2821 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jmasa@2821 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jmasa@2821 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jmasa@2821 | 13 | * accompanied this code). |
jmasa@2821 | 14 | * |
jmasa@2821 | 15 | * You should have received a copy of the GNU General Public License version |
jmasa@2821 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jmasa@2821 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jmasa@2821 | 18 | * |
jmasa@2821 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
jmasa@2821 | 20 | * or visit www.oracle.com if you need additional information or have any |
jmasa@2821 | 21 | * questions. |
jmasa@2821 | 22 | * |
jmasa@2821 | 23 | */ |
jmasa@2821 | 24 | |
jmasa@2821 | 25 | #include "precompiled.hpp" |
jmasa@2821 | 26 | #include "gc_implementation/g1/g1MonitoringSupport.hpp" |
jmasa@2821 | 27 | #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
jmasa@2821 | 28 | #include "gc_implementation/g1/g1CollectorPolicy.hpp" |
jmasa@2821 | 29 | |
jmasa@2821 | 30 | G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h, |
jmasa@2821 | 31 | VirtualSpace* g1_storage_addr) : |
jmasa@2821 | 32 | _g1h(g1h), |
jmasa@2821 | 33 | _incremental_collection_counters(NULL), |
jmasa@2821 | 34 | _full_collection_counters(NULL), |
jmasa@2821 | 35 | _non_young_collection_counters(NULL), |
jmasa@2821 | 36 | _old_space_counters(NULL), |
jmasa@2821 | 37 | _young_collection_counters(NULL), |
jmasa@2821 | 38 | _eden_counters(NULL), |
jmasa@2821 | 39 | _from_counters(NULL), |
jmasa@2821 | 40 | _to_counters(NULL), |
jmasa@2821 | 41 | _g1_storage_addr(g1_storage_addr) |
jmasa@2821 | 42 | { |
jmasa@2821 | 43 | // Counters for GC collections |
jmasa@2821 | 44 | // |
jmasa@2821 | 45 | // name "collector.0". In a generational collector this would be the |
jmasa@2821 | 46 | // young generation collection. |
jmasa@2821 | 47 | _incremental_collection_counters = |
jmasa@2821 | 48 | new CollectorCounters("G1 incremental collections", 0); |
jmasa@2821 | 49 | // name "collector.1". In a generational collector this would be the |
jmasa@2821 | 50 | // old generation collection. |
jmasa@2821 | 51 | _full_collection_counters = |
jmasa@2821 | 52 | new CollectorCounters("G1 stop-the-world full collections", 1); |
jmasa@2821 | 53 | |
jmasa@2821 | 54 | // timer sampling for all counters supporting sampling only update the |
jmasa@2821 | 55 | // used value. See the take_sample() method. G1 requires both used and |
jmasa@2821 | 56 | // capacity updated so sampling is not currently used. It might |
jmasa@2821 | 57 | // be sufficient to update all counters in take_sample() even though |
jmasa@2821 | 58 | // take_sample() only returns "used". When sampling was used, there |
jmasa@2821 | 59 | // were some anomolous values emitted which may have been the consequence |
jmasa@2821 | 60 | // of not updating all values simultaneously (i.e., see the calculation done |
jmasa@2821 | 61 | // in eden_space_used(), is it possbile that the values used to |
jmasa@2821 | 62 | // calculate either eden_used or survivor_used are being updated by |
jmasa@2821 | 63 | // the collector when the sample is being done?). |
jmasa@2821 | 64 | const bool sampled = false; |
jmasa@2821 | 65 | |
jmasa@2821 | 66 | // "Generation" and "Space" counters. |
jmasa@2821 | 67 | // |
jmasa@2821 | 68 | // name "generation.1" This is logically the old generation in |
jmasa@2821 | 69 | // generational GC terms. The "1, 1" parameters are for |
jmasa@2821 | 70 | // the n-th generation (=1) with 1 space. |
jmasa@2821 | 71 | // Counters are created from minCapacity, maxCapacity, and capacity |
jmasa@2821 | 72 | _non_young_collection_counters = |
jmasa@2821 | 73 | new GenerationCounters("whole heap", 1, 1, _g1_storage_addr); |
jmasa@2821 | 74 | |
jmasa@2821 | 75 | // name "generation.1.space.0" |
jmasa@2821 | 76 | // Counters are created from maxCapacity, capacity, initCapacity, |
jmasa@2821 | 77 | // and used. |
jmasa@2821 | 78 | _old_space_counters = new HSpaceCounters("space", 0, |
jmasa@2821 | 79 | _g1h->max_capacity(), _g1h->capacity(), _non_young_collection_counters); |
jmasa@2821 | 80 | |
jmasa@2821 | 81 | // Young collection set |
jmasa@2821 | 82 | // name "generation.0". This is logically the young generation. |
jmasa@2821 | 83 | // The "0, 3" are paremeters for the n-th genertaion (=0) with 3 spaces. |
jmasa@2821 | 84 | // See _non_young_collection_counters for additional counters |
jmasa@2821 | 85 | _young_collection_counters = new GenerationCounters("young", 0, 3, NULL); |
jmasa@2821 | 86 | |
jmasa@2821 | 87 | // Replace "max_heap_byte_size() with maximum young gen size for |
jmasa@2821 | 88 | // g1Collectedheap |
jmasa@2821 | 89 | // name "generation.0.space.0" |
jmasa@2821 | 90 | // See _old_space_counters for additional counters |
jmasa@2821 | 91 | _eden_counters = new HSpaceCounters("eden", 0, |
jmasa@2821 | 92 | _g1h->max_capacity(), eden_space_committed(), |
jmasa@2821 | 93 | _young_collection_counters); |
jmasa@2821 | 94 | |
jmasa@2821 | 95 | // name "generation.0.space.1" |
jmasa@2821 | 96 | // See _old_space_counters for additional counters |
jmasa@2821 | 97 | // Set the arguments to indicate that this survivor space is not used. |
jmasa@2821 | 98 | _from_counters = new HSpaceCounters("s0", 1, (long) 0, (long) 0, |
jmasa@2821 | 99 | _young_collection_counters); |
jmasa@2821 | 100 | |
jmasa@2821 | 101 | // name "generation.0.space.2" |
jmasa@2821 | 102 | // See _old_space_counters for additional counters |
jmasa@2821 | 103 | _to_counters = new HSpaceCounters("s1", 2, |
jmasa@2821 | 104 | _g1h->max_capacity(), |
jmasa@2821 | 105 | survivor_space_committed(), |
jmasa@2821 | 106 | _young_collection_counters); |
jmasa@2821 | 107 | } |
jmasa@2821 | 108 | |
jmasa@2821 | 109 | size_t G1MonitoringSupport::overall_committed() { |
jmasa@2821 | 110 | return g1h()->capacity(); |
jmasa@2821 | 111 | } |
jmasa@2821 | 112 | |
jmasa@2821 | 113 | size_t G1MonitoringSupport::overall_used() { |
jmasa@2821 | 114 | return g1h()->used_unlocked(); |
jmasa@2821 | 115 | } |
jmasa@2821 | 116 | |
jmasa@2821 | 117 | size_t G1MonitoringSupport::eden_space_committed() { |
jmasa@2821 | 118 | return MAX2(eden_space_used(), (size_t) HeapRegion::GrainBytes); |
jmasa@2821 | 119 | } |
jmasa@2821 | 120 | |
jmasa@2821 | 121 | size_t G1MonitoringSupport::eden_space_used() { |
jmasa@2821 | 122 | size_t young_list_length = g1h()->young_list()->length(); |
jmasa@2821 | 123 | size_t eden_used = young_list_length * HeapRegion::GrainBytes; |
jmasa@2821 | 124 | size_t survivor_used = survivor_space_used(); |
jmasa@2821 | 125 | eden_used = subtract_up_to_zero(eden_used, survivor_used); |
jmasa@2821 | 126 | return eden_used; |
jmasa@2821 | 127 | } |
jmasa@2821 | 128 | |
jmasa@2821 | 129 | size_t G1MonitoringSupport::survivor_space_committed() { |
jmasa@2821 | 130 | return MAX2(survivor_space_used(), |
jmasa@2821 | 131 | (size_t) HeapRegion::GrainBytes); |
jmasa@2821 | 132 | } |
jmasa@2821 | 133 | |
jmasa@2821 | 134 | size_t G1MonitoringSupport::survivor_space_used() { |
jmasa@2821 | 135 | size_t survivor_num = g1h()->g1_policy()->recorded_survivor_regions(); |
jmasa@2821 | 136 | size_t survivor_used = survivor_num * HeapRegion::GrainBytes; |
jmasa@2821 | 137 | return survivor_used; |
jmasa@2821 | 138 | } |
jmasa@2821 | 139 | |
jmasa@2821 | 140 | size_t G1MonitoringSupport::old_space_committed() { |
jmasa@2821 | 141 | size_t committed = overall_committed(); |
jmasa@2821 | 142 | size_t eden_committed = eden_space_committed(); |
jmasa@2821 | 143 | size_t survivor_committed = survivor_space_committed(); |
jmasa@2821 | 144 | committed = subtract_up_to_zero(committed, eden_committed); |
jmasa@2821 | 145 | committed = subtract_up_to_zero(committed, survivor_committed); |
jmasa@2821 | 146 | committed = MAX2(committed, (size_t) HeapRegion::GrainBytes); |
jmasa@2821 | 147 | return committed; |
jmasa@2821 | 148 | } |
jmasa@2821 | 149 | |
jmasa@2821 | 150 | // See the comment near the top of g1MonitoringSupport.hpp for |
jmasa@2821 | 151 | // an explanation of these calculations for "used" and "capacity". |
jmasa@2821 | 152 | size_t G1MonitoringSupport::old_space_used() { |
jmasa@2821 | 153 | size_t used = overall_used(); |
jmasa@2821 | 154 | size_t eden_used = eden_space_used(); |
jmasa@2821 | 155 | size_t survivor_used = survivor_space_used(); |
jmasa@2821 | 156 | used = subtract_up_to_zero(used, eden_used); |
jmasa@2821 | 157 | used = subtract_up_to_zero(used, survivor_used); |
jmasa@2821 | 158 | return used; |
jmasa@2821 | 159 | } |
jmasa@2821 | 160 | |
jmasa@2821 | 161 | void G1MonitoringSupport::update_counters() { |
jmasa@2821 | 162 | if (UsePerfData) { |
jmasa@2821 | 163 | eden_counters()->update_capacity(eden_space_committed()); |
jmasa@2821 | 164 | eden_counters()->update_used(eden_space_used()); |
jmasa@2821 | 165 | to_counters()->update_capacity(survivor_space_committed()); |
jmasa@2821 | 166 | to_counters()->update_used(survivor_space_used()); |
jmasa@2821 | 167 | old_space_counters()->update_capacity(old_space_committed()); |
jmasa@2821 | 168 | old_space_counters()->update_used(old_space_used()); |
jmasa@2821 | 169 | non_young_collection_counters()->update_all(); |
jmasa@2821 | 170 | } |
jmasa@2821 | 171 | } |
jmasa@2821 | 172 | |
jmasa@2821 | 173 | void G1MonitoringSupport::update_eden_counters() { |
jmasa@2821 | 174 | if (UsePerfData) { |
jmasa@2821 | 175 | eden_counters()->update_capacity(eden_space_committed()); |
jmasa@2821 | 176 | eden_counters()->update_used(eden_space_used()); |
jmasa@2821 | 177 | } |
jmasa@2821 | 178 | } |