* 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.
Commit migrated from https://github.com/dotnet/coreclr/commit/
cee1a8c9d9c6669318d1567c85457fbcd642587d
#GetLongPathNameW
#GetModuleFileNameW
#GetProcAddress
-#GetProcessAffinityMask
#GetProcessHeap
#GetShortPathNameW
#GetStdHandle
{
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);
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;
}
PAL_GetLogicalCpuCountFromOS(VOID);
PALIMPORT
+DWORD
+PALAPI
+PAL_GetTotalCpuCount(VOID);
+
+PALIMPORT
size_t
PALAPI
PAL_GetRestrictedPhysicalMemoryLimit(VOID);
bool
ReadMemoryValueFromFile(const char* filename, size_t* val);
-DWORD
-GetTotalCpuCount();
-
#ifdef __APPLE__
bool
GetApplicationContainerFolder(PathCharString& buffer, const char *applicationGroupId, int applicationGroupIdLength);
#endif
#endif // __APPLE__
-DWORD GetTotalCpuCount()
+DWORD
+PALAPI
+PAL_GetTotalCpuCount()
{
int nrcpus = 0;
nrcpus = CPU_COUNT(&cpuSet);
#else // HAVE_SCHED_GETAFFINITY
- nrcpus = GetTotalCpuCount();
+ nrcpus = PAL_GetTotalCpuCount();
#endif // HAVE_SCHED_GETAFFINITY
return nrcpus;
#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>
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
#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);
extern "C" int _lwp_self ();
#endif
+#if HAVE_CPUSET_T
+typedef cpuset_t cpu_set_t;
+#endif
+
using namespace CorUnix;
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);
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
return g_SystemInfo.dwNumberOfProcessors;
}
#else // !FEATURE_PAL
- return g_currentProcessCpuCount;
+ return PAL_GetTotalCpuCount();
#endif // !FEATURE_PAL
}