From: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 6 Jan 2022 18:46:06 +0000 (-0800) Subject: Unify the FlushProcessWriteBuffers mechanism for macOS arm64 / x64 (#63301) X-Git-Tag: accepted/tizen/unified/20221103.165808~242^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b71484cd261a6f3ae7ede71d253c2c9cd3e92b7d;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Unify the FlushProcessWriteBuffers mechanism for macOS arm64 / x64 (#63301) The macOS arm64 was using a new mechanism to implement FlushProcessWriteBuffers because the original one based on a wired memory page doesn't work on arm64. We have seen people hitting problems with the wired memory page allocation on x64 in the past due to the fact that wired memory is a scarce resource and in some cases, e.g. in presence of apps that greedily grab all of the available wired memory pages, we were unable to initialize coreclr and execute any .NET application. This change switches x64 to the same mechanism as arm64 to prevent that issue from happening and updates the minimum supported x64 macOS to 10.14. That's the version required for the new APIs the change is using. Apple stopped supporting 10.13 a year ago anyways. Co-authored-by: Jan Vorlicek --- diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 502d432..c6f4a6a 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -420,7 +420,7 @@ if (CLR_CMAKE_HOST_UNIX) set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0") add_compile_options(-arch arm64) elseif(CLR_CMAKE_HOST_ARCH_AMD64) - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13") + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14") add_compile_options(-arch x86_64) else() clr_unknown_arch() diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 2a37c17..6319c51 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -67,7 +67,6 @@ #include #include -#if defined(HOST_ARM64) #include #include extern "C" @@ -84,7 +83,6 @@ extern "C" abort(); \ } \ } while (false) -#endif // defined(HOST_ARM64) #endif // __APPLE__ @@ -372,7 +370,7 @@ bool GCToOSInterface::Initialize() { s_flushUsingMemBarrier = TRUE; } -#if !(defined(TARGET_OSX) && defined(HOST_ARM64)) +#ifndef TARGET_OSX else { assert(g_helperPage == 0); @@ -404,7 +402,7 @@ bool GCToOSInterface::Initialize() return false; } } -#endif // !(defined(TARGET_OSX) && defined(HOST_ARM64)) +#endif // !TARGET_OSX InitializeCGroup(); @@ -544,7 +542,7 @@ void GCToOSInterface::FlushProcessWriteBuffers() status = pthread_mutex_unlock(&g_flushProcessWriteBuffersMutex); assert(status == 0 && "Failed to unlock the flushProcessWriteBuffersMutex lock"); } -#if defined(TARGET_OSX) && defined(HOST_ARM64) +#ifdef TARGET_OSX else { mach_msg_type_number_t cThreads; @@ -570,7 +568,7 @@ void GCToOSInterface::FlushProcessWriteBuffers() machret = vm_deallocate(mach_task_self(), (vm_address_t)pThreads, cThreads * sizeof(thread_act_t)); CHECK_MACH("vm_deallocate()", machret); } -#endif // defined(TARGET_OSX) && defined(HOST_ARM64) +#endif // TARGET_OSX } // Break into a debugger. Uses a compiler intrinsic if one is available, diff --git a/src/coreclr/pal/src/thread/process.cpp b/src/coreclr/pal/src/thread/process.cpp index 2b349a6..f31449f 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -85,7 +85,6 @@ SET_DEFAULT_DEBUG_CHANNEL(PROCESS); // some headers have code with asserts, so d #include #include #include -#if defined(HOST_ARM64) #include #include extern "C" @@ -103,7 +102,6 @@ extern "C" } \ } while (false) -#endif // defined(HOST_ARM64) #endif // __APPLE__ #ifdef __NetBSD__ @@ -3472,7 +3470,7 @@ InitializeFlushProcessWriteBuffers() } } -#if defined(TARGET_OSX) && defined(HOST_ARM64) +#ifdef TARGET_OSX return TRUE; #else s_helperPage = static_cast(mmap(0, GetVirtualPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)); @@ -3502,7 +3500,7 @@ InitializeFlushProcessWriteBuffers() } return status == 0; -#endif // defined(TARGET_OSX) && defined(HOST_ARM64) +#endif // TARGET_OSX } #define FATAL_ASSERT(e, msg) \ @@ -3552,7 +3550,7 @@ FlushProcessWriteBuffers() status = pthread_mutex_unlock(&flushProcessWriteBuffersMutex); FATAL_ASSERT(status == 0, "Failed to unlock the flushProcessWriteBuffersMutex lock"); } -#if defined(TARGET_OSX) && defined(HOST_ARM64) +#ifdef TARGET_OSX else { mach_msg_type_number_t cThreads; @@ -3578,7 +3576,7 @@ FlushProcessWriteBuffers() machret = vm_deallocate(mach_task_self(), (vm_address_t)pThreads, cThreads * sizeof(thread_act_t)); CHECK_MACH("vm_deallocate()", machret); } -#endif // defined(TARGET_OSX) && defined(HOST_ARM64) +#endif // TARGET_OSX } /*++