From ec711bf3110a93907e333b5d836f5f0f4f908f48 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Wed, 24 Jun 2020 11:22:36 +0000 Subject: [PATCH 1/2] support runtime LSE atomics detection for aarch64 Outline-atomics flag modifies builtin atomics to detect CPU support for atomic instructions in runtime, thus getting menefits of using LSE atomics without hurting compatibility. This flag has no effect if compiling for aarch64 >=v8.1. --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb0885f95e2..5beffe5adac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -866,6 +866,15 @@ ELSE() OPTION(USE_LD_GOLD "Use GNU gold linker" OFF) ENDIF() +#for aarch64 - allow dynamic use of LSE atomics +IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + MY_CHECK_CXX_COMPILER_FLAG( "-moutline-atomics" HAVE_OUTLINE_ATOMICS) + IF(HAVE_OUTLINE_ATOMICS) + STRING_APPEND(CMAKE_C_FLAGS " -moutline-atomics") + STRING_APPEND(CMAKE_CXX_FLAGS " -moutline-atomics") + ENDIF() +ENDIF() + IF(LINUX) OPTION(LINK_RANDOMIZE "Randomize the order of all symbols in the binary" OFF) SET(LINK_RANDOMIZE_SEED "mysql" From c4e5505fe410e3dbd2b76f011d6db3aa64aa9cef Mon Sep 17 00:00:00 2001 From: Tzachi Zidenberg Date: Tue, 4 Aug 2020 14:06:10 +0300 Subject: [PATCH 2/2] aarch64: support UT_RELAX_CPU macro an isb is a hardware block that produces some stall without using ALU or other CPU resources. It is fitting for this function. --- storage/innobase/include/ut0ut.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index 9cc98333517..dea092ded39 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -115,6 +115,8 @@ to memory). */ the YieldProcessor macro defined in WinNT.h. It is a CPU architecture- independent way by using YieldProcessor. */ #define UT_RELAX_CPU() YieldProcessor() +#elif defined(__aarch64__) +#define UT_RELAX_CPU() __asm__ __volatile__("isb" ::: "memory") #else #define UT_RELAX_CPU() __asm__ __volatile__("" ::: "memory") #endif