< prev index next >
src/share/vm/gc/g1/concurrentMarkThread.cpp
Print this page
@@ -76,11 +76,23 @@
void do_void(){
_cm->cleanup();
}
};
-
+// We want to avoid that the logging from the concurrent thread is mixed
+// with the logging from a STW GC. Join the STS to ensure that the logging
+// is done either before or after the STW logging.
+void ConcurrentMarkThread::cm_log(bool doit, const char* fmt, ...) {
+ if (doit) {
+ SuspendibleThreadSetJoiner sts_joiner;
+ va_list args;
+ va_start(args, fmt);
+ gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id());
+ gclog_or_tty->vprint_cr(fmt, args);
+ va_end(args);
+ }
+}
void ConcurrentMarkThread::run() {
initialize_in_thread();
_vtime_start = os::elapsedVTime();
wait_for_universe_init();
@@ -107,10 +119,12 @@
// make sure that we do not join the STS until the root regions
// have been scanned. If we did then it's possible that a
// subsequent GC could block us from joining the STS and proceed
// without the root regions have been scanned which would be a
// correctness issue.
+ // This means that we can not use the cm_log() method for the logging
+ // regarding the root region scanning below.
double scan_start = os::elapsedTime();
if (!cm()->has_aborted()) {
if (G1Log::fine()) {
gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id());
@@ -126,14 +140,11 @@
scan_end - scan_start);
}
}
double mark_start_sec = os::elapsedTime();
- if (G1Log::fine()) {
- gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id());
- gclog_or_tty->print_cr("[GC concurrent-mark-start]");
- }
+ cm_log(G1Log::fine(), "[GC concurrent-mark-start]");
int iter = 0;
do {
iter++;
if (!cm()->has_aborted()) {
@@ -149,29 +160,19 @@
double remark_prediction_ms = g1_policy->predict_remark_time_ms();
jlong sleep_time_ms = mmu_tracker->when_ms(now, remark_prediction_ms);
os::sleep(current_thread, sleep_time_ms, false);
}
- if (G1Log::fine()) {
- gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id());
- gclog_or_tty->print_cr("[GC concurrent-mark-end, %1.7lf secs]",
- mark_end_sec - mark_start_sec);
- }
+ cm_log(G1Log::fine(), "[GC concurrent-mark-end, %1.7lf secs]", mark_end_sec - mark_start_sec);
CMCheckpointRootsFinalClosure final_cl(_cm);
VM_CGC_Operation op(&final_cl, "GC remark", true /* needs_pll */);
VMThread::execute(&op);
}
if (cm()->restart_for_overflow()) {
- if (G1TraceMarkStackOverflow) {
- gclog_or_tty->print_cr("Restarting conc marking because of MS overflow "
- "in remark (restart #%d).", iter);
- }
- if (G1Log::fine()) {
- gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id());
- gclog_or_tty->print_cr("[GC concurrent-mark-restart-for-overflow]");
- }
+ cm_log(G1TraceMarkStackOverflow, "Restarting conc marking because of MS overflow in remark (restart #%d).", iter);
+ cm_log(G1Log::fine(), "[GC concurrent-mark-restart-for-overflow]");
}
} while (cm()->restart_for_overflow());
double end_time = os::elapsedVTime();
// Update the total virtual time before doing this, since it will try
@@ -207,14 +208,11 @@
// case they are needed by the pause. If a Full GC takes
// place, it would wait for us to process the regions
// reclaimed by cleanup.
double cleanup_start_sec = os::elapsedTime();
- if (G1Log::fine()) {
- gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id());
- gclog_or_tty->print_cr("[GC concurrent-cleanup-start]");
- }
+ cm_log(G1Log::fine(), "[GC concurrent-cleanup-start]");
// Now do the concurrent cleanup operation.
_cm->completeCleanup();
// Notify anyone who's waiting that there are no more free
@@ -227,15 +225,11 @@
// while it's trying to join the STS, which is conditional on
// the GC workers finishing.
g1h->reset_free_regions_coming();
double cleanup_end_sec = os::elapsedTime();
- if (G1Log::fine()) {
- gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id());
- gclog_or_tty->print_cr("[GC concurrent-cleanup-end, %1.7lf secs]",
- cleanup_end_sec - cleanup_start_sec);
- }
+ cm_log(G1Log::fine(), "[GC concurrent-cleanup-end, %1.7lf secs]", cleanup_end_sec - cleanup_start_sec);
}
guarantee(cm()->cleanup_list_is_empty(),
"at this point there should be no regions on the cleanup list");
// There is a tricky race before recording that the concurrent
@@ -264,19 +258,17 @@
// already reset).
{
SuspendibleThreadSetJoiner sts_join;
if (!cm()->has_aborted()) {
g1_policy->record_concurrent_mark_cleanup_completed();
- }
- }
-
- if (cm()->has_aborted()) {
+ } else {
if (G1Log::fine()) {
gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id());
gclog_or_tty->print_cr("[GC concurrent-mark-abort]");
}
}
+ }
// We now want to allow clearing of the marking bitmap to be
// suspended by a collection pause.
// We may have aborted just before the remark. Do not bother clearing the
// bitmap then, as it has been done during mark abort.
< prev index next >