# HG changeset patch # Parent cd6a7dd8a17ad7394e9a5390f35b23d84840c719 # User tschatzl diff -r cd6a7dd8a17a src/share/vm/gc/g1/dirtyCardQueue.cpp --- a/src/share/vm/gc/g1/dirtyCardQueue.cpp Tue Feb 09 12:32:45 2016 +0100 +++ b/src/share/vm/gc/g1/dirtyCardQueue.cpp Tue Feb 09 13:05:46 2016 +0100 @@ -160,7 +160,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(CardTableEntryClosure* cl, diff -r cd6a7dd8a17a src/share/vm/gc/g1/g1ConcurrentMark.cpp --- a/src/share/vm/gc/g1/g1ConcurrentMark.cpp Tue Feb 09 12:32:45 2016 +0100 +++ b/src/share/vm/gc/g1/g1ConcurrentMark.cpp Tue Feb 09 13:05:46 2016 +0100 @@ -489,11 +489,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; diff -r cd6a7dd8a17a src/share/vm/runtime/os.cpp --- a/src/share/vm/runtime/os.cpp Tue Feb 09 12:32:45 2016 +0100 +++ b/src/share/vm/runtime/os.cpp Tue Feb 09 13:05:46 2016 +0100 @@ -68,6 +68,7 @@ uintptr_t os::_serialize_page_mask = 0; long os::_rand_seed = 1; int os::_processor_count = 0; +int os::_initial_active_processor_count = 0; size_t os::_page_sizes[os::page_sizes_max]; #ifndef PRODUCT @@ -1662,6 +1663,13 @@ } #endif +void os::set_processor_count(int count) { + assert(_processor_count == 0, "Trying to set processor count twice, from %d to %d", _processor_count, count); + _processor_count = count; + _initial_active_processor_count = active_processor_count(); + log_trace(os)("Initial active processor count is %d", _initial_active_processor_count); +} + /////////////// Unit tests /////////////// #ifndef PRODUCT diff -r cd6a7dd8a17a src/share/vm/runtime/os.hpp --- a/src/share/vm/runtime/os.hpp Tue Feb 09 12:32:45 2016 +0100 +++ b/src/share/vm/runtime/os.hpp Tue Feb 09 13:05:46 2016 +0100 @@ -237,12 +237,18 @@ static int processor_count() { return _processor_count; } - static void set_processor_count(int count) { _processor_count = count; } + static void set_processor_count(int count); // Returns the number of CPUs this process is currently allowed to run on. // Note that on some OSes this can change dynamically. static int active_processor_count(); + // At startup the number of active CPUs this process is allowed to run on. + // This value does not change dynamically. May be different to active_processor_count(). + static int initial_active_processor_count() { + return _initial_active_processor_count; + } + // Bind processes to processors. // This is a two step procedure: // first you generate a distribution of processes to processors, @@ -982,8 +988,9 @@ protected: - static long _rand_seed; // seed for random number generator - static int _processor_count; // number of processors + static long _rand_seed; // seed for random number generator + static int _processor_count; // number of processors + static int _initial_active_processor_count; // number of active processors during initialization. static char* format_boot_path(const char* format_string, const char* home, diff -r cd6a7dd8a17a src/share/vm/runtime/vm_version.cpp --- a/src/share/vm/runtime/vm_version.cpp Tue Feb 09 12:32:45 2016 +0100 +++ b/src/share/vm/runtime/vm_version.cpp Tue Feb 09 13:05:46 2016 +0100 @@ -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);