提交 aa9c4de1 编写于 作者: Y ysr

6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT

Summary: On sun4v/CMT avoid use of memset() in BOT updates so as to prevent concurrent BOT readers from seeing the phantom zeros arising from memset()'s use of BIS.
Reviewed-by: jmasa, johnc, minqi, poonam, tonyp
上级 d6e47e82
...@@ -104,6 +104,12 @@ void VM_Version::initialize() { ...@@ -104,6 +104,12 @@ void VM_Version::initialize() {
if (FLAG_IS_DEFAULT(OptoLoopAlignment)) { if (FLAG_IS_DEFAULT(OptoLoopAlignment)) {
FLAG_SET_DEFAULT(OptoLoopAlignment, 4); FLAG_SET_DEFAULT(OptoLoopAlignment, 4);
} }
// When using CMS, we cannot use memset() in BOT updates because
// the sun4v/CMT version in libc_psr uses BIS which exposes
// "phantom zeros" to concurrent readers. See 6948537.
if (FLAG_IS_DEFAULT(UseMemSetInBOT) && UseConcMarkSweepGC) {
FLAG_SET_DEFAULT(UseMemSetInBOT, false);
}
} }
// Use hardware population count instruction if available. // Use hardware population count instruction if available.
......
...@@ -789,6 +789,14 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen, ...@@ -789,6 +789,14 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen,
_gc_counters = new CollectorCounters("CMS", 1); _gc_counters = new CollectorCounters("CMS", 1);
_completed_initialization = true; _completed_initialization = true;
_inter_sweep_timer.start(); // start of time _inter_sweep_timer.start(); // start of time
#ifdef SPARC
// Issue a stern warning, but allow use for experimentation and debugging.
if (VM_Version::is_sun4v() && UseMemSetInBOT) {
assert(!FLAG_IS_DEFAULT(UseMemSetInBOT), "Error");
warning("Experimental flag -XX:+UseMemSetInBOT is known to cause instability"
" on sun4v; please understand that you are using at your own risk!");
}
#endif
} }
const char* ConcurrentMarkSweepGeneration::name() const { const char* ConcurrentMarkSweepGeneration::name() const {
......
...@@ -140,14 +140,38 @@ class BlockOffsetSharedArray: public CHeapObj { ...@@ -140,14 +140,38 @@ class BlockOffsetSharedArray: public CHeapObj {
"right address out of range"); "right address out of range");
assert(left < right, "Heap addresses out of order"); assert(left < right, "Heap addresses out of order");
size_t num_cards = pointer_delta(right, left) >> LogN_words; size_t num_cards = pointer_delta(right, left) >> LogN_words;
// Below, we may use an explicit loop instead of memset()
// because on certain platforms memset() can give concurrent
// readers "out-of-thin-air," phantom zeros; see 6948537.
if (UseMemSetInBOT) {
memset(&_offset_array[index_for(left)], offset, num_cards); memset(&_offset_array[index_for(left)], offset, num_cards);
} else {
size_t i = index_for(left);
const size_t end = i + num_cards;
for (; i < end; i++) {
_offset_array[i] = offset;
}
}
} }
void set_offset_array(size_t left, size_t right, u_char offset) { void set_offset_array(size_t left, size_t right, u_char offset) {
assert(right < _vs.committed_size(), "right address out of range"); assert(right < _vs.committed_size(), "right address out of range");
assert(left <= right, "indexes out of order"); assert(left <= right, "indexes out of order");
size_t num_cards = right - left + 1; size_t num_cards = right - left + 1;
// Below, we may use an explicit loop instead of memset
// because on certain platforms memset() can give concurrent
// readers "out-of-thin-air," phantom zeros; see 6948537.
if (UseMemSetInBOT) {
memset(&_offset_array[left], offset, num_cards); memset(&_offset_array[left], offset, num_cards);
} else {
size_t i = left;
const size_t end = i + num_cards;
for (; i < end; i++) {
_offset_array[i] = offset;
}
}
} }
void check_offset_array(size_t index, HeapWord* high, HeapWord* low) const { void check_offset_array(size_t index, HeapWord* high, HeapWord* low) const {
......
...@@ -327,6 +327,10 @@ class CommandLineFlags { ...@@ -327,6 +327,10 @@ class CommandLineFlags {
product(bool, UseMembar, false, \ product(bool, UseMembar, false, \
"(Unstable) Issues membars on thread state transitions") \ "(Unstable) Issues membars on thread state transitions") \
\ \
/* Temporary: See 6948537 */ \
experimental(bool, UseMemSetInBOT, true, \
"(Unstable) uses memset in BOT updates in GC code") \
\
diagnostic(bool, UnlockDiagnosticVMOptions, trueInDebug, \ diagnostic(bool, UnlockDiagnosticVMOptions, trueInDebug, \
"Enable normal processing of flags relating to field diagnostics")\ "Enable normal processing of flags relating to field diagnostics")\
\ \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册