summaryrefslogtreecommitdiff
path: root/storage/innobase/include
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-04-19 22:30:18 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-04-20 16:29:12 +0300
commitd34a67b067606f61c9ec6700769770418d5bb47d (patch)
tree1e012e42e9cfd042af23a73bd393eec0b9f50e80 /storage/innobase/include
parent88613e1df69ab416d43f21551acec340648d0017 (diff)
downloadmariadb-git-d34a67b067606f61c9ec6700769770418d5bb47d.tar.gz
MDEV-12534 Use atomic operations whenever available
Allow 64-bit atomic operations on 32-bit systems, only relying on HAVE_ATOMIC_BUILTINS_64, disregarding the width of the register file. Define UNIV_WORD_SIZE correctly on all systems, including Windows. In MariaDB 10.0 and 10.1, it was incorrectly defined as 4 on 64-bit Windows. Define HAVE_ATOMIC_BUILTINS_64 on Windows (64-bit atomics are available on both 32-bit and 64-bit Windows platforms; the operations were unnecessarily disabled even on 64-bit Windows). MONITOR_OS_PENDING_READS, MONITOR_OS_PENDING_WRITES: Enable by default. os_file_n_pending_preads, os_file_n_pending_pwrites, os_n_pending_reads, os_n_pending_writes: Remove. Use the monitor counters instead. os_file_count_mutex: Remove. On a system that does not support 64-bit atomics, monitor_mutex will be used instead.
Diffstat (limited to 'storage/innobase/include')
-rw-r--r--storage/innobase/include/os0file.h12
-rw-r--r--storage/innobase/include/os0sync.h5
-rw-r--r--storage/innobase/include/srv0mon.h62
-rw-r--r--storage/innobase/include/univ.i12
4 files changed, 50 insertions, 41 deletions
diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h
index 6cb4f54d629..bdb4682eafb 100644
--- a/storage/innobase/include/os0file.h
+++ b/storage/innobase/include/os0file.h
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2013, 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted
by Percona Inc.. Those modifications are
@@ -51,16 +51,6 @@ extern ibool os_has_said_disk_full;
/** Flag: enable debug printout for asynchronous i/o */
extern ibool os_aio_print_debug;
-/** Number of pending os_file_pread() operations */
-extern ulint os_file_n_pending_preads;
-/** Number of pending os_file_pwrite() operations */
-extern ulint os_file_n_pending_pwrites;
-
-/** Number of pending read operations */
-extern ulint os_n_pending_reads;
-/** Number of pending write operations */
-extern ulint os_n_pending_writes;
-
#ifdef __WIN__
/** We define always WIN_ASYNC_IO, and check at run-time whether
diff --git a/storage/innobase/include/os0sync.h b/storage/innobase/include/os0sync.h
index 0754210c47a..dd6de43dc0b 100644
--- a/storage/innobase/include/os0sync.h
+++ b/storage/innobase/include/os0sync.h
@@ -667,10 +667,7 @@ os_atomic_clear(volatile lock_word_t* ptr)
# define HAVE_ATOMIC_BUILTINS
# define HAVE_ATOMIC_BUILTINS_BYTE
-
-# ifndef _WIN32
-# define HAVE_ATOMIC_BUILTINS_64
-# endif
+# define HAVE_ATOMIC_BUILTINS_64
/**********************************************************//**
Atomic compare and exchange of signed integers (both 32 and 64 bit).
diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h
index 2d90f47eefe..09af5d4159b 100644
--- a/storage/innobase/include/srv0mon.h
+++ b/storage/innobase/include/srv0mon.h
@@ -2,6 +2,7 @@
Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
+Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -541,22 +542,30 @@ on the counters */
/** Increment a monitor counter under mutex protection.
Use MONITOR_INC if appropriate mutex protection already exists.
+@param mutex mutex to acquire and release
@param monitor monitor to be incremented by 1
-@param mutex mutex to acquire and relese */
-# define MONITOR_MUTEX_INC(mutex, monitor) \
+@param enabled whether the monitor is enabled */
+#define MONITOR_MUTEX_INC_LOW(mutex, monitor, enabled) \
ut_ad(!mutex_own(mutex)); \
- if (MONITOR_IS_ON(monitor)) { \
+ if (enabled) { \
mutex_enter(mutex); \
if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
} \
mutex_exit(mutex); \
}
+/** Increment a monitor counter under mutex protection.
+Use MONITOR_INC if appropriate mutex protection already exists.
+@param mutex mutex to acquire and release
+@param monitor monitor to be incremented by 1 */
+#define MONITOR_MUTEX_INC(mutex, monitor) \
+ MONITOR_MUTEX_INC_LOW(mutex, monitor, MONITOR_IS_ON(monitor))
/** Decrement a monitor counter under mutex protection.
Use MONITOR_DEC if appropriate mutex protection already exists.
+@param mutex mutex to acquire and release
@param monitor monitor to be decremented by 1
-@param mutex mutex to acquire and relese */
-# define MONITOR_MUTEX_DEC(mutex, monitor) \
+@param enabled whether the monitor is enabled */
+#define MONITOR_MUTEX_DEC_LOW(mutex, monitor, enabled) \
ut_ad(!mutex_own(mutex)); \
if (MONITOR_IS_ON(monitor)) { \
mutex_enter(mutex); \
@@ -565,13 +574,20 @@ Use MONITOR_DEC if appropriate mutex protection already exists.
} \
mutex_exit(mutex); \
}
+/** Decrement a monitor counter under mutex protection.
+Use MONITOR_DEC if appropriate mutex protection already exists.
+@param mutex mutex to acquire and release
+@param monitor monitor to be decremented by 1 */
+#define MONITOR_MUTEX_DEC(mutex, monitor) \
+ MONITOR_MUTEX_DEC_LOW(mutex, monitor, MONITOR_IS_ON(monitor))
#if defined HAVE_ATOMIC_BUILTINS_64
/** Atomically increment a monitor counter.
Use MONITOR_INC if appropriate mutex protection exists.
-@param monitor monitor to be incremented by 1 */
-# define MONITOR_ATOMIC_INC(monitor) \
- if (MONITOR_IS_ON(monitor)) { \
+@param monitor monitor to be incremented by 1
+@param enabled whether the monitor is enabled */
+# define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \
+ if (enabled) { \
ib_uint64_t value; \
value = os_atomic_increment_uint64( \
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
@@ -584,9 +600,10 @@ Use MONITOR_INC if appropriate mutex protection exists.
/** Atomically decrement a monitor counter.
Use MONITOR_DEC if appropriate mutex protection exists.
-@param monitor monitor to be decremented by 1 */
-# define MONITOR_ATOMIC_DEC(monitor) \
- if (MONITOR_IS_ON(monitor)) { \
+@param monitor monitor to be decremented by 1
+@param enabled whether the monitor is enabled */
+# define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \
+ if (enabled) { \
ib_uint64_t value; \
value = os_atomic_decrement_uint64( \
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
@@ -617,14 +634,29 @@ srv_mon_free(void);
/** Atomically increment a monitor counter.
Use MONITOR_INC if appropriate mutex protection exists.
-@param monitor monitor to be incremented by 1 */
-# define MONITOR_ATOMIC_INC(monitor) MONITOR_MUTEX_INC(&monitor_mutex, monitor)
+@param monitor monitor to be incremented by 1
+@param enabled whether the monitor is enabled */
+# define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \
+ MONITOR_MUTEX_INC_LOW(&monitor_mutex, monitor, enabled)
/** Atomically decrement a monitor counter.
Use MONITOR_DEC if appropriate mutex protection exists.
-@param monitor monitor to be decremented by 1 */
-# define MONITOR_ATOMIC_DEC(monitor) MONITOR_MUTEX_DEC(&monitor_mutex, monitor)
+@param monitor monitor to be decremented by 1
+@param enabled whether the monitor is enabled */
+# define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \
+ MONITOR_MUTEX_DEC_LOW(&monitor_mutex, monitor, enabled)
#endif /* HAVE_ATOMIC_BUILTINS_64 */
+/** Atomically increment a monitor counter if it is enabled.
+Use MONITOR_INC if appropriate mutex protection exists.
+@param monitor monitor to be incremented by 1 */
+#define MONITOR_ATOMIC_INC(monitor) \
+ MONITOR_ATOMIC_INC_LOW(monitor, MONITOR_IS_ON(monitor))
+/** Atomically decrement a monitor counter if it is enabled.
+Use MONITOR_DEC if appropriate mutex protection exists.
+@param monitor monitor to be decremented by 1 */
+#define MONITOR_ATOMIC_DEC(monitor) \
+ MONITOR_ATOMIC_DEC_LOW(monitor, MONITOR_IS_ON(monitor))
+
#define MONITOR_DEC(monitor) \
if (MONITOR_IS_ON(monitor)) { \
MONITOR_VALUE(monitor)--; \
diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i
index 824a06829f9..fc0bf0aeeca 100644
--- a/storage/innobase/include/univ.i
+++ b/storage/innobase/include/univ.i
@@ -285,22 +285,12 @@ definitions: */
#endif /* !UNIV_MUST_NOT_INLINE */
-#ifdef _WIN32
-#define UNIV_WORD_SIZE 4
-#elif defined(_WIN64)
-#define UNIV_WORD_SIZE 8
-#else
-/** MySQL config.h generated by GNU autoconf will define SIZEOF_LONG in Posix */
-#define UNIV_WORD_SIZE SIZEOF_LONG
-#endif
+#define UNIV_WORD_SIZE SIZEOF_SIZE_T
/** The following alignment is used in memory allocations in memory heap
management to ensure correct alignment for doubles etc. */
#define UNIV_MEM_ALIGNMENT 8
-/** The following alignment is used in aligning lints etc. */
-#define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE
-
/*
DATABASE VERSION CONTROL
========================