mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
MDEV-26720: rw_lock: Prefer fetch_sub() to fetch_and()
rw_lock::write_unlock(): Revert part of
commit d46b42489a
(MDEV-24142)
to make the IA-32 and AMD64 implementation faster.
This commit is contained in:
parent
d301cc8edb
commit
0144d1d2a6
1 changed files with 6 additions and 2 deletions
|
@ -196,8 +196,12 @@ public:
|
|||
/** Release an exclusive lock */
|
||||
void write_unlock()
|
||||
{
|
||||
IF_DBUG_ASSERT(auto l=,)
|
||||
lock.fetch_and(~WRITER, std::memory_order_release);
|
||||
/* Below, we use fetch_sub(WRITER) instead of fetch_and(~WRITER).
|
||||
The reason is that on IA-32 and AMD64 it translates into the 80486
|
||||
instruction LOCK XADD, while fetch_and() translates into a loop
|
||||
around LOCK CMPXCHG. For other ISA either form should be fine. */
|
||||
static_assert(WRITER == 1U << 31, "compatibility");
|
||||
IF_DBUG_ASSERT(auto l=,) lock.fetch_sub(WRITER, std::memory_order_release);
|
||||
/* the write lock must have existed */
|
||||
#ifdef SUX_LOCK_GENERIC
|
||||
DBUG_ASSERT((l & (WRITER | UPDATER)) == WRITER);
|
||||
|
|
Loading…
Reference in a new issue