diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2019-04-09 02:50:28 +0200 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2019-04-09 03:16:24 +0200 |
commit | cee1a8c9d9c6669318d1567c85457fbcd642587d (patch) | |
tree | e0e0b374dba2d35ce9bf3a4696f53625efce19f9 | |
parent | 060990945a0117cb824b9d1c1e6c3a336533a3ee (diff) | |
download | coreclr-cee1a8c9d9c6669318d1567c85457fbcd642587d.tar.gz coreclr-cee1a8c9d9c6669318d1567c85457fbcd642587d.tar.bz2 coreclr-cee1a8c9d9c6669318d1567c85457fbcd642587d.zip |
Fix several issues
* Fix build on OSX and Linux machines without NUMA installed - there were
couple of places where I was missing ifdefs
* Fix bug in nodeMaskLength computation
* Remove testing change in eeconfig.cpp that has leaked into the PR
* Fix GCToOSInterface::GetTotalProcessorCount for embedded GC to return
all processors on the system, not just the ones enabled for the current
process.
-rw-r--r-- | src/dlls/mscordac/mscordac_unixexports.src | 1 | ||||
-rw-r--r-- | src/gc/unix/gcenv.unix.cpp | 5 | ||||
-rw-r--r-- | src/pal/inc/pal.h | 5 | ||||
-rw-r--r-- | src/pal/src/include/pal/palinternal.h | 3 | ||||
-rw-r--r-- | src/pal/src/misc/sysinfo.cpp | 6 | ||||
-rw-r--r-- | src/pal/src/numa/numa.cpp | 11 | ||||
-rw-r--r-- | src/pal/src/thread/thread.cpp | 8 | ||||
-rw-r--r-- | src/vm/eeconfig.cpp | 2 | ||||
-rw-r--r-- | src/vm/gcenv.os.cpp | 2 |
9 files changed, 21 insertions, 22 deletions
diff --git a/src/dlls/mscordac/mscordac_unixexports.src b/src/dlls/mscordac/mscordac_unixexports.src index 3709d55356..9902cb6bb6 100644 --- a/src/dlls/mscordac/mscordac_unixexports.src +++ b/src/dlls/mscordac/mscordac_unixexports.src @@ -123,7 +123,6 @@ nativeStringResourceTable_mscorrc_debug #GetLongPathNameW #GetModuleFileNameW #GetProcAddress -#GetProcessAffinityMask #GetProcessHeap #GetShortPathNameW #GetStdHandle diff --git a/src/gc/unix/gcenv.unix.cpp b/src/gc/unix/gcenv.unix.cpp index a6d56f2433..105a9582e7 100644 --- a/src/gc/unix/gcenv.unix.cpp +++ b/src/gc/unix/gcenv.unix.cpp @@ -573,7 +573,7 @@ bool GCToOSInterface::VirtualCommit(void* address, size_t size, uint16_t node) { if ((int)node <= g_highestNumaNode) { - int nodeMaskLength = (g_highestNumaNode + 1 + sizeof(unsigned long) - 1) / sizeof(unsigned long); + int nodeMaskLength = (g_highestNumaNode + sizeof(unsigned long) - 1) / sizeof(unsigned long); unsigned long *nodeMask = (unsigned long*)alloca(nodeMaskLength * sizeof(unsigned long)); memset(nodeMask, 0, nodeMaskLength); @@ -916,13 +916,14 @@ bool GCToOSInterface::GetProcessorForHeap(uint16_t heap_number, uint16_t* proc_n if (availableProcNumber == heap_number) { *proc_no = procNumber; - +#if HAVE_NUMA_H if (GCToOSInterface::CanEnableGCNumaAware()) { int result = numa_node_of_cpu(procNumber); *node_no = (result >= 0) ? (uint16_t)result : NUMA_NODE_UNDEFINED; } else +#endif // HAVE_NUMA_H { *node_no = NUMA_NODE_UNDEFINED; } diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h index 79bc677830..f4a726e89f 100644 --- a/src/pal/inc/pal.h +++ b/src/pal/inc/pal.h @@ -2450,6 +2450,11 @@ PALAPI PAL_GetLogicalCpuCountFromOS(VOID); PALIMPORT +DWORD +PALAPI +PAL_GetTotalCpuCount(VOID); + +PALIMPORT size_t PALAPI PAL_GetRestrictedPhysicalMemoryLimit(VOID); diff --git a/src/pal/src/include/pal/palinternal.h b/src/pal/src/include/pal/palinternal.h index 6f64208e05..67236aaa49 100644 --- a/src/pal/src/include/pal/palinternal.h +++ b/src/pal/src/include/pal/palinternal.h @@ -679,9 +679,6 @@ typedef enum _TimeConversionConstants bool ReadMemoryValueFromFile(const char* filename, size_t* val); -DWORD -GetTotalCpuCount(); - #ifdef __APPLE__ bool GetApplicationContainerFolder(PathCharString& buffer, const char *applicationGroupId, int applicationGroupIdLength); diff --git a/src/pal/src/misc/sysinfo.cpp b/src/pal/src/misc/sysinfo.cpp index 419c3f6708..1a1a12f02f 100644 --- a/src/pal/src/misc/sysinfo.cpp +++ b/src/pal/src/misc/sysinfo.cpp @@ -95,7 +95,9 @@ SET_DEFAULT_DEBUG_CHANNEL(MISC); #endif #endif // __APPLE__ -DWORD GetTotalCpuCount() +DWORD +PALAPI +PAL_GetTotalCpuCount() { int nrcpus = 0; @@ -150,7 +152,7 @@ PAL_GetLogicalCpuCountFromOS() nrcpus = CPU_COUNT(&cpuSet); #else // HAVE_SCHED_GETAFFINITY - nrcpus = GetTotalCpuCount(); + nrcpus = PAL_GetTotalCpuCount(); #endif // HAVE_SCHED_GETAFFINITY return nrcpus; diff --git a/src/pal/src/numa/numa.cpp b/src/pal/src/numa/numa.cpp index 0c9d4090a5..aabb800bac 100644 --- a/src/pal/src/numa/numa.cpp +++ b/src/pal/src/numa/numa.cpp @@ -25,11 +25,6 @@ SET_DEFAULT_DEBUG_CHANNEL(NUMA); #include "pal/corunix.hpp" #include "pal/thread.hpp" -#if HAVE_PTHREAD_NP_H -#include <pthread_np.h> -#endif - -#include <pthread.h> #include <dlfcn.h> #ifdef __FreeBSD__ #include <stdlib.h> @@ -43,10 +38,6 @@ SET_DEFAULT_DEBUG_CHANNEL(NUMA); using namespace CorUnix; -#if HAVE_CPUSET_T -typedef cpuset_t cpu_set_t; -#endif - // The highest NUMA node available int g_highestNumaNode = 0; // Is numa available @@ -213,7 +204,7 @@ VirtualAllocExNuma( #if HAVE_NUMA_H if (result != NULL && g_numaAvailable) { - int nodeMaskLength = (g_highestNumaNode + 1 + sizeof(unsigned long) - 1) / sizeof(unsigned long); + int nodeMaskLength = (g_highestNumaNode + sizeof(unsigned long) - 1) / sizeof(unsigned long); unsigned long *nodeMask = (unsigned long*)alloca(nodeMaskLength * sizeof(unsigned long)); memset(nodeMask, 0, nodeMaskLength); diff --git a/src/pal/src/thread/thread.cpp b/src/pal/src/thread/thread.cpp index 122e86014c..ecbf7251cd 100644 --- a/src/pal/src/thread/thread.cpp +++ b/src/pal/src/thread/thread.cpp @@ -77,6 +77,10 @@ SET_DEFAULT_DEBUG_CHANNEL(THREAD); // some headers have code with asserts, so do extern "C" int _lwp_self (); #endif +#if HAVE_CPUSET_T +typedef cpuset_t cpu_set_t; +#endif + using namespace CorUnix; @@ -2977,16 +2981,16 @@ BOOL PALAPI PAL_GetCurrentThreadAffinitySet(SIZE_T size, UINT_PTR* data) { +#if HAVE_PTHREAD_GETAFFINITY_NP cpu_set_t cpuSet; CPU_ZERO(&cpuSet); -#if HAVE_PTHREAD_GETAFFINITY_NP int st = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuSet); if (st == 0) { const SIZE_T BitsPerBitsetEntry = 8 * sizeof(UINT_PTR); - int nrcpus = GetTotalCpuCount(); + int nrcpus = PAL_GetTotalCpuCount(); // Get info for as much processors as it is possible to fit into the resulting set SIZE_T remainingCount = std::min(size * BitsPerBitsetEntry, (SIZE_T)nrcpus); diff --git a/src/vm/eeconfig.cpp b/src/vm/eeconfig.cpp index 6bd0eddf2b..9cb07fc2e8 100644 --- a/src/vm/eeconfig.cpp +++ b/src/vm/eeconfig.cpp @@ -1228,7 +1228,7 @@ HRESULT EEConfig::sync() CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_TC_StartupTier_CallCountingDelayMs); #ifndef FEATURE_PAL - bool hadSingleProcessorAtStartup = g_SystemInfo.dwNumberOfProcessors == 1;//CPUGroupInfo::HadSingleProcessorAtStartup(); + bool hadSingleProcessorAtStartup = CPUGroupInfo::HadSingleProcessorAtStartup(); #else // !FEATURE_PAL bool hadSingleProcessorAtStartup = g_SystemInfo.dwNumberOfProcessors == 1; #endif // !FEATURE_PAL diff --git a/src/vm/gcenv.os.cpp b/src/vm/gcenv.os.cpp index 8f9e1ba1bb..2334d95be5 100644 --- a/src/vm/gcenv.os.cpp +++ b/src/vm/gcenv.os.cpp @@ -928,7 +928,7 @@ uint32_t GCToOSInterface::GetTotalProcessorCount() return g_SystemInfo.dwNumberOfProcessors; } #else // !FEATURE_PAL - return g_currentProcessCpuCount; + return PAL_GetTotalCpuCount(); #endif // !FEATURE_PAL } |