Mon, 30 Sep 2013 12:43:59 +0200
8025441: G1: assert "assert(thread < _num_vtimes) failed: just checking" fails when G1ConcRefinementThreads > ParallelGCThreads
Summary: The initialization for the remembered set summary data structures used the wrong thread count, i.e. number of worker threads instead of number of refinement threads.
Reviewed-by: brutisso
1.1 --- a/src/share/vm/gc_implementation/g1/g1RemSet.cpp Tue Sep 24 14:46:29 2013 +0200 1.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSet.cpp Mon Sep 30 12:43:59 2013 +0200 1.3 @@ -83,7 +83,9 @@ 1.4 for (uint i = 0; i < n_workers(); i++) { 1.5 _cset_rs_update_cl[i] = NULL; 1.6 } 1.7 - _prev_period_summary.initialize(this, n_workers()); 1.8 + if (G1SummarizeRSetStats) { 1.9 + _prev_period_summary.initialize(this); 1.10 + } 1.11 } 1.12 1.13 G1RemSet::~G1RemSet() { 1.14 @@ -728,7 +730,7 @@ 1.15 1.16 void G1RemSet::print_periodic_summary_info(const char* header) { 1.17 G1RemSetSummary current; 1.18 - current.initialize(this, n_workers()); 1.19 + current.initialize(this); 1.20 1.21 _prev_period_summary.subtract_from(¤t); 1.22 print_summary_info(&_prev_period_summary, header); 1.23 @@ -738,7 +740,7 @@ 1.24 1.25 void G1RemSet::print_summary_info() { 1.26 G1RemSetSummary current; 1.27 - current.initialize(this, n_workers()); 1.28 + current.initialize(this); 1.29 1.30 print_summary_info(¤t, " Cumulative RS summary"); 1.31 }
2.1 --- a/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp Tue Sep 24 14:46:29 2013 +0200 2.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp Mon Sep 30 12:43:59 2013 +0200 2.3 @@ -77,12 +77,12 @@ 2.4 return _rs_threads_vtimes[thread]; 2.5 } 2.6 2.7 -void G1RemSetSummary::initialize(G1RemSet* remset, uint num_workers) { 2.8 +void G1RemSetSummary::initialize(G1RemSet* remset) { 2.9 assert(_rs_threads_vtimes == NULL, "just checking"); 2.10 assert(remset != NULL, "just checking"); 2.11 2.12 _remset = remset; 2.13 - _num_vtimes = num_workers; 2.14 + _num_vtimes = ConcurrentG1Refine::thread_num(); 2.15 _rs_threads_vtimes = NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC); 2.16 memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes); 2.17
3.1 --- a/src/share/vm/gc_implementation/g1/g1RemSetSummary.hpp Tue Sep 24 14:46:29 2013 +0200 3.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSetSummary.hpp Mon Sep 30 12:43:59 2013 +0200 3.3 @@ -84,7 +84,7 @@ 3.4 void subtract_from(G1RemSetSummary* other); 3.5 3.6 // initialize and get the first sampling 3.7 - void initialize(G1RemSet* remset, uint num_workers); 3.8 + void initialize(G1RemSet* remset); 3.9 3.10 void print_on(outputStream* out); 3.11
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/test/gc/g1/TestSummarizeRSetStatsThreads.java Mon Sep 30 12:43:59 2013 +0200 4.3 @@ -0,0 +1,83 @@ 4.4 +/* 4.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.7 + * 4.8 + * This code is free software; you can redistribute it and/or modify it 4.9 + * under the terms of the GNU General Public License version 2 only, as 4.10 + * published by the Free Software Foundation. 4.11 + * 4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.15 + * version 2 for more details (a copy is included in the LICENSE file that 4.16 + * accompanied this code). 4.17 + * 4.18 + * You should have received a copy of the GNU General Public License version 4.19 + * 2 along with this work; if not, write to the Free Software Foundation, 4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.21 + * 4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4.23 + * or visit www.oracle.com if you need additional information or have any 4.24 + * questions. 4.25 + */ 4.26 + 4.27 +/* 4.28 + * @test TestSummarizeRSetStatsThreads 4.29 + * @bug 8025441 4.30 + * @summary Ensure that various values of worker threads/concurrent 4.31 + * refinement threads do not crash the VM. 4.32 + * @key gc 4.33 + * @library /testlibrary 4.34 + */ 4.35 + 4.36 +import java.util.regex.Matcher; 4.37 +import java.util.regex.Pattern; 4.38 + 4.39 +import com.oracle.java.testlibrary.ProcessTools; 4.40 +import com.oracle.java.testlibrary.OutputAnalyzer; 4.41 + 4.42 +public class TestSummarizeRSetStatsThreads { 4.43 + 4.44 + private static void runTest(int refinementThreads, int workerThreads) throws Exception { 4.45 + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", 4.46 + "-XX:+UnlockDiagnosticVMOptions", 4.47 + "-XX:+G1SummarizeRSetStats", 4.48 + "-XX:G1ConcRefinementThreads=" + refinementThreads, 4.49 + "-XX:ParallelGCThreads=" + workerThreads, 4.50 + "-version"); 4.51 + 4.52 + OutputAnalyzer output = new OutputAnalyzer(pb.start()); 4.53 + 4.54 + // check output to contain the string "Concurrent RS threads times (s)" followed by 4.55 + // the correct number of values in the next line. 4.56 + 4.57 + // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used. 4.58 + // Additionally use at least one thread. 4.59 + int expectedNumRefinementThreads = refinementThreads == 0 ? workerThreads : refinementThreads; 4.60 + expectedNumRefinementThreads = Math.max(1, expectedNumRefinementThreads); 4.61 + // create the pattern made up of n copies of a floating point number pattern 4.62 + String numberPattern = String.format("%0" + expectedNumRefinementThreads + "d", 0) 4.63 + .replace("0", "\\s+\\d+\\.\\d+"); 4.64 + String pattern = "Concurrent RS threads times \\(s\\)$" + numberPattern + "$"; 4.65 + Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout()); 4.66 + 4.67 + if (!m.find()) { 4.68 + throw new Exception("Could not find correct output for concurrent RS threads times in stdout," + 4.69 + " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout()); 4.70 + } 4.71 + output.shouldHaveExitValue(0); 4.72 + } 4.73 + 4.74 + public static void main(String[] args) throws Exception { 4.75 + if (!TestSummarizeRSetStatsTools.testingG1GC()) { 4.76 + return; 4.77 + } 4.78 + // different valid combinations of number of refinement and gc worker threads 4.79 + runTest(0, 0); 4.80 + runTest(0, 5); 4.81 + runTest(5, 0); 4.82 + runTest(10, 10); 4.83 + runTest(1, 2); 4.84 + runTest(4, 3); 4.85 + } 4.86 +}