Skip to content

Commit bb7e84b

Browse files
committed
MDEV-11296 - InnoDB stalls under OLTP RW on P8
Simplified away rw_lock_lock_word_incr().
1 parent e06e455 commit bb7e84b

File tree

2 files changed

+3
-39
lines changed

2 files changed

+3
-39
lines changed

storage/innobase/include/sync0rw.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -521,15 +521,6 @@ rw_lock_lock_word_decr(
521521
ulint amount, /*!< in: amount to decrement */
522522
lint threshold); /*!< in: threshold of judgement */
523523
/******************************************************************//**
524-
Increments lock_word the specified amount and returns new value.
525-
@return lock->lock_word after increment */
526-
UNIV_INLINE
527-
lint
528-
rw_lock_lock_word_incr(
529-
/*===================*/
530-
rw_lock_t* lock, /*!< in/out: rw-lock */
531-
ulint amount); /*!< in: amount to increment */
532-
/******************************************************************//**
533524
This function sets the lock->writer_thread and lock->recursive fields.
534525
For platforms where we are using atomic builtins instead of lock->mutex
535526
it sets the lock->writer_thread field using atomics to ensure memory

storage/innobase/include/sync0rw.ic

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -291,32 +291,6 @@ rw_lock_lock_word_decr(
291291
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
292292
}
293293

294-
/******************************************************************//**
295-
Increments lock_word the specified amount and returns new value.
296-
@return lock->lock_word after increment */
297-
UNIV_INLINE
298-
lint
299-
rw_lock_lock_word_incr(
300-
/*===================*/
301-
rw_lock_t* lock, /*!< in/out: rw-lock */
302-
ulint amount) /*!< in: amount of increment */
303-
{
304-
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
305-
return(my_atomic_addlint(&lock->lock_word, amount) + amount);
306-
#else /* INNODB_RW_LOCKS_USE_ATOMICS */
307-
lint local_lock_word;
308-
309-
mutex_enter(&(lock->mutex));
310-
311-
lock->lock_word += amount;
312-
local_lock_word = lock->lock_word;
313-
314-
mutex_exit(&(lock->mutex));
315-
316-
return(local_lock_word);
317-
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
318-
}
319-
320294
/******************************************************************//**
321295
This function sets the lock->writer_thread and lock->recursive fields.
322296
For platforms where we are using atomic builtins instead of lock->mutex
@@ -526,7 +500,7 @@ rw_lock_s_unlock_func(
526500
ut_d(rw_lock_remove_debug_info(lock, pass, RW_LOCK_S));
527501

528502
/* Increment lock_word to indicate 1 less reader */
529-
lint lock_word = rw_lock_lock_word_incr(lock, 1);
503+
lint lock_word = my_atomic_addlint(&lock->lock_word, 1) + 1;
530504
if (lock_word == 0 || lock_word == -X_LOCK_HALF_DECR) {
531505

532506
/* wait_ex waiter exists. It may not be asleep, but we signal
@@ -571,7 +545,7 @@ rw_lock_x_unlock_func(
571545
if (lock->lock_word == 0 || lock->lock_word == -X_LOCK_HALF_DECR) {
572546
/* There is 1 x-lock */
573547
/* atomic increment is needed, because it is last */
574-
if (rw_lock_lock_word_incr(lock, X_LOCK_DECR) <= 0) {
548+
if (my_atomic_addlint(&lock->lock_word, X_LOCK_DECR) <= -X_LOCK_DECR) {
575549
ut_error;
576550
}
577551

@@ -624,8 +598,7 @@ rw_lock_sx_unlock_func(
624598
UNIV_MEM_INVALID(&lock->writer_thread,
625599
sizeof lock->writer_thread);
626600

627-
if (rw_lock_lock_word_incr(lock, X_LOCK_HALF_DECR)
628-
<= X_LOCK_HALF_DECR) {
601+
if (my_atomic_addlint(&lock->lock_word, X_LOCK_HALF_DECR) <= 0) {
629602
ut_error;
630603
}
631604
/* Lock is now free. May have to signal read/write

0 commit comments

Comments
 (0)