1604 // even while we are still in the process of reclaiming memory.
1605 bool during_cycle = _g1->concurrent_mark()->cmThread()->during_cycle();
1606 if (!during_cycle) {
1607 ergo_verbose1(ErgoConcCycles,
1608 "request concurrent cycle initiation",
1609 ergo_format_reason("requested by GC cause")
1610 ergo_format_str("GC cause"),
1611 GCCause::to_string(gc_cause));
1612 collector_state()->set_initiate_conc_mark_if_possible(true);
1613 return true;
1614 } else {
1615 ergo_verbose1(ErgoConcCycles,
1616 "do not request concurrent cycle initiation",
1617 ergo_format_reason("concurrent cycle already in progress")
1618 ergo_format_str("GC cause"),
1619 GCCause::to_string(gc_cause));
1620 return false;
1621 }
1622 }
1623
1624 void G1CollectorPolicy::decide_on_conc_mark_initiation() {
1625 // We are about to decide on whether this pause will be an
1626 // initial-mark pause.
1627
1628 // First, collector_state()->during_initial_mark_pause() should not be already set. We
1629 // will set it here if we have to. However, it should be cleared by
1630 // the end of the pause (it's only set for the duration of an
1631 // initial-mark pause).
1632 assert(!collector_state()->during_initial_mark_pause(), "pre-condition");
1633
1634 if (collector_state()->initiate_conc_mark_if_possible()) {
1635 // We had noticed on a previous pause that the heap occupancy has
1636 // gone over the initiating threshold and we should start a
1637 // concurrent marking cycle. So we might initiate one.
1638
1639 if (!about_to_start_mixed_phase() && collector_state()->gcs_are_young()) {
1640 // Initiate a new initial mark only if there is no marking or reclamation going
1641 // on.
1642
1643 collector_state()->set_during_initial_mark_pause(true);
1644 // And we can now clear initiate_conc_mark_if_possible() as
1645 // we've already acted on it.
1646 collector_state()->set_initiate_conc_mark_if_possible(false);
1647
1648 ergo_verbose0(ErgoConcCycles,
1649 "initiate concurrent cycle",
1650 ergo_format_reason("concurrent cycle initiation requested"));
1651 } else {
1652 // The concurrent marking thread is still finishing up the
1653 // previous cycle. If we start one right now the two cycles
1654 // overlap. In particular, the concurrent marking thread might
1655 // be in the process of clearing the next marking bitmap (which
1656 // we will use for the next cycle if we start one). Starting a
1657 // cycle now will be bad given that parts of the marking
1658 // information might get cleared by the marking thread. And we
1659 // cannot wait for the marking thread to finish the cycle as it
1660 // periodically yields while clearing the next marking bitmap
1661 // and, if it's in a yield point, it's waiting for us to
1662 // finish. So, at this point we will not start a cycle and we'll
1663 // let the concurrent marking thread complete the last one.
1664 ergo_verbose0(ErgoConcCycles,
1665 "do not initiate concurrent cycle",
1666 ergo_format_reason("concurrent cycle already in progress"));
1667 }
1668 }
1669 }
1670
|
1604 // even while we are still in the process of reclaiming memory.
1605 bool during_cycle = _g1->concurrent_mark()->cmThread()->during_cycle();
1606 if (!during_cycle) {
1607 ergo_verbose1(ErgoConcCycles,
1608 "request concurrent cycle initiation",
1609 ergo_format_reason("requested by GC cause")
1610 ergo_format_str("GC cause"),
1611 GCCause::to_string(gc_cause));
1612 collector_state()->set_initiate_conc_mark_if_possible(true);
1613 return true;
1614 } else {
1615 ergo_verbose1(ErgoConcCycles,
1616 "do not request concurrent cycle initiation",
1617 ergo_format_reason("concurrent cycle already in progress")
1618 ergo_format_str("GC cause"),
1619 GCCause::to_string(gc_cause));
1620 return false;
1621 }
1622 }
1623
1624 void G1CollectorPolicy::initiate_conc_mark() {
1625 collector_state()->set_during_initial_mark_pause(true);
1626 collector_state()->set_initiate_conc_mark_if_possible(false);
1627 }
1628
1629 void G1CollectorPolicy::decide_on_conc_mark_initiation() {
1630 // We are about to decide on whether this pause will be an
1631 // initial-mark pause.
1632
1633 // First, collector_state()->during_initial_mark_pause() should not be already set. We
1634 // will set it here if we have to. However, it should be cleared by
1635 // the end of the pause (it's only set for the duration of an
1636 // initial-mark pause).
1637 assert(!collector_state()->during_initial_mark_pause(), "pre-condition");
1638
1639 if (collector_state()->initiate_conc_mark_if_possible()) {
1640 // We had noticed on a previous pause that the heap occupancy has
1641 // gone over the initiating threshold and we should start a
1642 // concurrent marking cycle. So we might initiate one.
1643
1644 if (!about_to_start_mixed_phase() && collector_state()->gcs_are_young()) {
1645 // Initiate a new initial mark if there is no marking or reclamation going on.
1646 initiate_conc_mark();
1647 ergo_verbose0(ErgoConcCycles,
1648 "initiate concurrent cycle",
1649 ergo_format_reason("concurrent cycle initiation requested"));
1650 } else if (_g1->user_requested_concurrent_full_gc(_g1->gc_cause())) {
1651 // Initiate a user requested initial mark and update the collector state to
1652 // reflect this.
1653 collector_state()->set_gcs_are_young(true);
1654 collector_state()->set_last_young_gc(false);
1655
1656 initiate_conc_mark();
1657 ergo_verbose0(ErgoConcCycles,
1658 "initiate concurrent cycle",
1659 ergo_format_reason("user requested concurrent cycle"));
1660 } else {
1661 // The concurrent marking thread is still finishing up the
1662 // previous cycle. If we start one right now the two cycles
1663 // overlap. In particular, the concurrent marking thread might
1664 // be in the process of clearing the next marking bitmap (which
1665 // we will use for the next cycle if we start one). Starting a
1666 // cycle now will be bad given that parts of the marking
1667 // information might get cleared by the marking thread. And we
1668 // cannot wait for the marking thread to finish the cycle as it
1669 // periodically yields while clearing the next marking bitmap
1670 // and, if it's in a yield point, it's waiting for us to
1671 // finish. So, at this point we will not start a cycle and we'll
1672 // let the concurrent marking thread complete the last one.
1673 ergo_verbose0(ErgoConcCycles,
1674 "do not initiate concurrent cycle",
1675 ergo_format_reason("concurrent cycle already in progress"));
1676 }
1677 }
1678 }
1679
|