<html>
  <head>
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi all,<br>
    <br>
    Please, review this patch to
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
    move the code to determine the number of used workers out of
    CollectionSetChooser::prepare_for_par_region_addition and up to
    G1CollectorPolicy::record_concurrent_mark_cleanup_end, where the
    worker threads are started. <br>
    <br>
    <a class="moz-txt-link-freetext"
      href="http://cr.openjdk.java.net/%7Estefank/8080837">http://cr.openjdk.java.net/~stefank/8080837</a><br>
    <a class="moz-txt-link-freetext"
      href="https://bugs.openjdk.java.net/browse/JDK-8080837">https://bugs.openjdk.java.net/browse/JDK-8080837</a><br>
    <br>
    The patch also remove the redundant calculation of n_threads:<br>
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
    <pre><span class="removed">-  uint n_threads = (uint) ParallelGCThreads;</span>
<span class="removed">-  if (UseDynamicNumberOfGCThreads) {</span>
<span class="removed">-    assert(G1CollectedHeap::heap()->workers()->active_workers() > 0,</span>
<span class="removed">-      "Should have been set earlier");</span>
<span class="removed">-    // This is defensive code. As the assertion above says, the number</span>
<span class="removed">-    // of active threads should be > 0, but in case there is some path</span>
<span class="removed">-    // or some improperly initialized variable with leads to no</span>
<span class="removed">-    // active threads, protect against that in a product build.</span>
<span class="removed">-    n_threads = MAX2(G1CollectedHeap::heap()->workers()->active_workers(),</span>
<span class="removed">-                     1U);</span>
<span class="removed">-  }

</span></pre>
    since that logic is already present in the setup code of G1's
    FlexibleWorkGang:<br>
      _workers = new FlexibleWorkGang("GC Thread", ParallelGCThreads,<br>
                              /* are_GC_task_threads */true,<br>
                              /* are_ConcurrentGC_threads */false);<br>
    <br>
    and FlexibleWorkGang::set_active_workers:<br>
      void set_active_workers(uint v) {<br>
        assert(v <= _total_workers,<br>
               "Trying to set more workers active than there are");<br>
        _active_workers = MIN2(v, _total_workers);<br>
        assert(v != 0, "Trying to set active workers to 0");<br>
        _active_workers = MAX2(1U, _active_workers);<br>
        assert(UseDynamicNumberOfGCThreads || _active_workers ==
    _total_workers,<br>
               "Unless dynamic should use total workers");<br>
      }<br>
    <br>
    which is called at the previous collection pause.<br>
    <br>
    Thanks,<br>
    StefanK<br>
  </body>
</html>