# HG changeset patch # User tschatzl # Date 1500297967 -7200 # Node ID dff06ff9effedf6ec5297df5794ae7f06c5a7dd4 # Parent bab8454fdbedc1327efedc73337fe09acccb7d2a 8183538: UpdateRS phase should claim cards Summary: Have the Update RS phase also claim cards so that they will not be rescanned later during Scan RS. Reviewed-by: ehelin, mgerdin diff -r bab8454fdbed -r dff06ff9effe hotspot/src/share/vm/gc/g1/g1RemSet.cpp --- a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp Mon Jul 17 12:11:32 2017 +0000 +++ b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp Mon Jul 17 15:26:07 2017 +0200 @@ -692,16 +692,17 @@ return; } - // During GC we can immediately clean the card since we will not re-enqueue stale - // cards as we know they can be disregarded. - *card_ptr = CardTableModRefBS::clean_card_val(); + // We claim lazily (so races are possible but they're benign), which reduces the + // number of potential duplicate scans (multiple threads may enqueue the same card twice). + *card_ptr = CardTableModRefBS::clean_card_val() | CardTableModRefBS::claimed_card_val(); // Construct the region representing the card. HeapWord* card_start = _ct_bs->addr_for(card_ptr); // And find the region containing it. - HeapRegion* r = _g1->heap_region_containing(card_start); + uint const card_region_idx = _g1->addr_to_region(card_start); - HeapWord* scan_limit = _scan_state->scan_top(r->hrm_index()); + _scan_state->add_dirty_region(card_region_idx); + HeapWord* scan_limit = _scan_state->scan_top(card_region_idx); if (scan_limit <= card_start) { // If the card starts above the area in the region containing objects to scan, skip it. return; @@ -713,8 +714,9 @@ MemRegion dirty_region(card_start, MIN2(scan_limit, card_end)); assert(!dirty_region.is_empty(), "sanity"); - update_rs_cl->set_region(r); - bool card_processed = r->oops_on_card_seq_iterate_careful(dirty_region, update_rs_cl); + HeapRegion* const card_region = _g1->region_at(card_region_idx); + update_rs_cl->set_region(card_region); + bool card_processed = card_region->oops_on_card_seq_iterate_careful(dirty_region, update_rs_cl); assert(card_processed, "must be"); }