Commit e79fa9f5 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-26467: Actually use spinloop on block_lock

In commit 277ba134
we accidentally omitted this.
parent d0d4ade9
......@@ -151,7 +151,7 @@ class ssux_lock_impl final
void wr_unlock();
#else
/** mutex for synchronization; held by U or X lock holders */
srw_mutex writer;
srw_mutex_impl<spinloop> writer;
/** S or U holders, and WRITER flag for X holder or waiter */
std::atomic<uint32_t> readers;
/** indicates an X request; readers=WRITER indicates granted X lock */
......
......@@ -417,7 +417,23 @@ void ssux_lock_impl<spinloop>::wr_wait(uint32_t lk)
DBUG_ASSERT(writer.is_locked());
DBUG_ASSERT(lk);
DBUG_ASSERT(lk < WRITER);
if (spinloop)
{
const unsigned delay= srw_pause_delay();
for (auto spin= srv_n_spin_wait_rounds; spin; spin--)
{
srw_pause(delay);
lk= readers.load(std::memory_order_acquire);
if (lk == WRITER)
return;
DBUG_ASSERT(lk > WRITER);
}
}
lk|= WRITER;
do
{
DBUG_ASSERT(lk > WRITER);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment