hotspot/src/share/vm/gc/g1/concurrentG1RefineThread.cpp
author kbarrett
Tue, 30 Aug 2016 23:48:16 -0400
changeset 40892 330a02d935ad
parent 37985 539c597ee0fa
child 46653 d72083d17b19
permissions -rw-r--r--
8156500: Move Reference pending list into VM to prevent deadlocks Summary: Move reference pending list and locking into VM Reviewed-by: coleenp, dholmes, dcubed, mchung, plevart Contributed-by: kim.barrett@oracle.com, per.liden@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
35916
23189249c2c1 8147884: Names of GC threads should be set before the threads start
asmotrak
parents: 35061
diff changeset
     2
 * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    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
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30613
diff changeset
    26
#include "gc/g1/concurrentG1Refine.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30613
diff changeset
    27
#include "gc/g1/concurrentG1RefineThread.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30613
diff changeset
    28
#include "gc/g1/g1CollectedHeap.inline.hpp"
30770
5ba2d9f2084d 8080585: concurrentGCThread.hpp should not include suspendibleThreadSet.hpp
pliden
parents: 30764
diff changeset
    29
#include "gc/g1/suspendibleThreadSet.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33608
diff changeset
    30
#include "logging/log.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "memory/resourceArea.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "runtime/mutexLocker.hpp"
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    34
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    35
ConcurrentG1RefineThread::
2882
d508a8bac491 6841831: G1: assert(contains_reference(from),"We just added it!") fires
iveresov
parents: 2881
diff changeset
    36
ConcurrentG1RefineThread(ConcurrentG1Refine* cg1r, ConcurrentG1RefineThread *next,
24104
febf9363fb68 8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents: 24094
diff changeset
    37
                         CardTableEntryClosure* refine_closure,
37510
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
    38
                         uint worker_id_offset, uint worker_id,
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
    39
                         size_t activate, size_t deactivate) :
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    40
  ConcurrentGCThread(),
24104
febf9363fb68 8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents: 24094
diff changeset
    41
  _refine_closure(refine_closure),
2882
d508a8bac491 6841831: G1: assert(contains_reference(from),"We just added it!") fires
iveresov
parents: 2881
diff changeset
    42
  _worker_id_offset(worker_id_offset),
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
    43
  _worker_id(worker_id),
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
    44
  _active(false),
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
    45
  _next(next),
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    46
  _monitor(NULL),
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    47
  _cg1r(cg1r),
37510
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
    48
  _vtime_accum(0.0),
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
    49
  _activation_threshold(activate),
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
    50
  _deactivation_threshold(deactivate)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    51
{
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    52
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 10528
diff changeset
    53
  // Each thread has its own monitor. The i-th thread is responsible for signaling
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 10528
diff changeset
    54
  // to thread i+1 if the number of buffers in the queue exceeds a threshold for this
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    55
  // 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
    56
  // 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
    57
  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
    58
    _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
    59
                           Monitor::_safepoint_check_never);
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    60
  } else {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    61
    _monitor = DirtyCardQ_CBL_mon;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    62
  }
24331
c0bc7e5653fb 6885993: Named Thread: introduce print() and print_on(outputStream* st) methods
zgu
parents: 24104
diff changeset
    63
c0bc7e5653fb 6885993: Named Thread: introduce print() and print_on(outputStream* st) methods
zgu
parents: 24104
diff changeset
    64
  // set name
29464
02c245ad3ec9 8073545: Use shorter and more descriptive names for GC worker threads
david
parents: 28163
diff changeset
    65
  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
    66
  create_and_start();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    67
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
37510
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
    69
void ConcurrentG1RefineThread::update_thresholds(size_t activate,
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
    70
                                                 size_t deactivate) {
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
    71
  assert(deactivate < activate, "precondition");
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
    72
  _activation_threshold = activate;
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
    73
  _deactivation_threshold = deactivate;
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    74
}
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
    75
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    76
void ConcurrentG1RefineThread::wait_for_completed_buffers() {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    77
  MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
37081
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36402
diff changeset
    78
  while (!should_terminate() && !is_active()) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    79
    _monitor->wait(Mutex::_no_safepoint_check_flag);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    80
  }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    81
}
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    82
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    83
bool ConcurrentG1RefineThread::is_active() {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    84
  DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents: 30770
diff changeset
    85
  return is_primary() ? dcqs.process_completed_buffers() : _active;
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    86
}
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    87
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    88
void ConcurrentG1RefineThread::activate() {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    89
  MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents: 30770
diff changeset
    90
  if (!is_primary()) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    91
    set_active(true);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    92
  } else {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    93
    DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    94
    dcqs.set_process_completed(true);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    95
  }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    96
  _monitor->notify();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    97
}
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
    98
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    99
void ConcurrentG1RefineThread::deactivate() {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   100
  MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents: 30770
diff changeset
   101
  if (!is_primary()) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   102
    set_active(false);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   103
  } else {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   104
    DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   105
    dcqs.set_process_completed(false);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   106
  }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   107
}
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   108
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents: 30770
diff changeset
   109
void ConcurrentG1RefineThread::run_service() {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   110
  _vtime_start = os::elapsedVTime();
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents: 30770
diff changeset
   111
37081
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36402
diff changeset
   112
  while (!should_terminate()) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   113
    // Wait for work
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   114
    wait_for_completed_buffers();
37081
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36402
diff changeset
   115
    if (should_terminate()) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   116
      break;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   117
    }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   118
37510
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
   119
    size_t buffers_processed = 0;
36196
5128f617b0c6 8150134: Simplify concurrent refinement thread deactivation
kbarrett
parents: 36179
diff changeset
   120
    DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
36371
fd81a4f0ea00 8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents: 36196
diff changeset
   121
    log_debug(gc, refine)("Activated %d, on threshold: " SIZE_FORMAT ", current: " SIZE_FORMAT,
37510
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
   122
                          _worker_id, _activation_threshold, dcqs.completed_buffers_num());
36196
5128f617b0c6 8150134: Simplify concurrent refinement thread deactivation
kbarrett
parents: 36179
diff changeset
   123
24094
5dbf1f44de18 8039147: Cleanup SuspendibleThreadSet
pliden
parents: 23855
diff changeset
   124
    {
30613
a7815bb05ae2 8079579: Add SuspendibleThreadSetLeaver and make SuspendibleThreadSet::joint()/leave() private
pliden
parents: 29464
diff changeset
   125
      SuspendibleThreadSetJoiner sts_join;
24094
5dbf1f44de18 8039147: Cleanup SuspendibleThreadSet
pliden
parents: 23855
diff changeset
   126
37197
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   127
      while (!should_terminate()) {
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   128
        if (sts_join.should_yield()) {
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   129
          sts_join.yield();
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   130
          continue;             // Re-check for termination after yield delay.
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   131
        }
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   132
36371
fd81a4f0ea00 8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents: 36196
diff changeset
   133
        size_t curr_buffer_num = dcqs.completed_buffers_num();
24094
5dbf1f44de18 8039147: Cleanup SuspendibleThreadSet
pliden
parents: 23855
diff changeset
   134
        // If the number of the buffers falls down into the yellow zone,
5dbf1f44de18 8039147: Cleanup SuspendibleThreadSet
pliden
parents: 23855
diff changeset
   135
        // that means that the transition period after the evacuation pause has ended.
5dbf1f44de18 8039147: Cleanup SuspendibleThreadSet
pliden
parents: 23855
diff changeset
   136
        if (dcqs.completed_queue_padding() > 0 && curr_buffer_num <= cg1r()->yellow_zone()) {
5dbf1f44de18 8039147: Cleanup SuspendibleThreadSet
pliden
parents: 23855
diff changeset
   137
          dcqs.set_completed_queue_padding(0);
5dbf1f44de18 8039147: Cleanup SuspendibleThreadSet
pliden
parents: 23855
diff changeset
   138
        }
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   139
24094
5dbf1f44de18 8039147: Cleanup SuspendibleThreadSet
pliden
parents: 23855
diff changeset
   140
        // Check if we need to activate the next thread.
37510
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
   141
        if ((_next != NULL) &&
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
   142
            !_next->is_active() &&
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
   143
            (curr_buffer_num > _next->_activation_threshold)) {
24094
5dbf1f44de18 8039147: Cleanup SuspendibleThreadSet
pliden
parents: 23855
diff changeset
   144
          _next->activate();
5dbf1f44de18 8039147: Cleanup SuspendibleThreadSet
pliden
parents: 23855
diff changeset
   145
        }
5dbf1f44de18 8039147: Cleanup SuspendibleThreadSet
pliden
parents: 23855
diff changeset
   146
37197
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   147
        // Process the next buffer, if there are enough left.
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   148
        if (!dcqs.apply_closure_to_completed_buffer(_refine_closure,
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   149
                                                    _worker_id + _worker_id_offset,
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   150
                                                    _deactivation_threshold,
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   151
                                                    false /* during_pause */)) {
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   152
          break; // Deactivate, number of buffers fell below threshold.
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   153
        }
37510
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
   154
        ++buffers_processed;
37197
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   155
      }
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
   156
    }
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   157
37197
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   158
    deactivate();
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   159
    log_debug(gc, refine)("Deactivated %d, off threshold: " SIZE_FORMAT
37510
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
   160
                          ", current: " SIZE_FORMAT ", processed: " SIZE_FORMAT,
37197
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   161
                          _worker_id, _deactivation_threshold,
37510
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
   162
                          dcqs.completed_buffers_num(),
cf066fe4531b 8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents: 37197
diff changeset
   163
                          buffers_processed);
37197
282fa21230c3 8151670: Unexpected concurrent refinement deactivation and reactivation
kbarrett
parents: 37081
diff changeset
   164
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   165
    if (os::supports_vtime()) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   166
      _vtime_accum = (os::elapsedVTime() - _vtime_start);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   167
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   168
      _vtime_accum = 0.0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   169
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   170
  }
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents: 30770
diff changeset
   171
36196
5128f617b0c6 8150134: Simplify concurrent refinement thread deactivation
kbarrett
parents: 36179
diff changeset
   172
  log_debug(gc, refine)("Stopping %d", _worker_id);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   173
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   174
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents: 30770
diff changeset
   175
void ConcurrentG1RefineThread::stop_service() {
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents: 30770
diff changeset
   176
  MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents: 30770
diff changeset
   177
  _monitor->notify();
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33608
diff changeset
   178
}