author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58508 | d6058bd73982 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
53747
13acc8e38a29
8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents:
53102
diff
changeset
|
2 |
* Copyright (c) 2001, 2019, 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:
5350
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5350
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:
5350
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
49751
c3a10df652c0
8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents:
48103
diff
changeset
|
26 |
#include "gc/g1/g1BarrierSet.hpp" |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47647
diff
changeset
|
27 |
#include "gc/g1/g1ConcurrentRefine.hpp" |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47647
diff
changeset
|
28 |
#include "gc/g1/g1ConcurrentRefineThread.hpp" |
53747
13acc8e38a29
8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents:
53102
diff
changeset
|
29 |
#include "gc/g1/g1DirtyCardQueue.hpp" |
47647
64dba69fc528
8189276: Make SuspendibleThreadSet and related code available to other GCs
rkennke
parents:
47216
diff
changeset
|
30 |
#include "gc/shared/suspendibleThreadSet.hpp" |
35061 | 31 |
#include "logging/log.hpp" |
7397 | 32 |
#include "memory/resourceArea.hpp" |
33 |
#include "runtime/handles.inline.hpp" |
|
34 |
#include "runtime/mutexLocker.hpp" |
|
1374 | 35 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47789
diff
changeset
|
36 |
G1ConcurrentRefineThread::G1ConcurrentRefineThread(G1ConcurrentRefine* cr, uint worker_id) : |
1374 | 37 |
ConcurrentGCThread(), |
51332 | 38 |
_vtime_start(0.0), |
39 |
_vtime_accum(0.0), |
|
58508
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
57953
diff
changeset
|
40 |
_total_refinement_time(), |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
57953
diff
changeset
|
41 |
_total_refined_cards(0), |
2881 | 42 |
_worker_id(worker_id), |
43 |
_active(false), |
|
4481 | 44 |
_monitor(NULL), |
51332 | 45 |
_cr(cr) |
1374 | 46 |
{ |
22551 | 47 |
// Each thread has its own monitor. The i-th thread is responsible for signaling |
48 |
// to thread i+1 if the number of buffers in the queue exceeds a threshold for this |
|
4481 | 49 |
// thread. Monitors are also used to wake up the threads during termination. |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
30770
diff
changeset
|
50 |
// The 0th (primary) worker is notified by mutator threads and has a special monitor. |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
30770
diff
changeset
|
51 |
if (!is_primary()) { |
28163
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
24331
diff
changeset
|
52 |
_monitor = new Monitor(Mutex::nonleaf, "Refinement monitor", true, |
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
24331
diff
changeset
|
53 |
Monitor::_safepoint_check_never); |
4481 | 54 |
} else { |
55 |
_monitor = DirtyCardQ_CBL_mon; |
|
56 |
} |
|
24331
c0bc7e5653fb
6885993: Named Thread: introduce print() and print_on(outputStream* st) methods
zgu
parents:
24104
diff
changeset
|
57 |
|
c0bc7e5653fb
6885993: Named Thread: introduce print() and print_on(outputStream* st) methods
zgu
parents:
24104
diff
changeset
|
58 |
// set name |
29464
02c245ad3ec9
8073545: Use shorter and more descriptive names for GC worker threads
david
parents:
28163
diff
changeset
|
59 |
set_name("G1 Refine#%d", worker_id); |
35916
23189249c2c1
8147884: Names of GC threads should be set before the threads start
asmotrak
parents:
35061
diff
changeset
|
60 |
create_and_start(); |
1374 | 61 |
} |
62 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47647
diff
changeset
|
63 |
void G1ConcurrentRefineThread::wait_for_completed_buffers() { |
54645
05aaccf7d558
8222988: Use MonitorLocker rather than MutexLocker when wait/notify used
coleenp
parents:
54623
diff
changeset
|
64 |
MonitorLocker ml(_monitor, Mutex::_no_safepoint_check_flag); |
37081
7656f5356a5d
8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents:
36402
diff
changeset
|
65 |
while (!should_terminate() && !is_active()) { |
54645
05aaccf7d558
8222988: Use MonitorLocker rather than MutexLocker when wait/notify used
coleenp
parents:
54623
diff
changeset
|
66 |
ml.wait(); |
4481 | 67 |
} |
68 |
} |
|
69 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47647
diff
changeset
|
70 |
bool G1ConcurrentRefineThread::is_active() { |
53747
13acc8e38a29
8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents:
53102
diff
changeset
|
71 |
G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
30770
diff
changeset
|
72 |
return is_primary() ? dcqs.process_completed_buffers() : _active; |
4481 | 73 |
} |
74 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47647
diff
changeset
|
75 |
void G1ConcurrentRefineThread::activate() { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
53747
diff
changeset
|
76 |
MutexLocker x(_monitor, Mutex::_no_safepoint_check_flag); |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
30770
diff
changeset
|
77 |
if (!is_primary()) { |
4481 | 78 |
set_active(true); |
79 |
} else { |
|
53747
13acc8e38a29
8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents:
53102
diff
changeset
|
80 |
G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); |
53102
35530ca3e0b2
8214201: Make PtrQueueSet completed buffer list private
kbarrett
parents:
51332
diff
changeset
|
81 |
dcqs.set_process_completed_buffers(true); |
4481 | 82 |
} |
83 |
_monitor->notify(); |
|
84 |
} |
|
2881 | 85 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47647
diff
changeset
|
86 |
void G1ConcurrentRefineThread::deactivate() { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
53747
diff
changeset
|
87 |
MutexLocker x(_monitor, Mutex::_no_safepoint_check_flag); |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
30770
diff
changeset
|
88 |
if (!is_primary()) { |
4481 | 89 |
set_active(false); |
90 |
} else { |
|
53747
13acc8e38a29
8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents:
53102
diff
changeset
|
91 |
G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); |
53102
35530ca3e0b2
8214201: Make PtrQueueSet completed buffer list private
kbarrett
parents:
51332
diff
changeset
|
92 |
dcqs.set_process_completed_buffers(false); |
4481 | 93 |
} |
94 |
} |
|
95 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47647
diff
changeset
|
96 |
void G1ConcurrentRefineThread::run_service() { |
4481 | 97 |
_vtime_start = os::elapsedVTime(); |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
30770
diff
changeset
|
98 |
|
37081
7656f5356a5d
8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents:
36402
diff
changeset
|
99 |
while (!should_terminate()) { |
4481 | 100 |
// Wait for work |
101 |
wait_for_completed_buffers(); |
|
37081
7656f5356a5d
8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents:
36402
diff
changeset
|
102 |
if (should_terminate()) { |
4481 | 103 |
break; |
104 |
} |
|
105 |
||
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47789
diff
changeset
|
106 |
log_debug(gc, refine)("Activated worker %d, on threshold: " SIZE_FORMAT ", current: " SIZE_FORMAT, |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47789
diff
changeset
|
107 |
_worker_id, _cr->activation_threshold(_worker_id), |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
108 |
G1BarrierSet::dirty_card_queue_set().num_cards()); |
36196
5128f617b0c6
8150134: Simplify concurrent refinement thread deactivation
kbarrett
parents:
36179
diff
changeset
|
109 |
|
58508
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
57953
diff
changeset
|
110 |
size_t start_total_refined_cards = _total_refined_cards; // For logging. |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
57953
diff
changeset
|
111 |
|
24094 | 112 |
{ |
30613
a7815bb05ae2
8079579: Add SuspendibleThreadSetLeaver and make SuspendibleThreadSet::joint()/leave() private
pliden
parents:
29464
diff
changeset
|
113 |
SuspendibleThreadSetJoiner sts_join; |
24094 | 114 |
|
37197
282fa21230c3
8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents:
37081
diff
changeset
|
115 |
while (!should_terminate()) { |
282fa21230c3
8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents:
37081
diff
changeset
|
116 |
if (sts_join.should_yield()) { |
282fa21230c3
8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents:
37081
diff
changeset
|
117 |
sts_join.yield(); |
282fa21230c3
8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents:
37081
diff
changeset
|
118 |
continue; // Re-check for termination after yield delay. |
282fa21230c3
8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents:
37081
diff
changeset
|
119 |
} |
282fa21230c3
8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents:
37081
diff
changeset
|
120 |
|
58508
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
57953
diff
changeset
|
121 |
Ticks start_time = Ticks::now(); |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
57953
diff
changeset
|
122 |
if (!_cr->do_refinement_step(_worker_id, &_total_refined_cards)) { |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
57953
diff
changeset
|
123 |
break; // No cards to process. |
37197
282fa21230c3
8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents:
37081
diff
changeset
|
124 |
} |
58508
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
57953
diff
changeset
|
125 |
_total_refinement_time += (Ticks::now() - start_time); |
37197
282fa21230c3
8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents:
37081
diff
changeset
|
126 |
} |
2881 | 127 |
} |
4481 | 128 |
|
37197
282fa21230c3
8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents:
37081
diff
changeset
|
129 |
deactivate(); |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47789
diff
changeset
|
130 |
log_debug(gc, refine)("Deactivated worker %d, off threshold: " SIZE_FORMAT |
58508
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
57953
diff
changeset
|
131 |
", current: " SIZE_FORMAT ", refined cards: " |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
57953
diff
changeset
|
132 |
SIZE_FORMAT ", total refined cards: " SIZE_FORMAT, |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47789
diff
changeset
|
133 |
_worker_id, _cr->deactivation_threshold(_worker_id), |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
134 |
G1BarrierSet::dirty_card_queue_set().num_cards(), |
58508
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
57953
diff
changeset
|
135 |
_total_refined_cards - start_total_refined_cards, |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
57953
diff
changeset
|
136 |
_total_refined_cards); |
37197
282fa21230c3
8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents:
37081
diff
changeset
|
137 |
|
1374 | 138 |
if (os::supports_vtime()) { |
139 |
_vtime_accum = (os::elapsedVTime() - _vtime_start); |
|
140 |
} else { |
|
141 |
_vtime_accum = 0.0; |
|
142 |
} |
|
143 |
} |
|
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
30770
diff
changeset
|
144 |
|
36196
5128f617b0c6
8150134: Simplify concurrent refinement thread deactivation
kbarrett
parents:
36179
diff
changeset
|
145 |
log_debug(gc, refine)("Stopping %d", _worker_id); |
1374 | 146 |
} |
147 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47647
diff
changeset
|
148 |
void G1ConcurrentRefineThread::stop_service() { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
53747
diff
changeset
|
149 |
MutexLocker x(_monitor, Mutex::_no_safepoint_check_flag); |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
30770
diff
changeset
|
150 |
_monitor->notify(); |
35061 | 151 |
} |