Add 10_mimalloc_restrict_cpu_yield.patch to fix mimalloc armel build.
authorRyan Pavlik <ryan.pavlik@collabora.com>
Tue, 19 Jan 2021 19:58:49 +0000 (13:58 -0600)
committerRyan Pavlik <ryan.pavlik@collabora.com>
Thu, 21 Jan 2021 15:58:29 +0000 (09:58 -0600)
debian/patches/10_mimalloc_restrict_cpu_yield.patch [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/10_mimalloc_restrict_cpu_yield.patch b/debian/patches/10_mimalloc_restrict_cpu_yield.patch
new file mode 100644 (file)
index 0000000..c7b4ae8
--- /dev/null
@@ -0,0 +1,41 @@
+From: Ryan Pavlik <ryan.pavlik@collabora.com>
+Date: Tue, 19 Jan 2021 13:46:43 -0600
+Subject: Restricts cpu yield instructions a little.
+
+adding clobber for ARM and preventing older 32 bits chips not supporting this instruction.
+
+Backport of https://github.com/microsoft/mimalloc/commit/33a10b48605f8bb419487a03125815ad6ee00a70
+---
+ extlib/mimalloc/include/mimalloc-atomic.h | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/extlib/mimalloc/include/mimalloc-atomic.h b/extlib/mimalloc/include/mimalloc-atomic.h
+index 722b6ad..94010d4 100644
+--- a/extlib/mimalloc/include/mimalloc-atomic.h
++++ b/extlib/mimalloc/include/mimalloc-atomic.h
+@@ -267,16 +267,22 @@ static inline void mi_atomic_maxi64(volatile int64_t* p, int64_t x) {
+     std::this_thread::yield();
+   }
+ #elif (defined(__GNUC__) || defined(__clang__)) && \
+-      (defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__))
++      (defined(__x86_64__) || defined(__i386__) || (defined(__arm__) && __ARM_ARCH__ >= 7) || defined(__aarch64__))
+ #if defined(__x86_64__) || defined(__i386__)
+   static inline void mi_atomic_yield(void) {
+     asm volatile ("pause" ::: "memory");
+   }
+-#elif defined(__arm__) || defined(__aarch64__)
++#elif (defined(__arm__) && __ARM_ARCH__ >= 7) || defined(__aarch64__)
+   static inline void mi_atomic_yield(void) {
+-    asm volatile("yield");
++    __asm__ volatile("yield" ::: "memory");
+   }
+ #endif
++#elif defined(__sun)
++  // Fallback for other archs
++  #include <synch.h>
++  static inline void mi_atomic_yield(void) {
++    smt_pause();
++  }
+ #elif defined(__wasi__)
+   #include <sched.h>
+   static inline void mi_atomic_yield(void) {
index 1f205726b52aa6392aae106dcc4fd0c476c1cade..7cde63c3605f4ecefc110394ada357522e86ad59 100644 (file)
@@ -1 +1,2 @@
 01_RemoveGitHash.patch
+10_mimalloc_restrict_cpu_yield.patch