summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-02-25 00:20:10 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-05-20 14:39:59 +0300
commit6bfe9d97143e3cb00495fd4977af78cc29a31725 (patch)
tree733270947827f248e010ad590a60044002f155d3
parentf19923cb8e1819c5850b7fc89c4c71e764dc6adb (diff)
downloadmariadb-git-10.5-MDEV-18724.tar.gz
WIP: Explicit memory barriers10.5-MDEV-18724
-rw-r--r--storage/innobase/buf/buf0buf.cc4
-rw-r--r--storage/innobase/include/buf0buf.h20
2 files changed, 14 insertions, 10 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index c0f2ac67f8b..3403619f661 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -4441,8 +4441,8 @@ evict_from_pool:
bpage = &block->page;
/* Note: We have already buffer fixed this block. */
- if (bpage->buf_fix_count > 1
- || bpage->io_fix() != BUF_IO_NONE) {
+ if (bpage->buf_fix_count.load(std::memory_order_acquire) > 1
+ || bpage->io_fix(std::memory_order_relaxed) != BUF_IO_NONE) {
/* This condition often occurs when the buffer
is not buffer-fixed, but I/O-fixed by
buf_page_init_for_read(). */
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index 9b00f020964..8cac73b79e4 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -1379,7 +1379,8 @@ public:
/** Copy constructor */
buf_page_t(const buf_page_t& b) :
id(b.id), hash(b.hash),
- buf_fix_count(b.buf_fix_count), io_fix_(b.io_fix()),
+ buf_fix_count(b.buf_fix_count.load(std::memory_order_relaxed)),
+ io_fix_(b.io_fix_.load(std::memory_order_relaxed)),
state_(b.state()),
flush_type(b.flush_type),
buf_pool_index(b.buf_pool_index),
@@ -1423,7 +1424,7 @@ public:
buf_pool->zip_hash */
/** Count of how manyfold this block is currently bufferfixed. */
- Atomic_counter<uint32_t> buf_fix_count;
+ std::atomic<uint32_t> buf_fix_count;
/** type of pending I/O operation; also protected by buf_pool->mutex */
std::atomic<buf_io_fix> io_fix_;
@@ -1574,10 +1575,11 @@ public:
in the buffer pool. Protected by
block mutex */
- void fix() { buf_fix_count++; }
- uint32_t unfix()
+ void fix(std::memory_order sync = std::memory_order_acquire)
+ { buf_fix_count.fetch_add(1, sync); }
+ uint32_t unfix(std::memory_order sync = std::memory_order_release)
{
- uint32_t count= buf_fix_count--;
+ uint32_t count= buf_fix_count.fetch_sub(1, sync);
ut_ad(count != 0);
return count - 1;
}
@@ -1596,11 +1598,13 @@ public:
}
/** @return the I/O fix status of the block */
- buf_io_fix io_fix() const { return io_fix_; }
+ buf_io_fix io_fix(std::memory_order sync = std::memory_order_relaxed) const
+ { return io_fix_.load(sync); }
/** Set the io_fix of the block. */
- void set_io_fix(buf_io_fix io_fix)
- { ut_ad(holding_buf_pool_mutex()); io_fix_ = io_fix; }
+ void set_io_fix(buf_io_fix io_fix,
+ std::memory_order sync = std::memory_order_relaxed)
+ { ut_ad(holding_buf_pool_mutex()); io_fix_.store(io_fix, sync); }
/** @return the state of of the block */
buf_page_state state() const { return state_; }