src/share/vm/gc_implementation/g1/g1MonitoringSupport.cpp

Fri, 29 Apr 2011 14:59:04 -0400

author
tonyp
date
Fri, 29 Apr 2011 14:59:04 -0400
changeset 2849
063382f9b575
parent 2821
b52782ae3880
child 3176
8229bd737950
permissions
-rw-r--r--

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

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

mercurial