author | tschatzl |
Wed, 25 Nov 2015 14:43:29 +0100 | |
changeset 34300 | 6075c1e0e913 |
parent 33608 | 7afc768e4d62 |
child 36371 | fd81a4f0ea00 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
30764 | 2 |
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. |
1374 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5033
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5033
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5033
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/g1/concurrentG1Refine.hpp" |
27 |
#include "gc/g1/concurrentG1RefineThread.hpp" |
|
28 |
#include "gc/g1/g1CollectedHeap.inline.hpp" |
|
29 |
#include "gc/g1/g1HotCardCache.hpp" |
|
22220
eb467dfb9585
8029326: G1 does not check if threads gets created
ehelin
parents:
17854
diff
changeset
|
30 |
#include "runtime/java.hpp" |
8926
717a49db1743
7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents:
8683
diff
changeset
|
31 |
|
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
32 |
ConcurrentG1Refine::ConcurrentG1Refine(G1CollectedHeap* g1h) : |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
33 |
_threads(NULL), |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
34 |
_sample_thread(NULL), |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
35 |
_hot_card_cache(g1h) |
1374 | 36 |
{ |
22551 | 37 |
// Ergonomically select initial concurrent refinement parameters |
5033 | 38 |
if (FLAG_IS_DEFAULT(G1ConcRefinementGreenZone)) { |
30876
44a71334fd94
8080876: Replace unnecessary MAX2(ParallelGCThreads, 1) calls with ParallelGCThreads
stefank
parents:
30764
diff
changeset
|
39 |
FLAG_SET_DEFAULT(G1ConcRefinementGreenZone, (intx)ParallelGCThreads); |
4481 | 40 |
} |
5033 | 41 |
set_green_zone(G1ConcRefinementGreenZone); |
4481 | 42 |
|
5033 | 43 |
if (FLAG_IS_DEFAULT(G1ConcRefinementYellowZone)) { |
44 |
FLAG_SET_DEFAULT(G1ConcRefinementYellowZone, green_zone() * 3); |
|
4481 | 45 |
} |
5033 | 46 |
set_yellow_zone(MAX2<int>(G1ConcRefinementYellowZone, green_zone())); |
4481 | 47 |
|
5033 | 48 |
if (FLAG_IS_DEFAULT(G1ConcRefinementRedZone)) { |
49 |
FLAG_SET_DEFAULT(G1ConcRefinementRedZone, yellow_zone() * 2); |
|
4481 | 50 |
} |
5033 | 51 |
set_red_zone(MAX2<int>(G1ConcRefinementRedZone, yellow_zone())); |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
52 |
} |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
53 |
|
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
54 |
ConcurrentG1Refine* ConcurrentG1Refine::create(G1CollectedHeap* g1h, CardTableEntryClosure* refine_closure, jint* ecode) { |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
55 |
ConcurrentG1Refine* cg1r = new ConcurrentG1Refine(g1h); |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
56 |
if (cg1r == NULL) { |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
57 |
*ecode = JNI_ENOMEM; |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
58 |
vm_shutdown_during_initialization("Could not create ConcurrentG1Refine"); |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
59 |
return NULL; |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
60 |
} |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
61 |
cg1r->_n_worker_threads = thread_num(); |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
62 |
|
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
63 |
cg1r->reset_threshold_step(); |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
64 |
|
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
65 |
cg1r->_threads = NEW_C_HEAP_ARRAY_RETURN_NULL(ConcurrentG1RefineThread*, cg1r->_n_worker_threads, mtGC); |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
66 |
if (cg1r->_threads == NULL) { |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
67 |
*ecode = JNI_ENOMEM; |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
68 |
vm_shutdown_during_initialization("Could not allocate an array for ConcurrentG1RefineThread"); |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
69 |
return NULL; |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
70 |
} |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
71 |
|
23855
c4574075402c
8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents:
22551
diff
changeset
|
72 |
uint worker_id_offset = DirtyCardQueueSet::num_par_ids(); |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
73 |
|
4481 | 74 |
ConcurrentG1RefineThread *next = NULL; |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
75 |
for (uint i = cg1r->_n_worker_threads - 1; i != UINT_MAX; i--) { |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
76 |
ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(cg1r, next, refine_closure, worker_id_offset, i); |
4481 | 77 |
assert(t != NULL, "Conc refine should have been created"); |
22220
eb467dfb9585
8029326: G1 does not check if threads gets created
ehelin
parents:
17854
diff
changeset
|
78 |
if (t->osthread() == NULL) { |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
79 |
*ecode = JNI_ENOMEM; |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
80 |
vm_shutdown_during_initialization("Could not create ConcurrentG1RefineThread"); |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
81 |
return NULL; |
22220
eb467dfb9585
8029326: G1 does not check if threads gets created
ehelin
parents:
17854
diff
changeset
|
82 |
} |
eb467dfb9585
8029326: G1 does not check if threads gets created
ehelin
parents:
17854
diff
changeset
|
83 |
|
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
84 |
assert(t->cg1r() == cg1r, "Conc refine thread should refer to this"); |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
85 |
cg1r->_threads[i] = t; |
4481 | 86 |
next = t; |
1374 | 87 |
} |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
88 |
|
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
89 |
cg1r->_sample_thread = new G1YoungRemSetSamplingThread(); |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
90 |
if (cg1r->_sample_thread->osthread() == NULL) { |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
91 |
*ecode = JNI_ENOMEM; |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
92 |
vm_shutdown_during_initialization("Could not create G1YoungRemSetSamplingThread"); |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
93 |
return NULL; |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
94 |
} |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
95 |
|
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
96 |
*ecode = JNI_OK; |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
97 |
return cg1r; |
1374 | 98 |
} |
99 |
||
4481 | 100 |
void ConcurrentG1Refine::reset_threshold_step() { |
5033 | 101 |
if (FLAG_IS_DEFAULT(G1ConcRefinementThresholdStep)) { |
4481 | 102 |
_thread_threshold_step = (yellow_zone() - green_zone()) / (worker_thread_num() + 1); |
103 |
} else { |
|
5033 | 104 |
_thread_threshold_step = G1ConcRefinementThresholdStep; |
2882
d508a8bac491
6841831: G1: assert(contains_reference(from),"We just added it!") fires
iveresov
parents:
2881
diff
changeset
|
105 |
} |
4481 | 106 |
} |
107 |
||
26160 | 108 |
void ConcurrentG1Refine::init(G1RegionToSpaceMapper* card_counts_storage) { |
109 |
_hot_card_cache.initialize(card_counts_storage); |
|
1374 | 110 |
} |
111 |
||
2881 | 112 |
void ConcurrentG1Refine::stop() { |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
113 |
for (uint i = 0; i < _n_worker_threads; i++) { |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
114 |
_threads[i]->stop(); |
2881 | 115 |
} |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
116 |
_sample_thread->stop(); |
2881 | 117 |
} |
118 |
||
4481 | 119 |
void ConcurrentG1Refine::reinitialize_threads() { |
120 |
reset_threshold_step(); |
|
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
121 |
for (uint i = 0; i < _n_worker_threads; i++) { |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
122 |
_threads[i]->initialize(); |
4481 | 123 |
} |
124 |
} |
|
125 |
||
1374 | 126 |
ConcurrentG1Refine::~ConcurrentG1Refine() { |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
127 |
for (uint i = 0; i < _n_worker_threads; i++) { |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
128 |
delete _threads[i]; |
1374 | 129 |
} |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
130 |
FREE_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _threads); |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
131 |
|
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
132 |
delete _sample_thread; |
1374 | 133 |
} |
134 |
||
2881 | 135 |
void ConcurrentG1Refine::threads_do(ThreadClosure *tc) { |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
136 |
worker_threads_do(tc); |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
137 |
tc->do_thread(_sample_thread); |
1374 | 138 |
} |
139 |
||
17854
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17327
diff
changeset
|
140 |
void ConcurrentG1Refine::worker_threads_do(ThreadClosure * tc) { |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
141 |
for (uint i = 0; i < worker_thread_num(); i++) { |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
142 |
tc->do_thread(_threads[i]); |
17854
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17327
diff
changeset
|
143 |
} |
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17327
diff
changeset
|
144 |
} |
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17327
diff
changeset
|
145 |
|
23855
c4574075402c
8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents:
22551
diff
changeset
|
146 |
uint ConcurrentG1Refine::thread_num() { |
26932
33d6fa41d290
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
26160
diff
changeset
|
147 |
return G1ConcRefinementThreads; |
1374 | 148 |
} |
4022 | 149 |
|
150 |
void ConcurrentG1Refine::print_worker_threads_on(outputStream* st) const { |
|
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
151 |
for (uint i = 0; i < _n_worker_threads; ++i) { |
4022 | 152 |
_threads[i]->print_on(st); |
153 |
st->cr(); |
|
154 |
} |
|
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
155 |
_sample_thread->print_on(st); |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
156 |
st->cr(); |
4022 | 157 |
} |