Print this page
Abort concurrent mark

Split Close
Expand all
Collapse all
          --- old/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
          +++ new/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
↓ open down ↓ 377 lines elided ↑ open up ↑
 378  378    // _tasks set inside the constructor
 379  379  
 380  380    _task_queues(new G1CMTaskQueueSet((int) _max_num_tasks)),
 381  381    _terminator((int) _max_num_tasks, _task_queues),
 382  382  
 383  383    _first_overflow_barrier_sync(),
 384  384    _second_overflow_barrier_sync(),
 385  385  
 386  386    _has_overflown(false),
 387  387    _concurrent(false),
 388      -  _has_aborted(false),
      388 +  _aborted_by_fullgc(false),
      389 +  _aborted_by_initial_mark(false),
 389  390    _restart_for_overflow(false),
 390  391    _gc_timer_cm(new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer()),
 391  392    _gc_tracer_cm(new (ResourceObj::C_HEAP, mtGC) G1OldTracer()),
 392  393  
 393  394    // _verbose_level set below
 394  395  
 395  396    _init_times(),
 396  397    _remark_times(),
 397  398    _remark_mark_times(),
 398  399    _remark_weak_ref_times(),
↓ open down ↓ 46 lines elided ↑ open up ↑
 445  446  
 446  447      _tasks[i] = new G1CMTask(i, this, task_queue, _region_mark_stats, _g1h->max_regions());
 447  448  
 448  449      _accum_task_vtime[i] = 0.0;
 449  450    }
 450  451  
 451  452    reset_at_marking_complete();
 452  453  }
 453  454  
 454  455  void G1ConcurrentMark::reset() {
 455      -  _has_aborted = false;
      456 +  _aborted_by_fullgc = false;
      457 +  _aborted_by_initial_mark = false;
 456  458  
 457  459    reset_marking_for_restart();
 458  460  
 459  461    // Reset all tasks, since different phases will use different number of active
 460  462    // threads. So, it's easiest to have all of them ready.
 461  463    for (uint i = 0; i < _max_num_tasks; ++i) {
 462  464      _tasks[i]->reset(_next_mark_bitmap);
 463  465    }
 464  466  
 465  467    uint max_regions = _g1h->max_regions();
↓ open down ↓ 431 lines elided ↑ open up ↑
 897  899    _gc_tracer_cm->report_gc_start(GCCause::_no_gc /* first parameter is not used */, _gc_timer_cm->gc_start());
 898  900  
 899  901    _g1h->trace_heap_before_gc(_gc_tracer_cm);
 900  902  }
 901  903  
 902  904  void G1ConcurrentMark::concurrent_cycle_end() {
 903  905    _g1h->collector_state()->set_clearing_next_bitmap(false);
 904  906  
 905  907    _g1h->trace_heap_after_gc(_gc_tracer_cm);
 906  908  
 907      -  if (has_aborted()) {
 908      -    log_info(gc, marking)("Concurrent Mark Abort");
      909 +  if (aborted_by_fullgc()) {
      910 +    log_info(gc, marking)("Concurrent Mark Abort due to Full GC");
 909  911      _gc_tracer_cm->report_concurrent_mode_failure();
      912 +  } else if (aborted_by_initial_mark()) {
      913 +    log_info(gc, marking)("Concurrent Mark Abort due to Humongous Reclaim");
 910  914    }
 911  915  
 912  916    _gc_timer_cm->register_gc_end();
 913  917  
 914  918    _gc_tracer_cm->report_gc_end(_gc_timer_cm->gc_end(), _gc_timer_cm->time_partitions());
 915  919  }
 916  920  
 917  921  void G1ConcurrentMark::mark_from_roots() {
 918  922    _restart_for_overflow = false;
 919  923  
↓ open down ↓ 1032 lines elided ↑ open up ↑
1952 1956    if (!log_is_enabled(Debug, gc, stats)) {
1953 1957      return;
1954 1958    }
1955 1959    log_debug(gc, stats)("---------------------------------------------------------------------");
1956 1960    for (size_t i = 0; i < _num_active_tasks; ++i) {
1957 1961      _tasks[i]->print_stats();
1958 1962      log_debug(gc, stats)("---------------------------------------------------------------------");
1959 1963    }
1960 1964  }
1961 1965  
1962      -void G1ConcurrentMark::concurrent_cycle_abort() {
1963      -  if (!cm_thread()->during_cycle() || _has_aborted) {
     1966 +void G1ConcurrentMark::concurrent_cycle_abort_by_initial_mark() {
     1967 +  _aborted_by_initial_mark = true;
     1968 +  _g1h->collector_state()->set_in_initial_mark_gc(false);
     1969 +}
     1970 +
     1971 +void G1ConcurrentMark::concurrent_cycle_abort_by_fullgc() {
     1972 +  if (!cm_thread()->during_cycle() || _aborted_by_fullgc) {
1964 1973      // We haven't started a concurrent cycle or we have already aborted it. No need to do anything.
1965 1974      return;
1966 1975    }
1967 1976  
1968 1977    // Clear all marks in the next bitmap for the next marking cycle. This will allow us to skip the next
1969 1978    // concurrent bitmap clearing.
1970 1979    {
1971 1980      GCTraceTime(Debug, gc) debug("Clear Next Bitmap");
1972 1981      clear_bitmap(_next_mark_bitmap, _g1h->workers(), false);
1973 1982    }
↓ open down ↓ 1 lines elided ↑ open up ↑
1975 1984    // since VerifyDuringGC verifies the objects marked during
1976 1985    // a full GC against the previous bitmap.
1977 1986  
1978 1987    // Empty mark stack
1979 1988    reset_marking_for_restart();
1980 1989    for (uint i = 0; i < _max_num_tasks; ++i) {
1981 1990      _tasks[i]->clear_region_fields();
1982 1991    }
1983 1992    _first_overflow_barrier_sync.abort();
1984 1993    _second_overflow_barrier_sync.abort();
1985      -  _has_aborted = true;
     1994 +  _aborted_by_fullgc = true;
1986 1995  
1987 1996    SATBMarkQueueSet& satb_mq_set = G1BarrierSet::satb_mark_queue_set();
1988 1997    satb_mq_set.abandon_partial_marking();
1989 1998    // This can be called either during or outside marking, we'll read
1990 1999    // the expected_active value from the SATB queue set.
1991 2000    satb_mq_set.set_active_all_threads(
1992 2001                                   false, /* new active value */
1993 2002                                   satb_mq_set.is_active() /* expected_active */);
1994 2003  }
1995 2004  
↓ open down ↓ 1017 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX