Commit d34a67b0 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 88613e1d
...@@ -881,15 +881,11 @@ buf_read_recv_pages( ...@@ -881,15 +881,11 @@ buf_read_recv_pages(
count++; count++;
if (count > 1000) { if (count > 1000) {
fprintf(stderr, ib_logf(IB_LOG_LEVEL_ERROR,
"InnoDB: Error: InnoDB has waited for" "waited for 10 seconds for " ULINTPF
" 10 seconds for pending\n" " pending reads to the buffer pool to"
"InnoDB: reads to the buffer pool to" " be finished",
" be finished.\n" buf_pool->n_pend_reads);
"InnoDB: Number of pending reads %lu,"
" pending pread calls %lu\n",
(ulong) buf_pool->n_pend_reads,
(ulong) os_file_n_pending_preads);
os_aio_print_debug = TRUE; os_aio_print_debug = TRUE;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc. 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 Portions of this file contain modifications contributed and copyrighted
by Percona Inc.. Those modifications are by Percona Inc.. Those modifications are
...@@ -51,16 +51,6 @@ extern ibool os_has_said_disk_full; ...@@ -51,16 +51,6 @@ extern ibool os_has_said_disk_full;
/** Flag: enable debug printout for asynchronous i/o */ /** Flag: enable debug printout for asynchronous i/o */
extern ibool os_aio_print_debug; 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__ #ifdef __WIN__
/** We define always WIN_ASYNC_IO, and check at run-time whether /** We define always WIN_ASYNC_IO, and check at run-time whether
......
...@@ -667,10 +667,7 @@ os_atomic_clear(volatile lock_word_t* ptr) ...@@ -667,10 +667,7 @@ os_atomic_clear(volatile lock_word_t* ptr)
# define HAVE_ATOMIC_BUILTINS # define HAVE_ATOMIC_BUILTINS
# define HAVE_ATOMIC_BUILTINS_BYTE # define HAVE_ATOMIC_BUILTINS_BYTE
# define HAVE_ATOMIC_BUILTINS_64
# ifndef _WIN32
# define HAVE_ATOMIC_BUILTINS_64
# endif
/**********************************************************//** /**********************************************************//**
Atomic compare and exchange of signed integers (both 32 and 64 bit). Atomic compare and exchange of signed integers (both 32 and 64 bit).
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it 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 under the terms of the GNU General Public License as published by the
...@@ -541,22 +542,30 @@ on the counters */ ...@@ -541,22 +542,30 @@ on the counters */
/** Increment a monitor counter under mutex protection. /** Increment a monitor counter under mutex protection.
Use MONITOR_INC if appropriate mutex protection already exists. 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 monitor monitor to be incremented by 1
@param mutex mutex to acquire and relese */ @param enabled whether the monitor is enabled */
# define MONITOR_MUTEX_INC(mutex, monitor) \ #define MONITOR_MUTEX_INC_LOW(mutex, monitor, enabled) \
ut_ad(!mutex_own(mutex)); \ ut_ad(!mutex_own(mutex)); \
if (MONITOR_IS_ON(monitor)) { \ if (enabled) { \
mutex_enter(mutex); \ mutex_enter(mutex); \
if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \ if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \ MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
} \ } \
mutex_exit(mutex); \ 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. /** Decrement a monitor counter under mutex protection.
Use MONITOR_DEC if appropriate mutex protection already exists. 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 monitor monitor to be decremented by 1
@param mutex mutex to acquire and relese */ @param enabled whether the monitor is enabled */
# define MONITOR_MUTEX_DEC(mutex, monitor) \ #define MONITOR_MUTEX_DEC_LOW(mutex, monitor, enabled) \
ut_ad(!mutex_own(mutex)); \ ut_ad(!mutex_own(mutex)); \
if (MONITOR_IS_ON(monitor)) { \ if (MONITOR_IS_ON(monitor)) { \
mutex_enter(mutex); \ mutex_enter(mutex); \
...@@ -565,13 +574,20 @@ Use MONITOR_DEC if appropriate mutex protection already exists. ...@@ -565,13 +574,20 @@ Use MONITOR_DEC if appropriate mutex protection already exists.
} \ } \
mutex_exit(mutex); \ 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 #if defined HAVE_ATOMIC_BUILTINS_64
/** Atomically increment a monitor counter. /** Atomically increment a monitor counter.
Use MONITOR_INC if appropriate mutex protection exists. Use MONITOR_INC if appropriate mutex protection exists.
@param monitor monitor to be incremented by 1 */ @param monitor monitor to be incremented by 1
# define MONITOR_ATOMIC_INC(monitor) \ @param enabled whether the monitor is enabled */
if (MONITOR_IS_ON(monitor)) { \ # define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \
if (enabled) { \
ib_uint64_t value; \ ib_uint64_t value; \
value = os_atomic_increment_uint64( \ value = os_atomic_increment_uint64( \
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \ (ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
...@@ -584,9 +600,10 @@ Use MONITOR_INC if appropriate mutex protection exists. ...@@ -584,9 +600,10 @@ Use MONITOR_INC if appropriate mutex protection exists.
/** Atomically decrement a monitor counter. /** Atomically decrement a monitor counter.
Use MONITOR_DEC if appropriate mutex protection exists. Use MONITOR_DEC if appropriate mutex protection exists.
@param monitor monitor to be decremented by 1 */ @param monitor monitor to be decremented by 1
# define MONITOR_ATOMIC_DEC(monitor) \ @param enabled whether the monitor is enabled */
if (MONITOR_IS_ON(monitor)) { \ # define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \
if (enabled) { \
ib_uint64_t value; \ ib_uint64_t value; \
value = os_atomic_decrement_uint64( \ value = os_atomic_decrement_uint64( \
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \ (ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
...@@ -617,14 +634,29 @@ srv_mon_free(void); ...@@ -617,14 +634,29 @@ srv_mon_free(void);
/** Atomically increment a monitor counter. /** Atomically increment a monitor counter.
Use MONITOR_INC if appropriate mutex protection exists. Use MONITOR_INC if appropriate mutex protection exists.
@param monitor monitor to be incremented by 1 */ @param monitor monitor to be incremented by 1
# define MONITOR_ATOMIC_INC(monitor) MONITOR_MUTEX_INC(&monitor_mutex, monitor) @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. /** Atomically decrement a monitor counter.
Use MONITOR_DEC if appropriate mutex protection exists. Use MONITOR_DEC if appropriate mutex protection exists.
@param monitor monitor to be decremented by 1 */ @param monitor monitor to be decremented by 1
# define MONITOR_ATOMIC_DEC(monitor) MONITOR_MUTEX_DEC(&monitor_mutex, monitor) @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 */ #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) \ #define MONITOR_DEC(monitor) \
if (MONITOR_IS_ON(monitor)) { \ if (MONITOR_IS_ON(monitor)) { \
MONITOR_VALUE(monitor)--; \ MONITOR_VALUE(monitor)--; \
......
...@@ -285,22 +285,12 @@ definitions: */ ...@@ -285,22 +285,12 @@ definitions: */
#endif /* !UNIV_MUST_NOT_INLINE */ #endif /* !UNIV_MUST_NOT_INLINE */
#ifdef _WIN32 #define UNIV_WORD_SIZE SIZEOF_SIZE_T
#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
/** The following alignment is used in memory allocations in memory heap /** The following alignment is used in memory allocations in memory heap
management to ensure correct alignment for doubles etc. */ management to ensure correct alignment for doubles etc. */
#define UNIV_MEM_ALIGNMENT 8 #define UNIV_MEM_ALIGNMENT 8
/** The following alignment is used in aligning lints etc. */
#define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE
/* /*
DATABASE VERSION CONTROL DATABASE VERSION CONTROL
======================== ========================
......
This diff is collapsed.
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -643,11 +644,11 @@ static monitor_info_t innodb_counter_info[] = ...@@ -643,11 +644,11 @@ static monitor_info_t innodb_counter_info[] =
MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FSYNC}, MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FSYNC},
{"os_pending_reads", "os", "Number of reads pending", {"os_pending_reads", "os", "Number of reads pending",
MONITOR_NONE, MONITOR_DEFAULT_ON,
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_READS}, MONITOR_DEFAULT_START, MONITOR_OS_PENDING_READS},
{"os_pending_writes", "os", "Number of writes pending", {"os_pending_writes", "os", "Number of writes pending",
MONITOR_NONE, MONITOR_DEFAULT_ON,
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_WRITES}, MONITOR_DEFAULT_START, MONITOR_OS_PENDING_WRITES},
{"os_log_bytes_written", "os", {"os_log_bytes_written", "os",
......
...@@ -1409,10 +1409,10 @@ srv_export_innodb_status(void) ...@@ -1409,10 +1409,10 @@ srv_export_innodb_status(void)
mutex_enter(&srv_innodb_monitor_mutex); mutex_enter(&srv_innodb_monitor_mutex);
export_vars.innodb_data_pending_reads = export_vars.innodb_data_pending_reads =
os_n_pending_reads; MONITOR_VALUE(MONITOR_OS_PENDING_READS);
export_vars.innodb_data_pending_writes = export_vars.innodb_data_pending_writes =
os_n_pending_writes; MONITOR_VALUE(MONITOR_OS_PENDING_WRITES);
export_vars.innodb_data_pending_fsyncs = export_vars.innodb_data_pending_fsyncs =
fil_n_pending_log_flushes fil_n_pending_log_flushes
......
...@@ -1069,9 +1069,10 @@ sync_array_print_long_waits( ...@@ -1069,9 +1069,10 @@ sync_array_print_long_waits(
now the values of pending calls of these. */ now the values of pending calls of these. */
fprintf(stderr, fprintf(stderr,
"InnoDB: Pending preads %lu, pwrites %lu\n", "InnoDB: Pending reads " UINT64PF
(ulong) os_file_n_pending_preads, ", writes " UINT64PF "\n",
(ulong) os_file_n_pending_pwrites); MONITOR_VALUE(MONITOR_OS_PENDING_READS),
MONITOR_VALUE(MONITOR_OS_PENDING_WRITES));
srv_print_innodb_monitor = TRUE; srv_print_innodb_monitor = TRUE;
os_event_set(srv_monitor_event); os_event_set(srv_monitor_event);
......
...@@ -986,15 +986,11 @@ buf_read_recv_pages( ...@@ -986,15 +986,11 @@ buf_read_recv_pages(
count++; count++;
if (count > 1000) { if (count > 1000) {
fprintf(stderr, ib_logf(IB_LOG_LEVEL_ERROR,
"InnoDB: Error: InnoDB has waited for" "waited for 10 seconds for " ULINTPF
" 10 seconds for pending\n" " pending reads to the buffer pool to"
"InnoDB: reads to the buffer pool to" " be finished",
" be finished.\n" buf_pool->n_pend_reads);
"InnoDB: Number of pending reads %lu,"
" pending pread calls %lu\n",
(ulong) buf_pool->n_pend_reads,
(ulong) os_file_n_pending_preads);
os_aio_print_debug = TRUE; os_aio_print_debug = TRUE;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc. 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 Portions of this file contain modifications contributed and copyrighted
by Percona Inc.. Those modifications are by Percona Inc.. Those modifications are
...@@ -52,16 +52,6 @@ extern ibool os_has_said_disk_full; ...@@ -52,16 +52,6 @@ extern ibool os_has_said_disk_full;
/** Flag: enable debug printout for asynchronous i/o */ /** Flag: enable debug printout for asynchronous i/o */
extern ibool os_aio_print_debug; 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__ #ifdef __WIN__
/** We define always WIN_ASYNC_IO, and check at run-time whether /** We define always WIN_ASYNC_IO, and check at run-time whether
......
...@@ -718,10 +718,7 @@ os_atomic_clear(volatile lock_word_t* ptr) ...@@ -718,10 +718,7 @@ os_atomic_clear(volatile lock_word_t* ptr)
# define HAVE_ATOMIC_BUILTINS # define HAVE_ATOMIC_BUILTINS
# define HAVE_ATOMIC_BUILTINS_BYTE # define HAVE_ATOMIC_BUILTINS_BYTE
# define HAVE_ATOMIC_BUILTINS_64
# ifndef _WIN32
# define HAVE_ATOMIC_BUILTINS_64
# endif
/**********************************************************//** /**********************************************************//**
Atomic compare and exchange of signed integers (both 32 and 64 bit). Atomic compare and exchange of signed integers (both 32 and 64 bit).
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it 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 under the terms of the GNU General Public License as published by the
...@@ -541,22 +542,30 @@ on the counters */ ...@@ -541,22 +542,30 @@ on the counters */
/** Increment a monitor counter under mutex protection. /** Increment a monitor counter under mutex protection.
Use MONITOR_INC if appropriate mutex protection already exists. 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 monitor monitor to be incremented by 1
@param mutex mutex to acquire and relese */ @param enabled whether the monitor is enabled */
# define MONITOR_MUTEX_INC(mutex, monitor) \ #define MONITOR_MUTEX_INC_LOW(mutex, monitor, enabled) \
ut_ad(!mutex_own(mutex)); \ ut_ad(!mutex_own(mutex)); \
if (MONITOR_IS_ON(monitor)) { \ if (enabled) { \
mutex_enter(mutex); \ mutex_enter(mutex); \
if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \ if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \ MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
} \ } \
mutex_exit(mutex); \ 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. /** Decrement a monitor counter under mutex protection.
Use MONITOR_DEC if appropriate mutex protection already exists. 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 monitor monitor to be decremented by 1
@param mutex mutex to acquire and relese */ @param enabled whether the monitor is enabled */
# define MONITOR_MUTEX_DEC(mutex, monitor) \ #define MONITOR_MUTEX_DEC_LOW(mutex, monitor, enabled) \
ut_ad(!mutex_own(mutex)); \ ut_ad(!mutex_own(mutex)); \
if (MONITOR_IS_ON(monitor)) { \ if (MONITOR_IS_ON(monitor)) { \
mutex_enter(mutex); \ mutex_enter(mutex); \
...@@ -565,13 +574,20 @@ Use MONITOR_DEC if appropriate mutex protection already exists. ...@@ -565,13 +574,20 @@ Use MONITOR_DEC if appropriate mutex protection already exists.
} \ } \
mutex_exit(mutex); \ 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 #if defined HAVE_ATOMIC_BUILTINS_64
/** Atomically increment a monitor counter. /** Atomically increment a monitor counter.
Use MONITOR_INC if appropriate mutex protection exists. Use MONITOR_INC if appropriate mutex protection exists.
@param monitor monitor to be incremented by 1 */ @param monitor monitor to be incremented by 1
# define MONITOR_ATOMIC_INC(monitor) \ @param enabled whether the monitor is enabled */
if (MONITOR_IS_ON(monitor)) { \ # define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \
if (enabled) { \
ib_uint64_t value; \ ib_uint64_t value; \
value = os_atomic_increment_uint64( \ value = os_atomic_increment_uint64( \
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \ (ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
...@@ -584,9 +600,10 @@ Use MONITOR_INC if appropriate mutex protection exists. ...@@ -584,9 +600,10 @@ Use MONITOR_INC if appropriate mutex protection exists.
/** Atomically decrement a monitor counter. /** Atomically decrement a monitor counter.
Use MONITOR_DEC if appropriate mutex protection exists. Use MONITOR_DEC if appropriate mutex protection exists.
@param monitor monitor to be decremented by 1 */ @param monitor monitor to be decremented by 1
# define MONITOR_ATOMIC_DEC(monitor) \ @param enabled whether the monitor is enabled */
if (MONITOR_IS_ON(monitor)) { \ # define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \
if (enabled) { \
ib_uint64_t value; \ ib_uint64_t value; \
value = os_atomic_decrement_uint64( \ value = os_atomic_decrement_uint64( \
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \ (ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
...@@ -617,14 +634,29 @@ srv_mon_free(void); ...@@ -617,14 +634,29 @@ srv_mon_free(void);
/** Atomically increment a monitor counter. /** Atomically increment a monitor counter.
Use MONITOR_INC if appropriate mutex protection exists. Use MONITOR_INC if appropriate mutex protection exists.
@param monitor monitor to be incremented by 1 */ @param monitor monitor to be incremented by 1
# define MONITOR_ATOMIC_INC(monitor) MONITOR_MUTEX_INC(&monitor_mutex, monitor) @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. /** Atomically decrement a monitor counter.
Use MONITOR_DEC if appropriate mutex protection exists. Use MONITOR_DEC if appropriate mutex protection exists.
@param monitor monitor to be decremented by 1 */ @param monitor monitor to be decremented by 1
# define MONITOR_ATOMIC_DEC(monitor) MONITOR_MUTEX_DEC(&monitor_mutex, monitor) @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 */ #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) \ #define MONITOR_DEC(monitor) \
if (MONITOR_IS_ON(monitor)) { \ if (MONITOR_IS_ON(monitor)) { \
MONITOR_VALUE(monitor)--; \ MONITOR_VALUE(monitor)--; \
......
...@@ -304,22 +304,12 @@ definitions: */ ...@@ -304,22 +304,12 @@ definitions: */
#endif /* !UNIV_MUST_NOT_INLINE */ #endif /* !UNIV_MUST_NOT_INLINE */
#ifdef _WIN32 #define UNIV_WORD_SIZE SIZEOF_SIZE_T
#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
/** The following alignment is used in memory allocations in memory heap /** The following alignment is used in memory allocations in memory heap
management to ensure correct alignment for doubles etc. */ management to ensure correct alignment for doubles etc. */
#define UNIV_MEM_ALIGNMENT 8 #define UNIV_MEM_ALIGNMENT 8
/** The following alignment is used in aligning lints etc. */
#define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE
/* /*
DATABASE VERSION CONTROL DATABASE VERSION CONTROL
======================== ========================
......
This diff is collapsed.
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -643,11 +644,11 @@ static monitor_info_t innodb_counter_info[] = ...@@ -643,11 +644,11 @@ static monitor_info_t innodb_counter_info[] =
MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FSYNC}, MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FSYNC},
{"os_pending_reads", "os", "Number of reads pending", {"os_pending_reads", "os", "Number of reads pending",
MONITOR_NONE, MONITOR_DEFAULT_ON,
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_READS}, MONITOR_DEFAULT_START, MONITOR_OS_PENDING_READS},
{"os_pending_writes", "os", "Number of writes pending", {"os_pending_writes", "os", "Number of writes pending",
MONITOR_NONE, MONITOR_DEFAULT_ON,
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_WRITES}, MONITOR_DEFAULT_START, MONITOR_OS_PENDING_WRITES},
{"os_log_bytes_written", "os", {"os_log_bytes_written", "os",
......
...@@ -1735,10 +1735,10 @@ srv_export_innodb_status(void) ...@@ -1735,10 +1735,10 @@ srv_export_innodb_status(void)
mutex_enter(&srv_innodb_monitor_mutex); mutex_enter(&srv_innodb_monitor_mutex);
export_vars.innodb_data_pending_reads = export_vars.innodb_data_pending_reads =
os_n_pending_reads; MONITOR_VALUE(MONITOR_OS_PENDING_READS);
export_vars.innodb_data_pending_writes = export_vars.innodb_data_pending_writes =
os_n_pending_writes; MONITOR_VALUE(MONITOR_OS_PENDING_WRITES);
export_vars.innodb_data_pending_fsyncs = export_vars.innodb_data_pending_fsyncs =
fil_n_pending_log_flushes fil_n_pending_log_flushes
......
...@@ -1161,9 +1161,10 @@ sync_array_print_long_waits( ...@@ -1161,9 +1161,10 @@ sync_array_print_long_waits(
now the values of pending calls of these. */ now the values of pending calls of these. */
fprintf(stderr, fprintf(stderr,
"InnoDB: Pending preads %lu, pwrites %lu\n", "InnoDB: Pending reads " UINT64PF
(ulong) os_file_n_pending_preads, ", writes " UINT64PF "\n",
(ulong) os_file_n_pending_pwrites); MONITOR_VALUE(MONITOR_OS_PENDING_READS),
MONITOR_VALUE(MONITOR_OS_PENDING_WRITES));
srv_print_innodb_monitor = TRUE; srv_print_innodb_monitor = TRUE;
os_event_set(srv_monitor_event); os_event_set(srv_monitor_event);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment