diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-10-02 11:19:55 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-10-02 11:19:55 +0300 |
commit | d301cc8edb30dc6d8c03eee3650c230f760062bd (patch) | |
tree | 5e6c8e65eeb6fe5474de1a15dad31a50a17c92cf | |
parent | ec619a1def69c175d9fa07201b2567c3478e9408 (diff) | |
parent | 98a7fa0ce792408e964ea00cdc571197a513f217 (diff) | |
download | mariadb-git-d301cc8edb30dc6d8c03eee3650c230f760062bd.tar.gz |
Merge 10.5 into 10.6
-rw-r--r-- | storage/innobase/include/rw_lock.h | 15 | ||||
-rw-r--r-- | storage/innobase/sync/srw_lock.cc | 6 |
2 files changed, 17 insertions, 4 deletions
diff --git a/storage/innobase/include/rw_lock.h b/storage/innobase/include/rw_lock.h index cd176f0b35b..e2f7b6b9508 100644 --- a/storage/innobase/include/rw_lock.h +++ b/storage/innobase/include/rw_lock.h @@ -50,9 +50,22 @@ protected: static constexpr uint32_t UPDATER= 1U << 29; #endif /* SUX_LOCK_GENERIC */ + /** Start waiting for an exclusive lock. */ + void write_lock_wait_start() + { +#if defined __GNUC__ && (defined __i386__ || defined __x86_64__) + static_assert(WRITER_WAITING == 1U << 30, "compatibility"); + __asm__ __volatile__("lock btsl $30, %0" : "+m" (lock)); +#elif defined _MSC_VER && (defined _M_IX86 || defined _M_IX64) + static_assert(WRITER_WAITING == 1U << 30, "compatibility"); + _interlockedbittestandset(reinterpret_cast<volatile long*>(&lock), 30); +#else + lock.fetch_or(WRITER_WAITING, std::memory_order_relaxed); +#endif + } /** Start waiting for an exclusive lock. @return current value of the lock word */ - uint32_t write_lock_wait_start() + uint32_t write_lock_wait_start_read() { return lock.fetch_or(WRITER_WAITING, std::memory_order_relaxed); } /** Wait for an exclusive lock. @param l the value of the lock word diff --git a/storage/innobase/sync/srw_lock.cc b/storage/innobase/sync/srw_lock.cc index 7d26dd2b590..2e22a01eb8f 100644 --- a/storage/innobase/sync/srw_lock.cc +++ b/storage/innobase/sync/srw_lock.cc @@ -193,10 +193,10 @@ void ssux_lock_impl<spinloop>::write_lock(bool holding_u) { for (;;) { - uint32_t l= write_lock_wait_start(); + write_lock_wait_start(); const uint32_t e= holding_u ? WRITER_WAITING | UPDATER : WRITER_WAITING; - l= e; + uint32_t l= e; if (write_lock_wait_try(l)) return; @@ -213,7 +213,7 @@ void ssux_lock_impl<spinloop>::write_lock(bool holding_u) return; } - for (l= write_lock_wait_start() | WRITER_WAITING; + for (l= write_lock_wait_start_read() | WRITER_WAITING; (l | WRITER_WAITING) == e; ) if (write_lock_wait_try(l)) return; |