Commit 68a85373 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-11296 - InnoDB stalls under OLTP RW on P8

Clean-up INNODB_RW_LOCKS_USE_ATOMICS: it is always set.
parent 8d010c44
......@@ -44,8 +44,6 @@ extern my_bool srv_instrument_semaphores;
#endif /* !UNIV_HOTBACKUP */
# define INNODB_RW_LOCKS_USE_ATOMICS
/** Counters for RW locks. */
struct rw_lock_stats_t {
typedef ib_counter_t<int64_t, IB_N_SLOTS> int64_counter_t;
......@@ -682,11 +680,6 @@ struct rw_lock_t
struct PSI_rwlock* pfs_psi;
#endif /* UNIV_PFS_RWLOCK */
#ifndef INNODB_RW_LOCKS_USE_ATOMICS
/** The mutex protecting rw_lock_t */
mutable ib_mutex_t mutex;
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
#ifdef UNIV_DEBUG
/** Value of rw_lock_t::magic_n */
# define RW_LOCK_MAGIC_N 22643
......
......@@ -134,17 +134,6 @@ rw_lock_get_reader_count(
return(0);
}
#ifndef INNODB_RW_LOCKS_USE_ATOMICS
UNIV_INLINE
ib_mutex_t*
rw_lock_get_mutex(
/*==============*/
rw_lock_t* lock)
{
return(&(lock->mutex));
}
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
/******************************************************************//**
Returns the value of writer_count for the lock. Does not reserve the lock
mutex, so the caller must be sure it is not changed during the call.
......@@ -221,7 +210,6 @@ rw_lock_lock_word_decr(
ulint amount, /*!< in: amount to decrement */
lint threshold) /*!< in: threshold of judgement */
{
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
lint local_lock_word;
local_lock_word = lock->lock_word;
......@@ -233,16 +221,6 @@ rw_lock_lock_word_decr(
}
}
return(false);
#else /* INNODB_RW_LOCKS_USE_ATOMICS */
bool success = false;
mutex_enter(&(lock->mutex));
if (lock->lock_word > threshold) {
lock->lock_word -= amount;
success = true;
}
mutex_exit(&(lock->mutex));
return(success);
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
}
/******************************************************************//**
......@@ -263,20 +241,8 @@ rw_lock_set_writer_id_and_recursion_flag(
allowed */
{
os_thread_id_t curr_thread = os_thread_get_curr_id();
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
my_atomic_storelong(&lock->writer_thread, (long) curr_thread);
lock->recursive = recursive;
#else /* INNODB_RW_LOCKS_USE_ATOMICS */
mutex_enter(&lock->mutex);
lock->writer_thread = curr_thread;
lock->recursive = recursive;
mutex_exit(&lock->mutex);
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
}
/******************************************************************//**
......@@ -368,28 +334,14 @@ rw_lock_x_lock_func_nowait(
const char* file_name,/*!< in: file name where lock requested */
ulint line) /*!< in: line where requested */
{
ibool success;
ibool local_recursive= lock->recursive;
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
lint oldval = X_LOCK_DECR;
success = my_atomic_caslint(&lock->lock_word, &oldval, 0);
#else
success = FALSE;
mutex_enter(&(lock->mutex));
if (lock->lock_word == X_LOCK_DECR) {
lock->lock_word = 0;
success = TRUE;
}
mutex_exit(&(lock->mutex));
#endif
/* Note: recursive must be loaded before writer_thread see
comment for rw_lock_set_writer_id_and_recursion_flag().
To achieve this we load it before my_atomic_caslint(),
which implies full memory barrier in current implementation. */
if (success) {
if (my_atomic_caslint(&lock->lock_word, &oldval, 0)) {
rw_lock_set_writer_id_and_recursion_flag(lock, true);
} else if (local_recursive
......
......@@ -4571,12 +4571,7 @@ row_search_mvcc(
/* PHASE 0: Release a possible s-latch we are holding on the
adaptive hash index latch if there is someone waiting behind */
if (trx->has_search_latch
#ifndef INNODB_RW_LOCKS_USE_ATOMICS
&& rw_lock_get_writer(
btr_get_search_latch(index)) != RW_LOCK_NOT_LOCKED
#endif /* !INNODB_RW_LOCKS_USE_ATOMICS */
) {
if (trx->has_search_latch) {
/* There is an x-latch request on the adaptive hash index:
release the s-latch to reduce starvation and wait for
......
......@@ -233,18 +233,6 @@ rw_lock_create_func(
/* If this is the very first time a synchronization object is
created, then the following call initializes the sync system. */
#ifndef INNODB_RW_LOCKS_USE_ATOMICS
mutex_create(LATCH_ID_RW_LOCK_MUTEX, rw_lock_get_mutex(lock));
lock->mutex.cfile_name = cfile_name;
lock->mutex.cline = cline;
lock->mutex.lock_name = cmutex_name;
#else /* INNODB_RW_LOCKS_USE_ATOMICS */
# ifdef UNIV_DEBUG
UT_NOT_USED(cmutex_name);
# endif
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
lock->lock_word = X_LOCK_DECR;
lock->waiters = 0;
......@@ -312,10 +300,6 @@ rw_lock_free_func(
mutex_enter(&rw_lock_list_mutex);
#ifndef INNODB_RW_LOCKS_USE_ATOMICS
mutex_free(rw_lock_get_mutex(lock));
#endif /* !INNODB_RW_LOCKS_USE_ATOMICS */
os_event_destroy(lock->event);
os_event_destroy(lock->wait_ex_event);
......@@ -1219,10 +1203,6 @@ rw_lock_list_print_info(
count++;
#ifndef INNODB_RW_LOCKS_USE_ATOMICS
mutex_enter(&lock->mutex);
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
if (lock->lock_word != X_LOCK_DECR) {
fprintf(file, "RW-LOCK: %p ", (void*) lock);
......@@ -1246,10 +1226,6 @@ rw_lock_list_print_info(
rw_lock_debug_mutex_exit();
}
#ifndef INNODB_RW_LOCKS_USE_ATOMICS
mutex_exit(&lock->mutex);
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
}
fprintf(file, "Total number of rw-locks " ULINTPF "\n", count);
......@@ -1270,15 +1246,6 @@ rw_lock_print(
"RW-LATCH INFO\n"
"RW-LATCH: %p ", (void*) lock);
#ifndef INNODB_RW_LOCKS_USE_ATOMICS
/* We used to acquire lock->mutex here, but it would cause a
recursive call to sync_thread_add_level() if UNIV_DEBUG
is defined. Since this function is only invoked from
sync_thread_levels_g(), let us choose the smaller evil:
performing dirty reads instead of causing bogus deadlocks or
assertion failures. */
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
if (lock->lock_word != X_LOCK_DECR) {
if (lock->waiters) {
......
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