# HG changeset patch # User rkennke # Date 1478702729 -3600 # Wed Nov 09 15:45:29 2016 +0100 # Node ID 85ec919f4e30693dc42748cdfde5c700f38463dd # Parent c8138d5377a44ccbab3ea757e16d8ca58d16c23a [mq]: cancel.patch diff --git a/src/share/vm/gc/shenandoah/shenandoahConcurrentMark.cpp b/src/share/vm/gc/shenandoah/shenandoahConcurrentMark.cpp --- a/src/share/vm/gc/shenandoah/shenandoahConcurrentMark.cpp +++ b/src/share/vm/gc/shenandoah/shenandoahConcurrentMark.cpp @@ -882,14 +882,21 @@ ParallelTaskTerminator* terminator) { ShenandoahHeap* heap = ShenandoahHeap::heap(); int seed = 17; - while (true) { - if (heap->cancelled_concgc()) clear_queue(q); - if (heap->cancelled_concgc() || - (!try_queue(q, cl) && - !try_draining_an_satb_buffer(q) && - !try_to_steal(worker_id, cl, &seed)) - ) { - if (terminator->offer_termination()) break; + bool terminate = false; + uint stride = ShenandoahMarkLoopStride; + while (! terminate) { + if (heap->cancelled_concgc()) { + clear_queue(q); + while (! terminator->offer_termination()); + return; + } + for (uint i = 0; i < stride && ! terminate; i++) { + if (!try_queue(q, cl) && + !try_draining_an_satb_buffer(q) && + !try_to_steal(worker_id, cl, &seed) + ) { + if (terminator->offer_termination()) terminate = true; + } } } } diff --git a/src/share/vm/gc/shenandoah/shenandoahHeap.cpp b/src/share/vm/gc/shenandoah/shenandoahHeap.cpp --- a/src/share/vm/gc/shenandoah/shenandoahHeap.cpp +++ b/src/share/vm/gc/shenandoah/shenandoahHeap.cpp @@ -2052,8 +2052,7 @@ // only report it once if (!_cancelled_concgc) { log_info(gc)("Cancelling GC"); - _cancelled_concgc = true; - OrderAccess::fence(); + OrderAccess::release_store(&_cancelled_concgc, true); _shenandoah_policy->report_concgc_cancelled(); } diff --git a/src/share/vm/gc/shenandoah/shenandoahHeap.hpp b/src/share/vm/gc/shenandoah/shenandoahHeap.hpp --- a/src/share/vm/gc/shenandoah/shenandoahHeap.hpp +++ b/src/share/vm/gc/shenandoah/shenandoahHeap.hpp @@ -124,7 +124,7 @@ HeapWord** _top_at_mark_starts; HeapWord** _top_at_mark_starts_base; - bool _cancelled_concgc; + volatile jbyte _cancelled_concgc; jbyte _growing_heap; diff --git a/src/share/vm/gc/shenandoah/shenandoahHeap.inline.hpp b/src/share/vm/gc/shenandoah/shenandoahHeap.inline.hpp --- a/src/share/vm/gc/shenandoah/shenandoahHeap.inline.hpp +++ b/src/share/vm/gc/shenandoah/shenandoahHeap.inline.hpp @@ -188,7 +188,7 @@ } inline bool ShenandoahHeap::cancelled_concgc() const { - bool cancelled = _cancelled_concgc; + bool cancelled = (bool) OrderAccess::load_acquire((jbyte*) &_cancelled_concgc); return cancelled; } diff --git a/src/share/vm/gc/shenandoah/shenandoah_globals.hpp b/src/share/vm/gc/shenandoah/shenandoah_globals.hpp --- a/src/share/vm/gc/shenandoah/shenandoah_globals.hpp +++ b/src/share/vm/gc/shenandoah/shenandoah_globals.hpp @@ -101,6 +101,9 @@ "(ignored otherwise). Defauls to 0%.") \ range(0,100) \ \ + experimental(uint, ShenandoahMarkLoopStride, 1000, \ + "How many items are processed during one marking step") \ + \ experimental(bool, ShenandoahConcurrentCodeRoots, false, \ "Scan code roots concurrently, instead of during a pause") \ \