Help with 8166811: Missing memory fences between memory allocation and refinement
Andrew Haley
aph at redhat.com
Mon Jan 18 11:43:47 UTC 2021
We're looking at backporting this to 8u.
However, the resulting patch was rather extensive, and I'm concerned
that backporting it requires a great deal of care.
Kim Barrett's initial comments suggest that, while not optimally
efficient, a couple of memory fences might do the job. From my
point of view this would be better because it cannot break anything.
However, I'm having some difficulty understanding Kim's comments.
My best guess follows. Is this what was intended?
All suggestions are very welcome.
index e787719fb1b..ccdd16c7390 100644
--- a/hotspot/src/share/vm/gc/g1/heapRegion.cpp
+++ b/hotspot/src/share/vm/gc/g1/heapRegion.cpp
@@ -413,6 +413,8 @@ bool HeapRegion::oops_on_card_seq_iterate_careful(MemRegion mr,
if (g1h->is_gc_active()) {
mr = mr.intersection(MemRegion(bottom(), scan_top()));
} else {
mr = mr.intersection(used_region());
}
if (mr.is_empty()) {
return true;
}
+ // LoadLoad/Acquire here?
+
// The intersection of the incoming mr (for the card) and the
// allocated part of the region is non-empty. This implies that
// we have actually allocated into this region. The code in
diff --git a/hotspot/src/share/vm/gc/g1/heapRegion.inline.hpp b/hotspot/src/share/vm/gc/g1/heapRegion.inline.hpp
index 01c53283579..72f9e8781cd 100644
--- a/hotspot/src/share/vm/gc/g1/heapRegion.inline.hpp
+++ b/hotspot/src/share/vm/gc/g1/heapRegion.inline.hpp
@@ -40,6 +40,9 @@ inline HeapWord* G1ContiguousSpace::allocate_impl(size_t min_word_size,
size_t want_to_allocate = MIN2(available, desired_word_size);
if (want_to_allocate >= min_word_size) {
HeapWord* new_top = obj + want_to_allocate;
+
+ // StoreStore/Release here?
+
set_top(new_top);
assert(is_aligned(obj) && is_aligned(new_top), "checking alignment");
*actual_size = want_to_allocate;
--
Andrew Haley (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the hotspot-gc-dev
mailing list