[Commits] 9115172: Clean-up InnoDB atomics

Sergey Vojtovich svoj at mariadb.org
Fri Sep 9 14:55:29 EEST 2016


revision-id: 91151728a8d44d95c6045d9ed8b2578a23f20ca6 (mariadb-10.2.1-8-g9115172)
parent(s): d3708f789d8215d065b7cd7623d8c3b4c3ec145f
committer: Sergey Vojtovich
timestamp: 2016-09-09 15:55:28 +0400
message:

Clean-up InnoDB atomics

Replaced os_atomic_increment_uint32 and os_atomic_decrement_uint32 with
my_atomic_add32().

---
 storage/innobase/buf/buf0buf.cc      |  6 ++----
 storage/innobase/dict/dict0mem.cc    |  2 +-
 storage/innobase/include/buf0buf.ic  |  4 ++--
 storage/innobase/include/os0atomic.h | 19 +------------------
 4 files changed, 6 insertions(+), 25 deletions(-)

diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 9dacc08..a7c2568 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -5199,8 +5199,7 @@ buf_page_init(
 
 		ut_a(buf_fix_count > 0);
 
-		os_atomic_increment_uint32(&block->page.buf_fix_count,
-					   buf_fix_count);
+		my_atomic_add32((int32*) &block->page.buf_fix_count, buf_fix_count);
 
 		buf_pool_watch_remove(buf_pool, hash_page);
 	} else {
@@ -5439,8 +5438,7 @@ buf_page_init_for_read(
 
 			ut_a(buf_fix_count > 0);
 
-			os_atomic_increment_uint32(
-				&bpage->buf_fix_count, buf_fix_count);
+			my_atomic_add32((int32*) &bpage->buf_fix_count, buf_fix_count);
 
 			ut_ad(buf_pool_watch_is_sentinel(buf_pool, watch_page));
 			buf_pool_watch_remove(buf_pool, watch_page);
diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc
index b0d679d..a8f8e34 100644
--- a/storage/innobase/dict/dict0mem.cc
+++ b/storage/innobase/dict/dict0mem.cc
@@ -1045,7 +1045,7 @@ dict_mem_create_temporary_tablename(
 	size_t		dblen   = dbend - dbtab + 1;
 
 	/* Increment a randomly initialized  number for each temp file. */
-	os_atomic_increment_uint32(&dict_temp_file_num, 1);
+	my_atomic_add32((int32*) &dict_temp_file_num, 1);
 
 	size = dblen + (sizeof(TEMP_FILE_PREFIX) + 3 + 20 + 1 + 10);
 	name = static_cast<char*>(mem_heap_alloc(heap, size));
diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic
index bf77997..a912f3e 100644
--- a/storage/innobase/include/buf0buf.ic
+++ b/storage/innobase/include/buf0buf.ic
@@ -968,7 +968,7 @@ ulint
 buf_block_fix(
 	buf_page_t*	bpage)
 {
-	return(os_atomic_increment_uint32(&bpage->buf_fix_count, 1));
+	return(my_atomic_add32((int32*) &bpage->buf_fix_count, 1) + 1);
 }
 
 /** Increments the bufferfix count.
@@ -1016,7 +1016,7 @@ ulint
 buf_block_unfix(
 	buf_page_t*	bpage)
 {
-	ulint	count = os_atomic_decrement_uint32(&bpage->buf_fix_count, 1);
+	ulint	count = my_atomic_add32((int32*) &bpage->buf_fix_count, -1) - 1;
 	ut_ad(count + 1 != 0);
 	return(count);
 }
diff --git a/storage/innobase/include/os0atomic.h b/storage/innobase/include/os0atomic.h
index 7ac429c..b476c52 100644
--- a/storage/innobase/include/os0atomic.h
+++ b/storage/innobase/include/os0atomic.h
@@ -33,6 +33,7 @@ Created 2012-09-23 Sunny Bains (Split from os0sync.h)
 #define os0atomic_h
 
 #include "univ.i"
+#include <my_atomic.h>
 
 #ifdef _WIN32
 
@@ -164,12 +165,6 @@ amount of increment. */
 		static_cast<lint>(amount)))			\
 	+ static_cast<ulint>(amount))
 
-# define os_atomic_increment_uint32(ptr, amount)		\
-	(static_cast<ulint>(InterlockedExchangeAdd(		\
-		reinterpret_cast<long*>(ptr),			\
-		static_cast<long>(amount)))			\
-	+ static_cast<ulint>(amount))
-
 # define os_atomic_increment_uint64(ptr, amount)		\
 	(static_cast<ib_uint64_t>(InterlockedExchangeAdd64(	\
 		reinterpret_cast<LONGLONG*>(ptr),		\
@@ -189,12 +184,6 @@ amount to decrement. There is no atomic substract function on Windows */
 		-(static_cast<lint>(amount))))			\
 	- static_cast<ulint>(amount))
 
-# define os_atomic_decrement_uint32(ptr, amount)		\
-	(static_cast<ib_uint32_t>(InterlockedExchangeAdd(	\
-		reinterpret_cast<long*>(ptr),			\
-		-(static_cast<long>(amount))))			\
-	- static_cast<ib_uint32_t>(amount))
-
 # define os_atomic_decrement_uint64(ptr, amount)		\
 	(static_cast<ib_uint64_t>(InterlockedExchangeAdd64(	\
 		reinterpret_cast<LONGLONG*>(ptr),		\
@@ -311,9 +300,6 @@ amount of increment. */
 # define os_atomic_increment_ulint(ptr, amount) \
 	os_atomic_increment(ptr, amount)
 
-# define os_atomic_increment_uint32(ptr, amount ) \
-	os_atomic_increment(ptr, amount)
-
 # define os_atomic_increment_uint64(ptr, amount) \
 	os_atomic_increment(ptr, amount)
 
@@ -339,9 +325,6 @@ amount to decrement. */
 # define os_atomic_decrement_ulint(ptr, amount) \
 	os_atomic_decrement(ptr, amount)
 
-# define os_atomic_decrement_uint32(ptr, amount) \
-	os_atomic_decrement(ptr, amount)
-
 # define os_atomic_decrement_uint64(ptr, amount) \
 	os_atomic_decrement(ptr, amount)
 


More information about the commits mailing list