changeset 6543:bb6a7cb5339b

8161993: G1 crashes if active_processor_count changes during startup Summary: Use the initial active processor count for memory initialization instead of the current active one. Reviewed-by: dholmes, mgerdin
author tschatzl
date Wed, 19 Apr 2017 04:27:50 +0100
parents 935f879e4eb0
children 8745b05c4772
files src/share/vm/gc_implementation/g1/concurrentMark.cpp src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp src/share/vm/runtime/vm_version.cpp
diffstat 3 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed Apr 19 04:15:53 2017 +0100
+++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed Apr 19 04:27:50 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -545,11 +545,10 @@
       double overall_cm_overhead =
         (double) MaxGCPauseMillis * marking_overhead /
         (double) GCPauseIntervalMillis;
-      double cpu_ratio = 1.0 / (double) os::processor_count();
+      double cpu_ratio = 1.0 / os::initial_active_processor_count();
       double marking_thread_num = ceil(overall_cm_overhead / cpu_ratio);
       double marking_task_overhead =
-        overall_cm_overhead / marking_thread_num *
-                                                (double) os::processor_count();
+        overall_cm_overhead / marking_thread_num * os::initial_active_processor_count();
       double sleep_factor =
                          (1.0 - marking_task_overhead) / marking_task_overhead;
 
--- a/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp	Wed Apr 19 04:15:53 2017 +0100
+++ b/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp	Wed Apr 19 04:27:50 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -94,7 +94,7 @@
 
 // Determines how many mutator threads can process the buffers in parallel.
 uint DirtyCardQueueSet::num_par_ids() {
-  return (uint)os::processor_count();
+  return (uint)os::initial_active_processor_count();
 }
 
 void DirtyCardQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
--- a/src/share/vm/runtime/vm_version.cpp	Wed Apr 19 04:15:53 2017 +0100
+++ b/src/share/vm/runtime/vm_version.cpp	Wed Apr 19 04:27:50 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -294,7 +294,7 @@
     // processor after the first 8.  For example, on a 72 cpu machine
     // and a chosen fraction of 5/8
     // use 8 + (72 - 8) * (5/8) == 48 worker threads.
-    unsigned int ncpus = (unsigned int) os::active_processor_count();
+    unsigned int ncpus = (unsigned int) os::initial_active_processor_count();
     return (ncpus <= switch_pt) ?
            ncpus :
           (switch_pt + ((ncpus - switch_pt) * num) / den);