Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #23413 from luhenry/fix-gh22302-2
Browse files Browse the repository at this point in the history
Improve detection of CPU limits when running inside a Container
  • Loading branch information
janvorli authored Mar 25, 2019
2 parents 368639e + 06d7406 commit e6c49f7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/pal/src/misc/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,17 @@ PAL_GetLogicalCpuCountFromOS()
{
int nrcpus = 0;

#if HAVE_SYSCONF
#if HAVE_SCHED_GETAFFINITY

cpu_set_t cpuSet;
int st = sched_getaffinity(0, sizeof(cpu_set_t), &cpuSet);
if (st != 0)
{
ASSERT("sched_getaffinity failed (%d)\n", errno);
}

nrcpus = CPU_COUNT(&cpuSet);
#elif HAVE_SYSCONF

#if defined(_ARM_) || defined(_ARM64_)
#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_CONF
Expand Down

0 comments on commit e6c49f7

Please sign in to comment.