summaryrefslogtreecommitdiff
path: root/storage/innobase
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2016-09-14 15:56:06 +0400
committerSergey Vojtovich <svoj@mariadb.org>2016-10-17 18:35:49 +0400
commit5608a737ea7b5630452957b82deff4c76406041e (patch)
treec62d02827644754c05406260a95face811c4ce5d /storage/innobase
parentf4d885c4e9d929639b7075b7382b439f0b4e3cc1 (diff)
downloadmariadb-git-5608a737ea7b5630452957b82deff4c76406041e.tar.gz
MDEV-10813 - Clean-up InnoDB atomics, memory barriers and mutexes
No point to issue RELEASE memory barrier in os_thread_create_func(): thread creation is full memory barrier. No point to issue os_wmb in rw_lock_set_waiter_flag() and rw_lock_reset_waiter_flag(): this is deadcode and it is unlikely operational anyway. If atomic builtins are unavailable - memory barriers are most certainly unavailable too. RELEASE memory barrier is definitely abused in buf_pool_withdraw_blocks(): most probably it was supposed to commit volatile variable update, which is not what memory barriers actually do. To operate properly it needs corresponding ACQUIRE barrier without an associated atomic operation anyway. ACQUIRE memory barrier is definitely abused in log_write_up_to(): most probably it was supposed to synchronize dirty read of log_sys->write_lsn. To operate properly it needs corresponding RELEASE barrier without an associated atomic operation anyway. Removed a bunch of ACQUIRE memory barriers from InnoDB rwlocks. They're meaningless without corresponding RELEASE memory barriers. Valid usage example of memory barriers without an associated atomic operation: http://en.cppreference.com/w/cpp/atomic/atomic_thread_fence
Diffstat (limited to 'storage/innobase')
-rw-r--r--storage/innobase/buf/buf0buf.cc1
-rw-r--r--storage/innobase/include/sync0rw.ic3
-rw-r--r--storage/innobase/log/log0log.cc1
-rw-r--r--storage/innobase/os/os0thread.cc3
-rw-r--r--storage/innobase/sync/sync0rw.cc16
5 files changed, 0 insertions, 24 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 820e8659d94..e187297b231 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -2504,7 +2504,6 @@ buf_pool_withdraw_blocks(
/* retry is not needed */
++buf_withdraw_clock;
- os_wmb;
return(false);
}
diff --git a/storage/innobase/include/sync0rw.ic b/storage/innobase/include/sync0rw.ic
index fc7d80ac9da..4d3e8acd3e6 100644
--- a/storage/innobase/include/sync0rw.ic
+++ b/storage/innobase/include/sync0rw.ic
@@ -92,7 +92,6 @@ rw_lock_set_waiter_flag(
my_atomic_storelint(&lock->waiters, 1);
#else /* INNODB_RW_LOCKS_USE_ATOMICS */
lock->waiters = 1;
- os_wmb;
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
}
@@ -110,7 +109,6 @@ rw_lock_reset_waiter_flag(
my_atomic_storelint(&lock->waiters, 0);
#else /* INNODB_RW_LOCKS_USE_ATOMICS */
lock->waiters = 0;
- os_wmb;
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
}
@@ -272,7 +270,6 @@ rw_lock_lock_word_decr(
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
lint local_lock_word;
- os_rmb;
local_lock_word = lock->lock_word;
while (local_lock_word > threshold) {
if (my_atomic_caslint(&lock->lock_word,
diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
index 95090c0890a..bc421774320 100644
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@ -1247,7 +1247,6 @@ loop:
(flush_to_disk == true) case, because the log_mutex
contention also works as the arbitrator for write-IO
(fsync) bandwidth between log files and data files. */
- os_rmb;
if (!flush_to_disk && log_sys->write_lsn >= lsn) {
return;
}
diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc
index 2d9abaa6c52..edc9c8e9406 100644
--- a/storage/innobase/os/os0thread.cc
+++ b/storage/innobase/os/os0thread.cc
@@ -117,9 +117,6 @@ os_thread_create_func(
{
os_thread_id_t new_thread_id;
- /* the new thread should look recent changes up here so far. */
- os_wmb;
-
#ifdef _WIN32
HANDLE handle;
diff --git a/storage/innobase/sync/sync0rw.cc b/storage/innobase/sync/sync0rw.cc
index 7c8aad640a2..183a09bc4ac 100644
--- a/storage/innobase/sync/sync0rw.cc
+++ b/storage/innobase/sync/sync0rw.cc
@@ -307,7 +307,6 @@ rw_lock_free_func(
/*==============*/
rw_lock_t* lock) /*!< in/out: rw-lock */
{
- os_rmb;
ut_ad(rw_lock_validate(lock));
ut_a(lock->lock_word == X_LOCK_DECR);
@@ -356,7 +355,6 @@ rw_lock_s_lock_spin(
lock_loop:
/* Spin waiting for the writer field to become free */
- os_rmb;
HMT_low();
while (i < srv_n_spin_wait_rounds && lock->lock_word <= 0) {
if (srv_spin_wait_delay) {
@@ -364,7 +362,6 @@ lock_loop:
}
i++;
- os_rmb;
}
HMT_medium();
@@ -480,7 +477,6 @@ rw_lock_x_lock_wait_func(
sync_array_t* sync_arr;
uint64_t count_os_wait = 0;
- os_rmb;
ut_ad(lock->lock_word <= threshold);
while (lock->lock_word < threshold) {
@@ -493,7 +489,6 @@ rw_lock_x_lock_wait_func(
if (i < srv_n_spin_wait_rounds) {
i++;
- os_rmb;
continue;
}
HMT_medium();
@@ -596,10 +591,6 @@ rw_lock_x_lock_low(
} else {
os_thread_id_t thread_id = os_thread_get_curr_id();
- if (!pass) {
- os_rmb;
- }
-
/* Decrement failed: An X or SX lock is held by either
this thread or another. Try to relock. */
if (!pass
@@ -681,10 +672,6 @@ rw_lock_sx_lock_low(
} else {
os_thread_id_t thread_id = os_thread_get_curr_id();
- if (!pass) {
- os_rmb;
- }
-
/* Decrement failed: It already has an X or SX lock by this
thread or another thread. If it is this thread, relock,
else fail. */
@@ -776,7 +763,6 @@ lock_loop:
} else {
/* Spin waiting for the lock_word to become free */
- os_rmb;
HMT_low();
while (i < srv_n_spin_wait_rounds
&& lock->lock_word <= X_LOCK_HALF_DECR) {
@@ -787,7 +773,6 @@ lock_loop:
}
i++;
- os_rmb;
}
HMT_medium();
@@ -885,7 +870,6 @@ lock_loop:
++spin_wait_count;
/* Spin waiting for the lock_word to become free */
- os_rmb;
while (i < srv_n_spin_wait_rounds
&& lock->lock_word <= X_LOCK_HALF_DECR) {