MDEV-34178: Simplify the U lock
The U lock mode of the sux_lock that was introduced in commit 03ca6495 (MDEV-24142) is unnecessarily complex. Internally, sux_lock comprises two parts, each with their own wait queue inside the operating system kernel: a mutex and a rw-lock. We can map the operations as follows: x_lock(): (X,X) u_lock(): (X,_) s_lock(): (_,S) The Update lock mode, which is mutually exclusive with itself and with X (exclusive) locks but not with shared (S) locks, was unnecessarily acquiring a shared lock on the second component. The mutual exclusion is guaranteed by the first component. We might simplify the #ifdef SUX_LOCK_GENERIC case further by omitting srw_mutex_impl::lock, because it is kind-of duplicating the mutex that we will use for having a wait queue. However, the predicate buf_page_t::can_relocate() would depend on the predicate is_locked_or_waiting(), which is not available for pthread_mutex_t. Reviewed by: Debarun Banerjee Tested by: Matthias Leich
Showing
Please register or sign in to comment