| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 1995, 2026, Oracle and/or its affiliates. |
| 4 |
Copyright (c) 2008, Google Inc. |
| 5 |
Copyright (c) 2012, Facebook Inc. |
| 6 |
|
| 7 |
Portions of this file contain modifications contributed and copyrighted by |
| 8 |
Google, Inc. Those modifications are gratefully acknowledged and are described |
| 9 |
briefly in the InnoDB documentation. The contributions by Google are |
| 10 |
incorporated with their permission, and subject to the conditions contained in |
| 11 |
the file COPYING.Google. |
| 12 |
|
| 13 |
This program is free software; you can redistribute it and/or modify it under |
| 14 |
the terms of the GNU General Public License, version 2.0, as published by the |
| 15 |
Free Software Foundation. |
| 16 |
|
| 17 |
This program is designed to work with certain software (including |
| 18 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 19 |
as designated in a particular file or component or in included license |
| 20 |
documentation. The authors of MySQL hereby grant you an additional |
| 21 |
permission to link the program and your derivative works with the |
| 22 |
separately licensed software that they have either included with |
| 23 |
the program or referenced in the documentation. |
| 24 |
|
| 25 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 26 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 27 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, |
| 28 |
for more details. |
| 29 |
|
| 30 |
You should have received a copy of the GNU General Public License along with |
| 31 |
this program; if not, write to the Free Software Foundation, Inc., |
| 32 |
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 33 |
|
| 34 |
*****************************************************************************/ |
| 35 |
|
| 36 |
/** @file include/sync0sync.h |
| 37 |
Mutex, the basic synchronization primitive |
| 38 |
|
| 39 |
Created 9/5/1995 Heikki Tuuri |
| 40 |
*******************************************************/ |
| 41 |
|
| 42 |
#ifndef sync0sync_h |
| 43 |
#define sync0sync_h |
| 44 |
|
| 45 |
#include "univ.i" |
| 46 |
#include "ut0counter.h" |
| 47 |
|
| 48 |
#ifdef HAVE_PSI_INTERFACE |
| 49 |
|
| 50 |
/** Define for performance schema registration key */ |
| 51 |
struct mysql_pfs_key_t { |
| 52 |
public: |
| 53 |
/** Default Constructor */ |
| 54 |
mysql_pfs_key_t() { s_count++; } |
| 55 |
|
| 56 |
/** Constructor */ |
| 57 |
mysql_pfs_key_t(unsigned int val) : m_value(val) {} |
| 58 |
|
| 59 |
/** Retrieve the count. |
| 60 |
@return number of keys defined */ |
| 61 |
static int get_count() { return s_count; } |
| 62 |
|
| 63 |
/* Key value. */ |
| 64 |
unsigned int m_value; |
| 65 |
|
| 66 |
private: |
| 67 |
/** To keep count of number of PS keys defined. */ |
| 68 |
static unsigned int s_count; |
| 69 |
}; |
| 70 |
|
| 71 |
#endif /* HAVE_PFS_INTERFACE */ |
| 72 |
|
| 73 |
#if defined UNIV_PFS_MUTEX || defined UNIV_PFS_RWLOCK |
| 74 |
|
| 75 |
/* By default, buffer mutexes and rwlocks will be excluded from |
| 76 |
instrumentation due to their large number of instances. */ |
| 77 |
#define PFS_SKIP_BUFFER_MUTEX_RWLOCK |
| 78 |
|
| 79 |
/* By default, event->mutex will also be excluded from instrumentation */ |
| 80 |
#define PFS_SKIP_EVENT_MUTEX |
| 81 |
|
| 82 |
#endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */ |
| 83 |
|
| 84 |
#ifdef UNIV_PFS_MUTEX |
| 85 |
/* Key defines to register InnoDB mutexes with performance schema */ |
| 86 |
extern mysql_pfs_key_t alter_stage_mutex_key; |
| 87 |
extern mysql_pfs_key_t autoinc_mutex_key; |
| 88 |
extern mysql_pfs_key_t autoinc_persisted_mutex_key; |
| 89 |
#ifndef PFS_SKIP_BUFFER_MUTEX_RWLOCK |
| 90 |
extern mysql_pfs_key_t buffer_block_mutex_key; |
| 91 |
#endif /* !PFS_SKIP_BUFFER_MUTEX_RWLOCK */ |
| 92 |
extern mysql_pfs_key_t buf_pool_chunks_mutex_key; |
| 93 |
extern mysql_pfs_key_t buf_pool_flush_state_mutex_key; |
| 94 |
extern mysql_pfs_key_t buf_pool_LRU_list_mutex_key; |
| 95 |
extern mysql_pfs_key_t buf_pool_free_list_mutex_key; |
| 96 |
extern mysql_pfs_key_t buf_pool_zip_free_mutex_key; |
| 97 |
extern mysql_pfs_key_t buf_pool_zip_hash_mutex_key; |
| 98 |
extern mysql_pfs_key_t buf_pool_zip_mutex_key; |
| 99 |
extern mysql_pfs_key_t ddl_autoinc_mutex_key; |
| 100 |
extern mysql_pfs_key_t dict_foreign_err_mutex_key; |
| 101 |
extern mysql_pfs_key_t dict_persist_dirty_tables_mutex_key; |
| 102 |
extern mysql_pfs_key_t dict_sys_mutex_key; |
| 103 |
extern mysql_pfs_key_t dict_table_mutex_key; |
| 104 |
extern mysql_pfs_key_t parser_mutex_key; |
| 105 |
extern mysql_pfs_key_t fil_system_mutex_key; |
| 106 |
extern mysql_pfs_key_t flush_list_mutex_key; |
| 107 |
extern mysql_pfs_key_t fts_bg_threads_mutex_key; |
| 108 |
extern mysql_pfs_key_t fts_delete_mutex_key; |
| 109 |
extern mysql_pfs_key_t fts_optimize_mutex_key; |
| 110 |
extern mysql_pfs_key_t fts_doc_id_mutex_key; |
| 111 |
extern mysql_pfs_key_t fts_pll_tokenize_mutex_key; |
| 112 |
extern mysql_pfs_key_t hash_table_mutex_key; |
| 113 |
extern mysql_pfs_key_t ibuf_bitmap_mutex_key; |
| 114 |
extern mysql_pfs_key_t ibuf_mutex_key; |
| 115 |
extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key; |
| 116 |
extern mysql_pfs_key_t lock_free_hash_mutex_key; |
| 117 |
extern mysql_pfs_key_t log_checkpointer_mutex_key; |
| 118 |
extern mysql_pfs_key_t log_closer_mutex_key; |
| 119 |
extern mysql_pfs_key_t log_writer_mutex_key; |
| 120 |
extern mysql_pfs_key_t log_flusher_mutex_key; |
| 121 |
extern mysql_pfs_key_t log_write_notifier_mutex_key; |
| 122 |
extern mysql_pfs_key_t log_flush_notifier_mutex_key; |
| 123 |
extern mysql_pfs_key_t log_limits_mutex_key; |
| 124 |
extern mysql_pfs_key_t log_files_mutex_key; |
| 125 |
extern mysql_pfs_key_t log_cmdq_mutex_key; |
| 126 |
extern mysql_pfs_key_t log_sn_lock_key; |
| 127 |
extern mysql_pfs_key_t log_sn_mutex_key; |
| 128 |
extern mysql_pfs_key_t log_sys_arch_mutex_key; |
| 129 |
extern mysql_pfs_key_t page_sys_arch_mutex_key; |
| 130 |
extern mysql_pfs_key_t page_sys_arch_oper_mutex_key; |
| 131 |
extern mysql_pfs_key_t page_sys_arch_client_mutex_key; |
| 132 |
extern mysql_pfs_key_t mutex_list_mutex_key; |
| 133 |
extern mysql_pfs_key_t recalc_pool_mutex_key; |
| 134 |
extern mysql_pfs_key_t page_cleaner_mutex_key; |
| 135 |
extern mysql_pfs_key_t purge_sys_pq_mutex_key; |
| 136 |
extern mysql_pfs_key_t recv_sys_mutex_key; |
| 137 |
extern mysql_pfs_key_t recv_writer_mutex_key; |
| 138 |
extern mysql_pfs_key_t rtr_active_mutex_key; |
| 139 |
extern mysql_pfs_key_t rtr_match_mutex_key; |
| 140 |
extern mysql_pfs_key_t rtr_path_mutex_key; |
| 141 |
extern mysql_pfs_key_t rtr_ssn_mutex_key; |
| 142 |
extern mysql_pfs_key_t temp_space_rseg_mutex_key; |
| 143 |
extern mysql_pfs_key_t undo_space_rseg_mutex_key; |
| 144 |
extern mysql_pfs_key_t trx_sys_rseg_mutex_key; |
| 145 |
extern mysql_pfs_key_t page_zip_stat_per_index_mutex_key; |
| 146 |
#ifdef UNIV_DEBUG |
| 147 |
extern mysql_pfs_key_t rw_lock_debug_mutex_key; |
| 148 |
#endif /* UNIV_DEBUG */ |
| 149 |
extern mysql_pfs_key_t rw_lock_list_mutex_key; |
| 150 |
extern mysql_pfs_key_t rw_lock_mutex_key; |
| 151 |
extern mysql_pfs_key_t srv_innodb_monitor_mutex_key; |
| 152 |
extern mysql_pfs_key_t srv_misc_tmpfile_mutex_key; |
| 153 |
extern mysql_pfs_key_t srv_monitor_file_mutex_key; |
| 154 |
#ifdef UNIV_DEBUG |
| 155 |
extern mysql_pfs_key_t sync_thread_mutex_key; |
| 156 |
#endif /* UNIV_DEBUG */ |
| 157 |
extern mysql_pfs_key_t trx_undo_mutex_key; |
| 158 |
extern mysql_pfs_key_t trx_mutex_key; |
| 159 |
extern mysql_pfs_key_t trx_pool_mutex_key; |
| 160 |
extern mysql_pfs_key_t trx_pool_manager_mutex_key; |
| 161 |
extern mysql_pfs_key_t temp_pool_manager_mutex_key; |
| 162 |
extern mysql_pfs_key_t lock_sys_page_mutex_key; |
| 163 |
extern mysql_pfs_key_t lock_sys_table_mutex_key; |
| 164 |
extern mysql_pfs_key_t lock_wait_mutex_key; |
| 165 |
extern mysql_pfs_key_t trx_sys_mutex_key; |
| 166 |
extern mysql_pfs_key_t trx_sys_shard_mutex_key; |
| 167 |
extern mysql_pfs_key_t trx_sys_serialisation_mutex_key; |
| 168 |
extern mysql_pfs_key_t srv_sys_mutex_key; |
| 169 |
extern mysql_pfs_key_t srv_threads_mutex_key; |
| 170 |
#ifndef PFS_SKIP_EVENT_MUTEX |
| 171 |
extern mysql_pfs_key_t event_mutex_key; |
| 172 |
extern mysql_pfs_key_t event_manager_mutex_key; |
| 173 |
#endif /* !PFS_SKIP_EVENT_MUTEX */ |
| 174 |
extern mysql_pfs_key_t sync_array_mutex_key; |
| 175 |
extern mysql_pfs_key_t zip_pad_mutex_key; |
| 176 |
extern mysql_pfs_key_t row_drop_list_mutex_key; |
| 177 |
extern mysql_pfs_key_t file_open_mutex_key; |
| 178 |
extern mysql_pfs_key_t master_key_id_mutex_key; |
| 179 |
extern mysql_pfs_key_t clone_sys_mutex_key; |
| 180 |
extern mysql_pfs_key_t clone_task_mutex_key; |
| 181 |
extern mysql_pfs_key_t clone_snapshot_mutex_key; |
| 182 |
extern mysql_pfs_key_t parallel_read_mutex_key; |
| 183 |
extern mysql_pfs_key_t dblwr_mutex_key; |
| 184 |
extern mysql_pfs_key_t ahi_enabled_mutex_key; |
| 185 |
#endif /* UNIV_PFS_MUTEX */ |
| 186 |
|
| 187 |
#ifdef UNIV_PFS_RWLOCK |
| 188 |
/* Following are rwlock keys used to register with MySQL |
| 189 |
performance schema */ |
| 190 |
extern mysql_pfs_key_t btr_search_latch_key; |
| 191 |
#ifndef PFS_SKIP_BUFFER_MUTEX_RWLOCK |
| 192 |
extern mysql_pfs_key_t buf_block_lock_key; |
| 193 |
#endif /* !PFS_SKIP_BUFFER_MUTEX_RWLOCK */ |
| 194 |
#ifdef UNIV_DEBUG |
| 195 |
extern mysql_pfs_key_t buf_block_debug_latch_key; |
| 196 |
#endif /* UNIV_DEBUG */ |
| 197 |
extern mysql_pfs_key_t dict_operation_lock_key; |
| 198 |
extern mysql_pfs_key_t undo_spaces_lock_key; |
| 199 |
extern mysql_pfs_key_t rsegs_lock_key; |
| 200 |
extern mysql_pfs_key_t lock_sys_global_rw_lock_key; |
| 201 |
extern mysql_pfs_key_t fil_space_latch_key; |
| 202 |
extern mysql_pfs_key_t fts_cache_rw_lock_key; |
| 203 |
extern mysql_pfs_key_t fts_cache_init_rw_lock_key; |
| 204 |
extern mysql_pfs_key_t trx_i_s_cache_lock_key; |
| 205 |
extern mysql_pfs_key_t trx_purge_latch_key; |
| 206 |
extern mysql_pfs_key_t index_tree_rw_lock_key; |
| 207 |
extern mysql_pfs_key_t index_online_log_key; |
| 208 |
extern mysql_pfs_key_t dict_table_stats_key; |
| 209 |
extern mysql_pfs_key_t trx_sys_rw_lock_key; |
| 210 |
extern mysql_pfs_key_t hash_table_locks_key; |
| 211 |
#endif /* UNIV_PFS_RWLOCK */ |
| 212 |
|
| 213 |
#ifdef HAVE_PSI_INTERFACE |
| 214 |
/* There are mutexes/rwlocks that we want to exclude from instrumentation |
| 215 |
even if their corresponding performance schema define is set. And this |
| 216 |
PFS_NOT_INSTRUMENTED is used as the key value to identify those objects that |
| 217 |
would be excluded from instrumentation.*/ |
| 218 |
extern mysql_pfs_key_t PFS_NOT_INSTRUMENTED; |
| 219 |
#endif /* HAVE_PFS_INTERFACE */ |
| 220 |
|
| 221 |
/** Prints info of the sync system. |
| 222 |
@param[in] file where to print */ |
| 223 |
void sync_print(FILE *file); |
| 224 |
|
| 225 |
#endif /* !sync0sync_h */ |