Tue, 04 Jun 2013 10:04:06 -0700
8015244: G1: Verification after a full GC is incorrectly placed.
Summary: In a full GC, move the verification after the GC to after RSet rebuilding. Verify RSet entries during a full GC under control of a flag.
Reviewed-by: tschatzl, brutisso
1 /*
2 * Copyright (c) 2001, 2013, 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/concurrentG1Refine.hpp"
27 #include "gc_implementation/g1/concurrentG1RefineThread.hpp"
28 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
29 #include "gc_implementation/g1/g1HotCardCache.hpp"
31 ConcurrentG1Refine::ConcurrentG1Refine(G1CollectedHeap* g1h) :
32 _threads(NULL), _n_threads(0),
33 _hot_card_cache(g1h)
34 {
35 // Ergomonically select initial concurrent refinement parameters
36 if (FLAG_IS_DEFAULT(G1ConcRefinementGreenZone)) {
37 FLAG_SET_DEFAULT(G1ConcRefinementGreenZone, MAX2<int>(ParallelGCThreads, 1));
38 }
39 set_green_zone(G1ConcRefinementGreenZone);
41 if (FLAG_IS_DEFAULT(G1ConcRefinementYellowZone)) {
42 FLAG_SET_DEFAULT(G1ConcRefinementYellowZone, green_zone() * 3);
43 }
44 set_yellow_zone(MAX2<int>(G1ConcRefinementYellowZone, green_zone()));
46 if (FLAG_IS_DEFAULT(G1ConcRefinementRedZone)) {
47 FLAG_SET_DEFAULT(G1ConcRefinementRedZone, yellow_zone() * 2);
48 }
49 set_red_zone(MAX2<int>(G1ConcRefinementRedZone, yellow_zone()));
51 _n_worker_threads = thread_num();
52 // We need one extra thread to do the young gen rset size sampling.
53 _n_threads = _n_worker_threads + 1;
55 reset_threshold_step();
57 _threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads, mtGC);
59 int worker_id_offset = (int)DirtyCardQueueSet::num_par_ids();
61 ConcurrentG1RefineThread *next = NULL;
62 for (int i = _n_threads - 1; i >= 0; i--) {
63 ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i);
64 assert(t != NULL, "Conc refine should have been created");
65 assert(t->cg1r() == this, "Conc refine thread should refer to this");
66 _threads[i] = t;
67 next = t;
68 }
69 }
71 void ConcurrentG1Refine::reset_threshold_step() {
72 if (FLAG_IS_DEFAULT(G1ConcRefinementThresholdStep)) {
73 _thread_threshold_step = (yellow_zone() - green_zone()) / (worker_thread_num() + 1);
74 } else {
75 _thread_threshold_step = G1ConcRefinementThresholdStep;
76 }
77 }
79 void ConcurrentG1Refine::init() {
80 _hot_card_cache.initialize();
81 }
83 void ConcurrentG1Refine::stop() {
84 if (_threads != NULL) {
85 for (int i = 0; i < _n_threads; i++) {
86 _threads[i]->stop();
87 }
88 }
89 }
91 void ConcurrentG1Refine::reinitialize_threads() {
92 reset_threshold_step();
93 if (_threads != NULL) {
94 for (int i = 0; i < _n_threads; i++) {
95 _threads[i]->initialize();
96 }
97 }
98 }
100 ConcurrentG1Refine::~ConcurrentG1Refine() {
101 if (_threads != NULL) {
102 for (int i = 0; i < _n_threads; i++) {
103 delete _threads[i];
104 }
105 FREE_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _threads, mtGC);
106 }
107 }
109 void ConcurrentG1Refine::threads_do(ThreadClosure *tc) {
110 if (_threads != NULL) {
111 for (int i = 0; i < _n_threads; i++) {
112 tc->do_thread(_threads[i]);
113 }
114 }
115 }
117 void ConcurrentG1Refine::worker_threads_do(ThreadClosure * tc) {
118 if (_threads != NULL) {
119 for (int i = 0; i < worker_thread_num(); i++) {
120 tc->do_thread(_threads[i]);
121 }
122 }
123 }
125 int ConcurrentG1Refine::thread_num() {
126 int n_threads = (G1ConcRefinementThreads > 0) ? G1ConcRefinementThreads
127 : ParallelGCThreads;
128 return MAX2<int>(n_threads, 1);
129 }
131 void ConcurrentG1Refine::print_worker_threads_on(outputStream* st) const {
132 for (int i = 0; i < _n_threads; ++i) {
133 _threads[i]->print_on(st);
134 st->cr();
135 }
136 }
138 ConcurrentG1RefineThread * ConcurrentG1Refine::sampling_thread() const {
139 return _threads[worker_thread_num()];
140 }