comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 4831:7ca7be5a6a0b

7129271: G1: Interference from multiple threads in PrintGC/PrintGCDetails output Summary: During an initial mark pause, signal the Concurrent Mark thread after the pause output from PrintGC/PrintGCDetails is complete. Reviewed-by: tonyp, brutisso
author johnc
date Tue, 17 Jan 2012 10:21:43 -0800
parents 9509c20bba28
children 57025542827f
comparison
equal deleted inserted replaced
4830:0b3d1ec6eaee 4831:7ca7be5a6a0b
3555 3555
3556 HRSPhaseSetter x(HRSPhaseEvacuation); 3556 HRSPhaseSetter x(HRSPhaseEvacuation);
3557 verify_region_sets_optional(); 3557 verify_region_sets_optional();
3558 verify_dirty_young_regions(); 3558 verify_dirty_young_regions();
3559 3559
3560 // This call will decide whether this pause is an initial-mark
3561 // pause. If it is, during_initial_mark_pause() will return true
3562 // for the duration of this pause.
3563 g1_policy()->decide_on_conc_mark_initiation();
3564
3565 // We do not allow initial-mark to be piggy-backed on a mixed GC.
3566 assert(!g1_policy()->during_initial_mark_pause() ||
3567 g1_policy()->gcs_are_young(), "sanity");
3568
3569 // We also do not allow mixed GCs during marking.
3570 assert(!mark_in_progress() || g1_policy()->gcs_are_young(), "sanity");
3571
3572 // Record whether this pause is an initial mark. When the current
3573 // thread has completed its logging output and it's safe to signal
3574 // the CM thread, the flag's value in the policy has been reset.
3575 bool should_start_conc_mark = g1_policy()->during_initial_mark_pause();
3576
3577 // Inner scope for scope based logging, timers, and stats collection
3560 { 3578 {
3561 // This call will decide whether this pause is an initial-mark
3562 // pause. If it is, during_initial_mark_pause() will return true
3563 // for the duration of this pause.
3564 g1_policy()->decide_on_conc_mark_initiation();
3565
3566 // We do not allow initial-mark to be piggy-backed on a mixed GC.
3567 assert(!g1_policy()->during_initial_mark_pause() ||
3568 g1_policy()->gcs_are_young(), "sanity");
3569
3570 // We also do not allow mixed GCs during marking.
3571 assert(!mark_in_progress() || g1_policy()->gcs_are_young(), "sanity");
3572
3573 char verbose_str[128]; 3579 char verbose_str[128];
3574 sprintf(verbose_str, "GC pause "); 3580 sprintf(verbose_str, "GC pause ");
3575 if (g1_policy()->gcs_are_young()) { 3581 if (g1_policy()->gcs_are_young()) {
3576 strcat(verbose_str, "(young)"); 3582 strcat(verbose_str, "(young)");
3577 } else { 3583 } else {
3623 gclog_or_tty->print(" VerifyBeforeGC:"); 3629 gclog_or_tty->print(" VerifyBeforeGC:");
3624 prepare_for_verify(); 3630 prepare_for_verify();
3625 Universe::verify(/* allow dirty */ false, 3631 Universe::verify(/* allow dirty */ false,
3626 /* silent */ false, 3632 /* silent */ false,
3627 /* option */ VerifyOption_G1UsePrevMarking); 3633 /* option */ VerifyOption_G1UsePrevMarking);
3628
3629 } 3634 }
3630 3635
3631 COMPILER2_PRESENT(DerivedPointerTable::clear()); 3636 COMPILER2_PRESENT(DerivedPointerTable::clear());
3632 3637
3633 // Please see comment in g1CollectedHeap.hpp and 3638 // Please see comment in g1CollectedHeap.hpp and
3777 } 3782 }
3778 3783
3779 if (g1_policy()->during_initial_mark_pause()) { 3784 if (g1_policy()->during_initial_mark_pause()) {
3780 concurrent_mark()->checkpointRootsInitialPost(); 3785 concurrent_mark()->checkpointRootsInitialPost();
3781 set_marking_started(); 3786 set_marking_started();
3782 // CAUTION: after the doConcurrentMark() call below, 3787 // Note that we don't actually trigger the CM thread at
3783 // the concurrent marking thread(s) could be running 3788 // this point. We do that later when we're sure that
3784 // concurrently with us. Make sure that anything after 3789 // the current thread has completed its logging output.
3785 // this point does not assume that we are the only GC thread
3786 // running. Note: of course, the actual marking work will
3787 // not start until the safepoint itself is released in
3788 // ConcurrentGCThread::safepoint_desynchronize().
3789 doConcurrentMark();
3790 } 3790 }
3791 3791
3792 allocate_dummy_regions(); 3792 allocate_dummy_regions();
3793 3793
3794 #if YOUNG_LIST_VERBOSE 3794 #if YOUNG_LIST_VERBOSE
3894 print_tracing_info(); 3894 print_tracing_info();
3895 vm_exit(-1); 3895 vm_exit(-1);
3896 } 3896 }
3897 } 3897 }
3898 3898
3899 // The closing of the inner scope, immediately above, will complete
3900 // the PrintGC logging output. The record_collection_pause_end() call
3901 // above will complete the logging output of PrintGCDetails.
3902 //
3903 // It is not yet to safe, however, to tell the concurrent mark to
3904 // start as we have some optional output below. We don't want the
3905 // output from the concurrent mark thread interfering with this
3906 // logging output either.
3907
3899 _hrs.verify_optional(); 3908 _hrs.verify_optional();
3900 verify_region_sets_optional(); 3909 verify_region_sets_optional();
3901 3910
3902 TASKQUEUE_STATS_ONLY(if (ParallelGCVerbose) print_taskqueue_stats()); 3911 TASKQUEUE_STATS_ONLY(if (ParallelGCVerbose) print_taskqueue_stats());
3903 TASKQUEUE_STATS_ONLY(reset_taskqueue_stats()); 3912 TASKQUEUE_STATS_ONLY(reset_taskqueue_stats());
3909 3918
3910 if (G1SummarizeRSetStats && 3919 if (G1SummarizeRSetStats &&
3911 (G1SummarizeRSetStatsPeriod > 0) && 3920 (G1SummarizeRSetStatsPeriod > 0) &&
3912 (total_collections() % G1SummarizeRSetStatsPeriod == 0)) { 3921 (total_collections() % G1SummarizeRSetStatsPeriod == 0)) {
3913 g1_rem_set()->print_summary_info(); 3922 g1_rem_set()->print_summary_info();
3923 }
3924
3925 // It should now be safe to tell the concurrent mark thread to start
3926 // without its logging output interfering with the logging output
3927 // that came from the pause.
3928
3929 if (should_start_conc_mark) {
3930 // CAUTION: after the doConcurrentMark() call below,
3931 // the concurrent marking thread(s) could be running
3932 // concurrently with us. Make sure that anything after
3933 // this point does not assume that we are the only GC thread
3934 // running. Note: of course, the actual marking work will
3935 // not start until the safepoint itself is released in
3936 // ConcurrentGCThread::safepoint_desynchronize().
3937 doConcurrentMark();
3914 } 3938 }
3915 3939
3916 return true; 3940 return true;
3917 } 3941 }
3918 3942