summaryrefslogtreecommitdiff
path: root/lib/scudo/scudo_tsd_shared.cpp
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2017-11-21 21:14:00 +0000
committerKostya Kortchinsky <kostyak@google.com>2017-11-21 21:14:00 +0000
commit8d1ef4a759edc138efdfab9c86047739fab8a536 (patch)
treecf71bb163e1b7ccb5ebc429352d6ce8661eeb0b9 /lib/scudo/scudo_tsd_shared.cpp
parentf5c4e6980b9a03990cbe80ce7eb85029fd9b37de (diff)
[scudo] Make getNumberOfCPUs Fuchsia compliant v2
Summary: This change allows Fuchsia to boot properly using the Scudo allocator. A first version of this commit was reverted by rL317834 because it broke Android builds for toolchains generated with older NDKs. This commit introduces a fall back to solve that issue. Reviewers: cryptoad, krytarowski, rnk, alekseyshl Reviewed By: cryptoad, krytarowski, alekseyshl Subscribers: llvm-commits, srhines, kubamracek, krytarowski Differential Revision: https://reviews.llvm.org/D40121 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/scudo/scudo_tsd_shared.cpp')
-rw-r--r--lib/scudo/scudo_tsd_shared.cpp9
1 files changed, 1 insertions, 8 deletions
diff --git a/lib/scudo/scudo_tsd_shared.cpp b/lib/scudo/scudo_tsd_shared.cpp
index 191c9ff13..3e13e5d3a 100644
--- a/lib/scudo/scudo_tsd_shared.cpp
+++ b/lib/scudo/scudo_tsd_shared.cpp
@@ -24,17 +24,10 @@ static atomic_uint32_t CurrentIndex;
static ScudoTSD *TSDs;
static u32 NumberOfTSDs;
-// sysconf(_SC_NPROCESSORS_{CONF,ONLN}) cannot be used as they allocate memory.
-static u32 getNumberOfCPUs() {
- cpu_set_t CPUs;
- CHECK_EQ(sched_getaffinity(0, sizeof(cpu_set_t), &CPUs), 0);
- return CPU_COUNT(&CPUs);
-}
-
static void initOnce() {
CHECK_EQ(pthread_key_create(&PThreadKey, NULL), 0);
initScudo();
- NumberOfTSDs = Min(Max(1U, getNumberOfCPUs()),
+ NumberOfTSDs = Min(Max(1U, GetNumberOfCPUsCached()),
static_cast<u32>(SCUDO_SHARED_TSD_POOL_SIZE));
TSDs = reinterpret_cast<ScudoTSD *>(
MmapOrDie(sizeof(ScudoTSD) * NumberOfTSDs, "ScudoTSDs"));