From f131b37c1ea625ba3717d0218ddf0cb4391530dd Mon Sep 17 00:00:00 2001 From: Egor Chesakov Date: Fri, 18 May 2018 15:03:00 -0700 Subject: [PATCH 1/2] Use sysconf(_SC_NPROCESSORS_CONF) instead of sysconf(_SC_NPROCESSORS_ONLN) in PAL and GC on ARM and ARM64 --- src/gc/unix/gcenv.unix.cpp | 8 +++++++- src/pal/src/misc/sysinfo.cpp | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/gc/unix/gcenv.unix.cpp b/src/gc/unix/gcenv.unix.cpp index 737c5efcf032..f34dd8993b28 100644 --- a/src/gc/unix/gcenv.unix.cpp +++ b/src/gc/unix/gcenv.unix.cpp @@ -40,6 +40,12 @@ #include // sysconf #include "globals.h" +#if defined(_ARM_) || defined(_ARM64_) +#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_CONF +#else +#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_ONLN +#endif + // The cachced number of logical CPUs observed. static uint32_t g_logicalCpuCount = 0; @@ -67,7 +73,7 @@ bool GCToOSInterface::Initialize() g_pageSizeUnixInl = uint32_t((pageSize > 0) ? pageSize : 0x1000); // Calculate and cache the number of processors on this machine - int cpuCount = sysconf(_SC_NPROCESSORS_ONLN); + int cpuCount = sysconf(SYSCONF_GET_NUMPROCS); if (cpuCount == -1) { return false; diff --git a/src/pal/src/misc/sysinfo.cpp b/src/pal/src/misc/sysinfo.cpp index bc55dadd4b14..495cc8bb94ea 100644 --- a/src/pal/src/misc/sysinfo.cpp +++ b/src/pal/src/misc/sysinfo.cpp @@ -103,10 +103,18 @@ PAL_GetLogicalCpuCountFromOS() int nrcpus = 0; #if HAVE_SYSCONF - nrcpus = sysconf(_SC_NPROCESSORS_ONLN); + +#if defined(_ARM_) || defined(_ARM64_) +#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_CONF +#define SYSCONF_GET_NUMPROCS_NAME "_SC_NPROCESSORS_CONF" +#else +#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_ONLN +#define SYSCONF_GET_NUMPROCS_NAME "_SC_NPROCESSORS_ONLN" +#endif + nrcpus = sysconf(SYSCONF_GET_NUMPROCS); if (nrcpus < 1) { - ASSERT("sysconf failed for _SC_NPROCESSORS_ONLN (%d)\n", errno); + ASSERT("sysconf failed for %s (%d)\n", SYSCONF_GET_NUMPROCS_NAME, errno); } #elif HAVE_SYSCTL int rc; From c0f8381635824919b9ec3a437b64f66e6a7e2e58 Mon Sep 17 00:00:00 2001 From: Egor Chesakov Date: Thu, 24 May 2018 06:08:26 -0700 Subject: [PATCH 2/2] Update g_highest_address and g_lowest_address in StompWriteBarrier(WriteBarrierOp::StompResize) on ARM (#18107) --- src/vm/gcenv.ee.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/vm/gcenv.ee.cpp b/src/vm/gcenv.ee.cpp index 5954b7b00cd4..4fb8dec6380a 100644 --- a/src/vm/gcenv.ee.cpp +++ b/src/vm/gcenv.ee.cpp @@ -879,11 +879,18 @@ void GCToEEInterface::StompWriteBarrier(WriteBarrierParameters* args) g_lowest_address = args->lowest_address; VolatileStore(&g_highest_address, args->highest_address); -#if defined(_ARM64_) +#if defined(_ARM64_) || defined(_ARM_) // Need to reupdate for changes to g_highest_address g_lowest_address is_runtime_suspended = (stompWBCompleteActions & SWB_EE_RESTART) || args->is_runtime_suspended; stompWBCompleteActions |= ::StompWriteBarrierResize(is_runtime_suspended, args->requires_upper_bounds_check); +#ifdef _ARM_ + if (stompWBCompleteActions & SWB_ICACHE_FLUSH) + { + ::FlushWriteBarrierInstructionCache(); + } +#endif + is_runtime_suspended = (stompWBCompleteActions & SWB_EE_RESTART) || args->is_runtime_suspended; if(!is_runtime_suspended) {