diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-04-19 22:30:18 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-04-20 16:29:12 +0300 |
commit | d34a67b067606f61c9ec6700769770418d5bb47d (patch) | |
tree | 1e012e42e9cfd042af23a73bd393eec0b9f50e80 /storage/innobase/include/srv0mon.h | |
parent | 88613e1df69ab416d43f21551acec340648d0017 (diff) | |
download | mariadb-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/srv0mon.h')
-rw-r--r-- | storage/innobase/include/srv0mon.h | 62 |
1 files changed, 47 insertions, 15 deletions
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)--; \ |