diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-06-26 11:16:40 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-06-26 11:16:40 +0300 |
commit | 759deaa0a22182353617c9fbff81f9f5fed25683 (patch) | |
tree | 6863b5373b55e2e795c219ee0b10ac3228b0d467 /include | |
parent | 5f22511e35674ecc376f4c56217ee2d78f92c772 (diff) | |
download | mariadb-git-759deaa0a22182353617c9fbff81f9f5fed25683.tar.gz |
MDEV-26010 fixup: Use acquire/release memory order
In commit 5f22511e35674ecc376f4c56217ee2d78f92c772 we depend on
Total Store Ordering. For correct operation on ISAs that implement
weaker memory ordering, we must explicitly use release/acquire stores
and loads on buf_page_t::oldest_modification_ to prevent a race condition
when buf_page_t::list does not happen to be on the same cache line.
buf_page_t::clear_oldest_modification(): Assert that the block is
not in buf_pool.flush_list, and use std::memory_order_release.
buf_page_t::oldest_modification_acquire(): Read oldest_modification_
with std::memory_order_acquire. In this way, if the return value is 0,
the caller may safely assume that it will not observe the buf_page_t
as being in buf_pool.flush_list, even if it is not holding
buf_pool.flush_list_mutex.
buf_flush_relocate_on_flush_list(), buf_LRU_free_page():
Invoke buf_page_t::oldest_modification_acquire().
Diffstat (limited to 'include')
-rw-r--r-- | include/my_atomic_wrapper.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/my_atomic_wrapper.h b/include/my_atomic_wrapper.h index d57559d360d..c5820b4f5b6 100644 --- a/include/my_atomic_wrapper.h +++ b/include/my_atomic_wrapper.h @@ -43,9 +43,10 @@ public: Type load(std::memory_order o= std::memory_order_relaxed) const { return m.load(o); } + void store(Type i, std::memory_order o= std::memory_order_relaxed) + { m.store(i, o); } operator Type() const { return m.load(); } - Type operator=(const Type val) - { m.store(val, std::memory_order_relaxed); return val; } + Type operator=(const Type i) { store(i); return i; } Type operator=(const Atomic_relaxed<Type> &rhs) { return *this= Type{rhs}; } Type fetch_add(const Type i, std::memory_order o= std::memory_order_relaxed) { return m.fetch_add(i, o); } |