45 #if defined(UNIV_DEBUG) && !defined(UNIV_HOTBACKUP)
46 extern "C" my_bool timed_mutexes;
49 #ifdef HAVE_WINDOWS_ATOMICS
50 typedef LONG lock_word_t;
52 #elif defined(HAVE_ATOMIC_BUILTINS) && !defined(HAVE_ATOMIC_BUILTINS_BYTE)
53 typedef ulint lock_word_t;
55 typedef byte lock_word_t;
58 #if defined UNIV_PFS_MUTEX || defined UNIV_PFS_RWLOCK
62 # define PFS_SKIP_BUFFER_MUTEX_RWLOCK
65 # define PFS_SKIP_EVENT_MUTEX
71 extern mysql_pfs_key_t autoinc_mutex_key;
72 extern mysql_pfs_key_t buffer_block_mutex_key;
73 extern mysql_pfs_key_t buf_pool_mutex_key;
74 extern mysql_pfs_key_t buf_pool_zip_mutex_key;
75 extern mysql_pfs_key_t cache_last_read_mutex_key;
76 extern mysql_pfs_key_t dict_foreign_err_mutex_key;
77 extern mysql_pfs_key_t dict_sys_mutex_key;
78 extern mysql_pfs_key_t file_format_max_mutex_key;
79 extern mysql_pfs_key_t fil_system_mutex_key;
80 extern mysql_pfs_key_t flush_list_mutex_key;
81 extern mysql_pfs_key_t fts_bg_threads_mutex_key;
82 extern mysql_pfs_key_t fts_delete_mutex_key;
83 extern mysql_pfs_key_t fts_optimize_mutex_key;
84 extern mysql_pfs_key_t fts_doc_id_mutex_key;
85 extern mysql_pfs_key_t fts_pll_tokenize_mutex_key;
86 extern mysql_pfs_key_t hash_table_mutex_key;
87 extern mysql_pfs_key_t ibuf_bitmap_mutex_key;
88 extern mysql_pfs_key_t ibuf_mutex_key;
89 extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
90 extern mysql_pfs_key_t log_sys_mutex_key;
91 extern mysql_pfs_key_t log_flush_order_mutex_key;
92 # ifndef HAVE_ATOMIC_BUILTINS
93 extern mysql_pfs_key_t server_mutex_key;
95 # ifdef UNIV_MEM_DEBUG
96 extern mysql_pfs_key_t mem_hash_mutex_key;
98 extern mysql_pfs_key_t mem_pool_mutex_key;
99 extern mysql_pfs_key_t mutex_list_mutex_key;
100 extern mysql_pfs_key_t purge_sys_bh_mutex_key;
101 extern mysql_pfs_key_t recv_sys_mutex_key;
102 extern mysql_pfs_key_t recv_writer_mutex_key;
103 extern mysql_pfs_key_t rseg_mutex_key;
104 # ifdef UNIV_SYNC_DEBUG
105 extern mysql_pfs_key_t rw_lock_debug_mutex_key;
107 extern mysql_pfs_key_t rw_lock_list_mutex_key;
108 extern mysql_pfs_key_t rw_lock_mutex_key;
109 extern mysql_pfs_key_t srv_dict_tmpfile_mutex_key;
110 extern mysql_pfs_key_t srv_innodb_monitor_mutex_key;
111 extern mysql_pfs_key_t srv_misc_tmpfile_mutex_key;
112 extern mysql_pfs_key_t srv_threads_mutex_key;
113 extern mysql_pfs_key_t srv_monitor_file_mutex_key;
114 # ifdef UNIV_SYNC_DEBUG
115 extern mysql_pfs_key_t sync_thread_mutex_key;
117 extern mysql_pfs_key_t buf_dblwr_mutex_key;
118 extern mysql_pfs_key_t trx_undo_mutex_key;
119 extern mysql_pfs_key_t trx_mutex_key;
120 extern mysql_pfs_key_t lock_sys_mutex_key;
121 extern mysql_pfs_key_t lock_sys_wait_mutex_key;
122 extern mysql_pfs_key_t trx_sys_mutex_key;
123 extern mysql_pfs_key_t srv_sys_mutex_key;
124 extern mysql_pfs_key_t srv_sys_tasks_mutex_key;
125 #ifndef HAVE_ATOMIC_BUILTINS
126 extern mysql_pfs_key_t srv_conc_mutex_key;
128 #ifndef HAVE_ATOMIC_BUILTINS_64
129 extern mysql_pfs_key_t monitor_mutex_key;
131 extern mysql_pfs_key_t event_os_mutex_key;
132 extern mysql_pfs_key_t ut_list_mutex_key;
133 extern mysql_pfs_key_t os_mutex_key;
134 extern mysql_pfs_key_t zip_pad_mutex_key;
152 #ifdef UNIV_PFS_MUTEX
176 # ifdef UNIV_SYNC_DEBUG
177 # define mutex_create(K, M, level) \
178 pfs_mutex_create_func((K), (M), #M, (level), __FILE__, __LINE__)
180 # define mutex_create(K, M, level) \
181 pfs_mutex_create_func((K), (M), #M, __FILE__, __LINE__)
184 # define mutex_create(K, M, level) \
185 pfs_mutex_create_func((K), (M), __FILE__, __LINE__)
188 # define mutex_enter(M) \
189 pfs_mutex_enter_func((M), __FILE__, __LINE__)
191 # define mutex_enter_nowait(M) \
192 pfs_mutex_enter_nowait_func((M), __FILE__, __LINE__)
194 # define mutex_exit(M) pfs_mutex_exit_func(M)
196 # define mutex_free(M) pfs_mutex_free_func(M)
203 # ifdef UNIV_SYNC_DEBUG
204 # define mutex_create(K, M, level) \
205 mutex_create_func((M), #M, (level), __FILE__, __LINE__)
207 # define mutex_create(K, M, level) \
208 mutex_create_func((M), #M, __FILE__, __LINE__)
211 # define mutex_create(K, M, level) \
212 mutex_create_func((M), __FILE__, __LINE__)
215 # define mutex_enter(M) mutex_enter_func((M), __FILE__, __LINE__)
217 # define mutex_enter_nowait(M) \
218 mutex_enter_nowait_func((M), __FILE__, __LINE__)
220 # define mutex_exit(M) mutex_exit_func(M)
222 # define mutex_free(M) mutex_free_func(M)
237 const char* cmutex_name,
238 # ifdef UNIV_SYNC_DEBUG
242 const char* cfile_name,
261 #define mutex_enter_fast(M) mutex_enter_func((M), __FILE__, __LINE__)
297 #ifdef UNIV_PFS_MUTEX
306 pfs_mutex_create_func(
311 const char* cmutex_name,
312 # ifdef UNIV_SYNC_DEBUG
316 const char* cfile_name,
325 pfs_mutex_enter_func(
338 pfs_mutex_enter_nowait_func(
368 #ifdef UNIV_SYNC_DEBUG
412 __attribute__((warn_unused_result));
414 #ifdef UNIV_SYNC_DEBUG
427 __attribute__((nonnull));
455 ibool dict_mutex_allowed)
457 __attribute__((warn_unused_result));
461 #define sync_thread_levels_empty_except_dict() \
462 (!sync_thread_levels_nonempty_gen(TRUE))
471 ibool has_search_latch)
474 __attribute__((warn_unused_result));
503 #ifdef UNIV_SYNC_DEBUG
652 #define SYNC_USER_TRX_LOCK 9999
653 #define SYNC_NO_ORDER_CHECK 3000
655 #define SYNC_LEVEL_VARYING 2000
661 #define SYNC_TRX_I_S_RWLOCK 1910
663 #define SYNC_TRX_I_S_LAST_READ 1900
665 #define SYNC_FILE_FORMAT_TAG 1200
667 #define SYNC_DICT_OPERATION 1010
671 #define SYNC_FTS_CACHE 1005
672 #define SYNC_DICT 1000
673 #define SYNC_DICT_AUTOINC_MUTEX 999
674 #define SYNC_STATS_AUTO_RECALC 997
675 #define SYNC_DICT_HEADER 995
676 #define SYNC_IBUF_HEADER 914
677 #define SYNC_IBUF_PESS_INSERT_MUTEX 912
679 #define SYNC_INDEX_TREE 900
680 #define SYNC_TREE_NODE_NEW 892
681 #define SYNC_TREE_NODE_FROM_HASH 891
682 #define SYNC_TREE_NODE 890
683 #define SYNC_PURGE_LATCH 800
684 #define SYNC_TRX_UNDO 700
685 #define SYNC_RSEG 600
686 #define SYNC_RSEG_HEADER_NEW 591
687 #define SYNC_RSEG_HEADER 590
688 #define SYNC_TRX_UNDO_PAGE 570
689 #define SYNC_EXTERN_STORAGE 500
691 #define SYNC_FSP_PAGE 395
693 #define SYNC_IBUF_MUTEX 370
695 #define SYNC_IBUF_INDEX_TREE 360
696 #define SYNC_IBUF_TREE_NODE_NEW 359
697 #define SYNC_IBUF_TREE_NODE 358
698 #define SYNC_IBUF_BITMAP_MUTEX 351
699 #define SYNC_IBUF_BITMAP 350
701 #define SYNC_INDEX_ONLINE_LOG 340
705 #define SYNC_LOCK_WAIT_SYS 300
706 #define SYNC_LOCK_SYS 299
707 #define SYNC_TRX_SYS 298
709 #define SYNC_THREADS 295
710 #define SYNC_REC_LOCK 294
711 #define SYNC_TRX_SYS_HEADER 290
712 #define SYNC_PURGE_QUEUE 200
714 #define SYNC_LOG_FLUSH_ORDER 147
715 #define SYNC_RECV 168
716 #define SYNC_FTS_TOKENIZE 167
717 #define SYNC_FTS_CACHE_INIT 166
718 #define SYNC_FTS_BG_THREADS 165
719 #define SYNC_FTS_OPTIMIZE 164 // FIXME: is this correct number, test
720 #define SYNC_WORK_QUEUE 162
721 #define SYNC_SEARCH_SYS 160
727 #define SYNC_BUF_POOL 150
728 #define SYNC_BUF_PAGE_HASH 149
729 #define SYNC_BUF_BLOCK 146
730 #define SYNC_BUF_FLUSH_LIST 145
731 #define SYNC_DOUBLEWRITE 140
732 #define SYNC_ANY_LATCH 135
733 #define SYNC_MEM_HASH 131
734 #define SYNC_MEM_POOL 130
737 #define RW_LOCK_NOT_LOCKED 350
738 #define RW_LOCK_EX 351
739 #define RW_LOCK_EXCLUSIVE 351
740 #define RW_LOCK_SHARED 352
741 #define RW_LOCK_WAIT_EX 353
742 #define SYNC_MUTEX 354
755 #if !defined(HAVE_ATOMIC_BUILTINS)
766 #ifdef UNIV_SYNC_DEBUG
777 # define MUTEX_MAGIC_N 979585UL
785 #ifdef UNIV_PFS_MUTEX
786 struct PSI_mutex* pfs_psi;
795 #define SYNC_SPIN_ROUNDS srv_n_spin_wait_rounds
800 #ifdef UNIV_SYNC_DEBUG
811 extern ut_list_base_node_t mutex_list;
816 #ifndef HAVE_ATOMIC_BUILTINS