summaryrefslogtreecommitdiff
path: root/storage/innobase/sync/sync0rw.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/sync/sync0rw.cc')
-rw-r--r--storage/innobase/sync/sync0rw.cc44
1 files changed, 18 insertions, 26 deletions
diff --git a/storage/innobase/sync/sync0rw.cc b/storage/innobase/sync/sync0rw.cc
index 2795fc902fc..983507fab0d 100644
--- a/storage/innobase/sync/sync0rw.cc
+++ b/storage/innobase/sync/sync0rw.cc
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
-Copyright (c) 2017, 2019, MariaDB Corporation.
+Copyright (c) 2017, 2020, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -202,11 +202,8 @@ rw_lock_create_func(
new(lock) rw_lock_t();
#endif /* UNIV_DEBUG */
- /* If this is the very first time a synchronization object is
- created, then the following call initializes the sync system. */
-
- lock->lock_word.store(X_LOCK_DECR, std::memory_order_relaxed);
- lock->waiters.store(0, std::memory_order_relaxed);
+ lock->lock_word = X_LOCK_DECR;
+ lock->waiters = 0;
lock->sx_recursive = 0;
lock->writer_thread= 0;
@@ -252,7 +249,7 @@ rw_lock_free_func(
rw_lock_t* lock) /*!< in/out: rw-lock */
{
ut_ad(rw_lock_validate(lock));
- ut_a(lock->lock_word.load(std::memory_order_relaxed) == X_LOCK_DECR);
+ ut_a(lock->lock_word == X_LOCK_DECR);
mutex_enter(&rw_lock_list_mutex);
@@ -294,7 +291,7 @@ lock_loop:
/* Spin waiting for the writer field to become free */
HMT_low();
while (i < srv_n_spin_wait_rounds &&
- lock->lock_word.load(std::memory_order_relaxed) <= 0) {
+ lock->lock_word <= 0) {
ut_delay(srv_spin_wait_delay);
i++;
}
@@ -412,10 +409,10 @@ rw_lock_x_lock_wait_func(
sync_array_t* sync_arr;
int64_t count_os_wait = 0;
- ut_ad(lock->lock_word.load(std::memory_order_relaxed) <= threshold);
+ ut_ad(lock->lock_word <= threshold);
HMT_low();
- while (lock->lock_word.load(std::memory_order_relaxed) < threshold) {
+ while (lock->lock_word < threshold) {
ut_delay(srv_spin_wait_delay);
if (i < srv_n_spin_wait_rounds) {
@@ -434,8 +431,7 @@ rw_lock_x_lock_wait_func(
i = 0;
/* Check lock_word to ensure wake-up isn't missed.*/
- if (lock->lock_word.load(std::memory_order_relaxed) < threshold) {
-
+ if (lock->lock_word < threshold) {
++count_os_wait;
/* Add debug info as it is needed to detect possible
@@ -524,17 +520,15 @@ rw_lock_x_lock_low(
file_name, line);
} else {
- auto lock_word = lock->lock_word.load(std::memory_order_relaxed);
+ int32_t lock_word = lock->lock_word;
/* At least one X lock by this thread already
exists. Add another. */
if (lock_word == 0
|| lock_word == -X_LOCK_HALF_DECR) {
- lock->lock_word.fetch_sub(X_LOCK_DECR,
- std::memory_order_relaxed);
+ lock->lock_word -= X_LOCK_DECR;
} else {
ut_ad(lock_word <= -X_LOCK_DECR);
- lock->lock_word.fetch_sub(1,
- std::memory_order_relaxed);
+ lock->lock_word--;
}
}
@@ -677,7 +671,7 @@ lock_loop:
/* Spin waiting for the lock_word to become free */
HMT_low();
while (i < srv_n_spin_wait_rounds
- && lock->lock_word.load(std::memory_order_relaxed) <= X_LOCK_HALF_DECR) {
+ && lock->lock_word <= X_LOCK_HALF_DECR) {
ut_delay(srv_spin_wait_delay);
i++;
}
@@ -778,7 +772,7 @@ lock_loop:
/* Spin waiting for the lock_word to become free */
while (i < srv_n_spin_wait_rounds
- && lock->lock_word.load(std::memory_order_relaxed) <= X_LOCK_HALF_DECR) {
+ && lock->lock_word <= X_LOCK_HALF_DECR) {
ut_delay(srv_spin_wait_delay);
i++;
}
@@ -841,13 +835,11 @@ rw_lock_validate(
/*=============*/
const rw_lock_t* lock) /*!< in: rw-lock */
{
- int32_t lock_word;
-
ut_ad(lock);
- lock_word = lock->lock_word.load(std::memory_order_relaxed);
+ int32_t lock_word = lock->lock_word;
- ut_ad(lock->waiters.load(std::memory_order_relaxed) < 2);
+ ut_ad(lock->waiters < 2);
ut_ad(lock_word > -(2 * X_LOCK_DECR));
ut_ad(lock_word <= X_LOCK_DECR);
@@ -910,7 +902,7 @@ rw_lock_add_debug_info(
rw_lock_debug_mutex_exit();
if (pass == 0 && lock_type != RW_LOCK_X_WAIT) {
- auto lock_word = lock->lock_word.load(std::memory_order_relaxed);
+ int32_t lock_word = lock->lock_word;
/* Recursive x while holding SX
(lock_type == RW_LOCK_X && lock_word == -X_LOCK_HALF_DECR)
@@ -1096,11 +1088,11 @@ rw_lock_list_print_info(
count++;
- if (lock->lock_word.load(std::memory_order_relaxed) != X_LOCK_DECR) {
+ if (lock->lock_word != X_LOCK_DECR) {
fprintf(file, "RW-LOCK: %p ", (void*) lock);
- if (int32_t waiters= lock->waiters.load(std::memory_order_relaxed)) {
+ if (int32_t waiters= lock->waiters) {
fprintf(file, " (%d waiters)\n", waiters);
} else {
putc('\n', file);