105
105
set only when UNIV_SYNC_PERF_STAT is defined */
106
106
extern ib_int64_t rw_x_exit_count;
108
#ifdef UNIV_PFS_RWLOCK
109
/* Following are rwlock keys used to register with MySQL
110
performance schema */
111
# ifdef UNIV_LOG_ARCHIVE
112
extern mysql_pfs_key_t archive_lock_key;
113
# endif /* UNIV_LOG_ARCHIVE */
114
extern mysql_pfs_key_t btr_search_latch_key;
115
extern mysql_pfs_key_t buf_block_lock_key;
116
# ifdef UNIV_SYNC_DEBUG
117
extern mysql_pfs_key_t buf_block_debug_latch_key;
118
# endif /* UNIV_SYNC_DEBUG */
119
extern mysql_pfs_key_t dict_operation_lock_key;
120
extern mysql_pfs_key_t fil_space_latch_key;
121
extern mysql_pfs_key_t checkpoint_lock_key;
122
extern mysql_pfs_key_t trx_i_s_cache_lock_key;
123
extern mysql_pfs_key_t trx_purge_latch_key;
124
extern mysql_pfs_key_t index_tree_rw_lock_key;
125
#endif /* UNIV_PFS_RWLOCK */
128
#ifndef UNIV_PFS_RWLOCK
129
108
/******************************************************************//**
130
109
Creates, or rather, initializes an rw-lock object in a specified memory
131
110
location (which must be appropriately aligned). The rw-lock is initialized
132
111
to the non-locked state. Explicit freeing of the rw-lock with rw_lock_free
133
is necessary only if the memory block containing it is freed.
134
if MySQL performance schema is enabled and "UNIV_PFS_RWLOCK" is
135
defined, the rwlock are instrumented with performance schema probes. */
137
# ifdef UNIV_SYNC_DEBUG
138
# define rw_lock_create(K, L, level) \
112
is necessary only if the memory block containing it is freed. */
114
# ifdef UNIV_SYNC_DEBUG
115
# define rw_lock_create(L, level) \
139
116
rw_lock_create_func((L), (level), #L, __FILE__, __LINE__)
140
# else /* UNIV_SYNC_DEBUG */
141
# define rw_lock_create(K, L, level) \
117
# else /* UNIV_SYNC_DEBUG */
118
# define rw_lock_create(L, level) \
142
119
rw_lock_create_func((L), #L, __FILE__, __LINE__)
143
# endif/* UNIV_SYNC_DEBUG */
144
# else /* UNIV_DEBUG */
145
# define rw_lock_create(K, L, level) \
120
# endif /* UNIV_SYNC_DEBUG */
121
#else /* UNIV_DEBUG */
122
# define rw_lock_create(L, level) \
146
123
rw_lock_create_func((L), __FILE__, __LINE__)
147
# endif /* UNIV_DEBUG */
149
/**************************************************************//**
150
NOTE! The following macros should be used in rw locking and
151
unlocking, not the corresponding function. */
153
# define rw_lock_s_lock(M) \
154
rw_lock_s_lock_func((M), 0, __FILE__, __LINE__)
156
# define rw_lock_s_lock_gen(M, P) \
157
rw_lock_s_lock_func((M), (P), __FILE__, __LINE__)
159
# define rw_lock_s_lock_nowait(M, F, L) \
160
rw_lock_s_lock_low((M), 0, (F), (L))
162
# ifdef UNIV_SYNC_DEBUG
163
# define rw_lock_s_unlock_gen(L, P) rw_lock_s_unlock_func(P, L)
165
# define rw_lock_s_unlock_gen(L, P) rw_lock_s_unlock_func(L)
169
# define rw_lock_x_lock(M) \
170
rw_lock_x_lock_func((M), 0, __FILE__, __LINE__)
172
# define rw_lock_x_lock_gen(M, P) \
173
rw_lock_x_lock_func((M), (P), __FILE__, __LINE__)
175
# define rw_lock_x_lock_nowait(M) \
176
rw_lock_x_lock_func_nowait((M), __FILE__, __LINE__)
178
# ifdef UNIV_SYNC_DEBUG
179
# define rw_lock_x_unlock_gen(L, P) rw_lock_x_unlock_func(P, L)
181
# define rw_lock_x_unlock_gen(L, P) rw_lock_x_unlock_func(L)
184
# define rw_lock_free(M) rw_lock_free_func(M)
186
#else /* !UNIV_PFS_RWLOCK */
188
/* Following macros point to Performance Schema instrumented functions. */
190
# ifdef UNIV_SYNC_DEBUG
191
# define rw_lock_create(K, L, level) \
192
pfs_rw_lock_create_func((K), (L), (level), #L, __FILE__, __LINE__)
193
# else /* UNIV_SYNC_DEBUG */
194
# define rw_lock_create(K, L, level) \
195
pfs_rw_lock_create_func((K), (L), #L, __FILE__, __LINE__)
196
# endif/* UNIV_SYNC_DEBUG */
197
# else /* UNIV_DEBUG */
198
# define rw_lock_create(K, L, level) \
199
pfs_rw_lock_create_func((K), (L), __FILE__, __LINE__)
200
# endif /* UNIV_DEBUG */
202
/******************************************************************
203
NOTE! The following macros should be used in rw locking and
204
unlocking, not the corresponding function. */
206
# define rw_lock_s_lock(M) \
207
pfs_rw_lock_s_lock_func((M), 0, __FILE__, __LINE__)
209
# define rw_lock_s_lock_gen(M, P) \
210
pfs_rw_lock_s_lock_func((M), (P), __FILE__, __LINE__)
212
# define rw_lock_s_lock_nowait(M, F, L) \
213
pfs_rw_lock_s_lock_low((M), 0, (F), (L))
215
# ifdef UNIV_SYNC_DEBUG
216
# define rw_lock_s_unlock_gen(L, P) pfs_rw_lock_s_unlock_func(P, L)
218
# define rw_lock_s_unlock_gen(L, P) pfs_rw_lock_s_unlock_func(L)
221
# define rw_lock_x_lock(M) \
222
pfs_rw_lock_x_lock_func((M), 0, __FILE__, __LINE__)
224
# define rw_lock_x_lock_gen(M, P) \
225
pfs_rw_lock_x_lock_func((M), (P), __FILE__, __LINE__)
227
# define rw_lock_x_lock_nowait(M) \
228
pfs_rw_lock_x_lock_func_nowait((M), __FILE__, __LINE__)
230
# ifdef UNIV_SYNC_DEBUG
231
# define rw_lock_x_unlock_gen(L, P) pfs_rw_lock_x_unlock_func(P, L)
233
# define rw_lock_x_unlock_gen(L, P) pfs_rw_lock_x_unlock_func(L)
236
# define rw_lock_free(M) pfs_rw_lock_free_func(M)
238
#endif /* UNIV_PFS_RWLOCK */
240
#define rw_lock_s_unlock(L) rw_lock_s_unlock_gen(L, 0)
241
#define rw_lock_x_unlock(L) rw_lock_x_unlock_gen(L, 0)
124
#endif /* UNIV_DEBUG */
243
126
/******************************************************************//**
244
127
Creates, or rather, initializes an rw-lock object in a specified memory
333
234
rw_lock_t* lock); /*!< in/out: rw-lock */
236
#ifdef UNIV_SYNC_DEBUG
237
# define rw_lock_s_unlock_gen(L, P) rw_lock_s_unlock_func(P, L)
239
# define rw_lock_s_unlock_gen(L, P) rw_lock_s_unlock_func(L)
241
/*******************************************************************//**
242
Releases a shared mode lock. */
243
#define rw_lock_s_unlock(L) rw_lock_s_unlock_gen(L, 0)
245
/**************************************************************//**
246
NOTE! The following macro should be used in rw x-locking, not the
247
corresponding function. */
249
#define rw_lock_x_lock(M) rw_lock_x_lock_func(\
250
(M), 0, __FILE__, __LINE__)
251
/**************************************************************//**
252
NOTE! The following macro should be used in rw x-locking, not the
253
corresponding function. */
255
#define rw_lock_x_lock_gen(M, P) rw_lock_x_lock_func(\
256
(M), (P), __FILE__, __LINE__)
257
/**************************************************************//**
258
NOTE! The following macros should be used in rw x-locking, not the
259
corresponding function. */
261
#define rw_lock_x_lock_nowait(M) rw_lock_x_lock_func_nowait(\
262
(M), __FILE__, __LINE__)
335
263
/******************************************************************//**
336
264
NOTE! Use the corresponding macro, not directly this function! Lock an
337
265
rw-lock in exclusive mode for the current thread. If the rw-lock is locked
647
578
#endif /* UNIV_SYNC_DEBUG */
649
/* For performance schema instrumentation, a new set of rwlock
650
wrap functions are created if "UNIV_PFS_RWLOCK" is defined.
651
The instrumentations are not planted directly into original
652
functions, so that we keep the underlying function as they
653
are. And in case, user wants to "take out" some rwlock from
654
instrumentation even if performance schema (UNIV_PFS_RWLOCK)
655
is defined, they can do so by reinstating APIs directly link to
656
original underlying functions.
657
The instrumented function names have prefix of "pfs_rw_lock_" vs.
658
original name prefix of "rw_lock_". Following are list of functions
659
that have been instrumented:
664
rw_lock_x_lock_nowait()
665
rw_lock_x_unlock_gen()
668
rw_lock_s_lock_nowait()
669
rw_lock_s_unlock_gen()
672
Two function APIs rw_lock_x_unlock_direct() and rw_lock_s_unlock_direct()
673
do not have any caller/user, they are not instrumented.
676
#ifdef UNIV_PFS_RWLOCK
677
/******************************************************************//**
678
Performance schema instrumented wrap function for rw_lock_create_func()
679
NOTE! Please use the corresponding macro rw_lock_create(), not
680
directly this function! */
683
pfs_rw_lock_create_func(
684
/*====================*/
685
PSI_rwlock_key key, /*!< in: key registered with
686
performance schema */
687
rw_lock_t* lock, /*!< in: rw lock */
689
# ifdef UNIV_SYNC_DEBUG
690
ulint level, /*!< in: level */
691
# endif /* UNIV_SYNC_DEBUG */
692
const char* cmutex_name, /*!< in: mutex name */
693
#endif /* UNIV_DEBUG */
694
const char* cfile_name, /*!< in: file name where created */
695
ulint cline); /*!< in: file line where created */
697
/******************************************************************//**
698
Performance schema instrumented wrap function for rw_lock_x_lock_func()
699
NOTE! Please use the corresponding macro rw_lock_x_lock(), not
700
directly this function! */
703
pfs_rw_lock_x_lock_func(
704
/*====================*/
705
rw_lock_t* lock, /*!< in: pointer to rw-lock */
706
ulint pass, /*!< in: pass value; != 0, if the lock will
707
be passed to another thread to unlock */
708
const char* file_name,/*!< in: file name where lock requested */
709
ulint line); /*!< in: line where requested */
710
/******************************************************************//**
711
Performance schema instrumented wrap function for
712
rw_lock_x_lock_func_nowait()
713
NOTE! Please use the corresponding macro, not directly this function!
714
@return TRUE if success */
717
pfs_rw_lock_x_lock_func_nowait(
718
/*===========================*/
719
rw_lock_t* lock, /*!< in: pointer to rw-lock */
720
const char* file_name,/*!< in: file name where lock requested */
721
ulint line); /*!< in: line where requested */
722
/******************************************************************//**
723
Performance schema instrumented wrap function for rw_lock_s_lock_func()
724
NOTE! Please use the corresponding macro rw_lock_s_lock(), not directly
728
pfs_rw_lock_s_lock_func(
729
/*====================*/
730
rw_lock_t* lock, /*!< in: pointer to rw-lock */
731
ulint pass, /*!< in: pass value; != 0, if the lock will
732
be passed to another thread to unlock */
733
const char* file_name,/*!< in: file name where lock requested */
734
ulint line); /*!< in: line where requested */
735
/******************************************************************//**
736
Performance schema instrumented wrap function for rw_lock_s_lock_func()
737
NOTE! Please use the corresponding macro rw_lock_s_lock(), not directly
739
@return TRUE if success */
742
pfs_rw_lock_s_lock_low(
743
/*===================*/
744
rw_lock_t* lock, /*!< in: pointer to rw-lock */
745
ulint pass, /*!< in: pass value; != 0, if the
746
lock will be passed to another
748
const char* file_name, /*!< in: file name where lock requested */
749
ulint line); /*!< in: line where requested */
750
/******************************************************************//**
751
Performance schema instrumented wrap function for rw_lock_x_lock_func()
752
NOTE! Please use the corresponding macro rw_lock_x_lock(), not directly
756
pfs_rw_lock_x_lock_func(
757
/*====================*/
758
rw_lock_t* lock, /*!< in: pointer to rw-lock */
759
ulint pass, /*!< in: pass value; != 0, if the lock will
760
be passed to another thread to unlock */
761
const char* file_name,/*!< in: file name where lock requested */
762
ulint line); /*!< in: line where requested */
763
/******************************************************************//**
764
Performance schema instrumented wrap function for rw_lock_s_unlock_func()
765
NOTE! Please use the corresponding macro rw_lock_s_unlock(), not directly
769
pfs_rw_lock_s_unlock_func(
770
/*======================*/
771
#ifdef UNIV_SYNC_DEBUG
772
ulint pass, /*!< in: pass value; != 0, if the
773
lock may have been passed to another
776
rw_lock_t* lock); /*!< in/out: rw-lock */
777
/******************************************************************//**
778
Performance schema instrumented wrap function for rw_lock_s_unlock_func()
779
NOTE! Please use the corresponding macro rw_lock_x_unlock(), not directly
783
pfs_rw_lock_x_unlock_func(
784
/*======================*/
785
#ifdef UNIV_SYNC_DEBUG
786
ulint pass, /*!< in: pass value; != 0, if the
787
lock may have been passed to another
790
rw_lock_t* lock); /*!< in/out: rw-lock */
791
/******************************************************************//**
792
Performance schema instrumented wrap function for rw_lock_free_func()
793
NOTE! Please use the corresponding macro rw_lock_free(), not directly
797
pfs_rw_lock_free_func(
798
/*==================*/
799
rw_lock_t* lock); /*!< in: rw-lock */
800
#endif /* UNIV_PFS_RWLOCK */
803
580
#ifndef UNIV_NONINL
804
581
#include "sync0rw.ic"