MySQL  8.0.18
Source Code Documentation
psi_rwlock_bits.h
Go to the documentation of this file.
1 /* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef COMPONENTS_SERVICES_PSI_RWLOCK_BITS_H
24 #define COMPONENTS_SERVICES_PSI_RWLOCK_BITS_H
25 
26 /**
27  @file
28  Performance schema instrumentation interface.
29 
30  @defgroup psi_abi_rwlock Rwlock Instrumentation (ABI)
31  @ingroup psi_abi
32  @{
33 */
34 
35 /**
36  Instrumented rwlock key.
37  To instrument a rwlock, a rwlock key must be obtained
38  using @c register_rwlock.
39  Using a zero key always disable the instrumentation.
40 */
41 typedef unsigned int PSI_rwlock_key;
42 
43 /**
44  @def PSI_RWLOCK_VERSION_1
45  Performance Schema Rwlock Interface number for version 1.
46  This version is obsolete.
47 */
48 #define PSI_RWLOCK_VERSION_1 1
49 
50 /**
51  @def PSI_RWLOCK_VERSION_2
52  Performance Schema Rwlock Interface number for version 2.
53  This version is supported.
54 */
55 #define PSI_RWLOCK_VERSION_2 2
56 
57 /**
58  @def PSI_CURRENT_RWLOCK_VERSION
59  Performance Schema Rwlock Interface number for the most recent version.
60  The most current version is @c PSI_RWLOCK_VERSION_2
61 */
62 #define PSI_CURRENT_RWLOCK_VERSION 2
63 
64 /**
65  Interface for an instrumented rwlock.
66  This is an opaque structure.
67 */
68 struct PSI_rwlock;
69 typedef struct PSI_rwlock PSI_rwlock;
70 
71 /**
72  Interface for an instrumented rwlock operation.
73  This is an opaque structure.
74 */
75 struct PSI_rwlock_locker;
77 
78 #if 0
79 /*
80  Keeping the original version 1 definition in the source,
81  in case we ever need to provide support for version 1.
82 */
83 
84 /**
85  Operation performed on an instrumented rwlock.
86  For basic READ / WRITE lock,
87  operations are "READ" or "WRITE".
88  For SX-locks, operations are "SHARED", "SHARED-EXCLUSIVE" or "EXCLUSIVE".
89 */
91  /** Read lock. */
93  /** Write lock. */
95  /** Read lock attempt. */
97  /** Write lock attempt. */
99 
100  /** Shared lock. */
102  /** Shared Exclusive lock. */
104  /** Exclusive lock. */
106  /** Shared lock attempt. */
108  /** Shared Exclusive lock attempt. */
110  /** Exclusive lock attempt. */
112 };
113 #endif
114 
115 /**
116  Operation performed on an instrumented rwlock.
117  For basic READ / WRITE lock,
118  operations are "READ" or "WRITE".
119  For SX-locks, operations are "SHARED", "SHARED-EXCLUSIVE" or "EXCLUSIVE".
120 */
122  /** Read lock. */
124  /** Write lock. */
126  /** Read lock attempt. */
128  /** Write lock attempt. */
130  /** Unlock (Read or Write). */
132 
133  /** Shared lock. */
135  /** Shared Exclusive lock. */
137  /** Exclusive lock. */
139  /** Shared lock attempt. */
141  /** Shared Exclusive lock attempt. */
143  /** Exclusive lock attempt. */
145  /** Unlock a shared lock. */
147  /** Unlock a shared exclusive lock. */
149  /** Unlock an exclusive lock. */
151 };
153 
154 /**
155  Rwlock information.
156  @since PSI_RWLOCK_VERSION_1
157  This structure is used to register an instrumented rwlock.
158 */
160  /**
161  Pointer to the key assigned to the registered rwlock.
162  */
164  /**
165  The name of the rwlock to register.
166  */
167  const char *m_name;
168  /**
169  The flags of the rwlock to register.
170  @sa PSI_FLAG_SINGLETON
171  */
172  unsigned int m_flags;
173  /** Volatility index. */
175  /** Documentation. */
176  const char *m_documentation;
177 };
179 
180 /**
181  State data storage for @c start_rwlock_rdwait_v1_t, @c
182  start_rwlock_wrwait_v1_t.
183  This structure provide temporary storage to a rwlock locker.
184  The content of this structure is considered opaque,
185  the fields are only hints of what an implementation
186  of the psi interface can use.
187  This memory is provided by the instrumented code for performance reasons.
188  @sa start_rwlock_rdwait_v1_t
189  @sa start_rwlock_wrwait_v1_t
190 */
192  /** Internal state. */
193  unsigned int m_flags;
194  /** Current operation. */
196  /** Current rwlock. */
198  /** Current thread. */
200  /** Timer start. */
201  unsigned long long m_timer_start;
202  /** Timer function. */
203  unsigned long long (*m_timer)(void);
204  /** Internal data. */
205  void *m_wait;
206 };
208 
209 /**
210  Rwlock registration API.
211  @param category a category name (typically a plugin name)
212  @param info an array of rwlock info to register
213  @param count the size of the info array
214 */
215 typedef void (*register_rwlock_v1_t)(const char *category,
216  struct PSI_rwlock_info_v1 *info,
217  int count);
218 
219 /**
220  Rwlock instrumentation initialization API.
221  @param key the registered rwlock key
222  @param identity the address of the rwlock itself
223  @return an instrumented rwlock
224 */
225 typedef struct PSI_rwlock *(*init_rwlock_v1_t)(PSI_rwlock_key key,
226  const void *identity);
227 
228 /**
229  Rwlock instrumentation destruction API.
230  @param rwlock the rwlock to destroy
231 */
232 typedef void (*destroy_rwlock_v1_t)(struct PSI_rwlock *rwlock);
233 
234 /**
235  Record a rwlock instrumentation read wait start event.
236  @param state data storage for the locker
237  @param rwlock the instrumented rwlock to lock
238  @param op the operation to perform
239  @param src_file the source file name
240  @param src_line the source line number
241  @return a rwlock locker, or NULL
242 */
243 typedef struct PSI_rwlock_locker *(*start_rwlock_rdwait_v1_t)(
244  struct PSI_rwlock_locker_state_v1 *state, struct PSI_rwlock *rwlock,
245  enum PSI_rwlock_operation op, const char *src_file, unsigned int src_line);
246 
247 /**
248  Record a rwlock instrumentation read wait end event.
249  @param locker a thread locker for the running thread
250  @param rc the wait operation return code
251 */
252 typedef void (*end_rwlock_rdwait_v1_t)(struct PSI_rwlock_locker *locker,
253  int rc);
254 
255 /**
256  Record a rwlock instrumentation write wait start event.
257  @param state data storage for the locker
258  @param rwlock the instrumented rwlock to lock
259  @param op the operation to perform
260  @param src_file the source file name
261  @param src_line the source line number
262  @return a rwlock locker, or NULL
263 */
264 typedef struct PSI_rwlock_locker *(*start_rwlock_wrwait_v1_t)(
265  struct PSI_rwlock_locker_state_v1 *state, struct PSI_rwlock *rwlock,
266  enum PSI_rwlock_operation op, const char *src_file, unsigned int src_line);
267 
268 /**
269  Record a rwlock instrumentation write wait end event.
270  @param locker a thread locker for the running thread
271  @param rc the wait operation return code
272 */
273 typedef void (*end_rwlock_wrwait_v1_t)(struct PSI_rwlock_locker *locker,
274  int rc);
275 
276 /**
277  Record a rwlock instrumentation unlock event.
278  @param rwlock the rwlock instrumentation
279 */
280 typedef void (*unlock_rwlock_v1_t)(struct PSI_rwlock *rwlock);
281 
282 /**
283  Record a rwlock instrumentation unlock event.
284  @param rwlock the rwlock instrumentation
285  @param op the unlock operation performed
286 */
287 typedef void (*unlock_rwlock_v2_t)(struct PSI_rwlock *rwlock,
288  enum PSI_rwlock_operation op);
289 
292 
293 /** @} (end of group psi_abi_rwlock) */
294 
295 #endif /* COMPONENTS_SERVICES_PSI_RWLOCK_BITS_H */
struct PSI_rwlock_locker PSI_rwlock_locker
Definition: psi_rwlock_bits.h:76
PSI_rwlock_key * m_key
Pointer to the key assigned to the registered rwlock.
Definition: psi_rwlock_bits.h:163
Read lock attempt.
Definition: psi_rwlock_bits.h:127
ssize_t count
Definition: memcached.c:386
enum PSI_rwlock_operation m_operation
Current operation.
Definition: psi_rwlock_bits.h:195
Shared Exclusive lock.
Definition: psi_rwlock_bits.h:136
Shared lock attempt.
Definition: psi_rwlock_bits.h:140
void(* end_rwlock_wrwait_v1_t)(struct PSI_rwlock_locker *locker, int rc)
Record a rwlock instrumentation write wait end event.
Definition: psi_rwlock_bits.h:273
Shared Exclusive lock attempt.
Definition: psi_rwlock_bits.h:142
unsigned long long(* m_timer)(void)
Timer function.
Definition: psi_rwlock_bits.h:203
void(* unlock_rwlock_v2_t)(struct PSI_rwlock *rwlock, enum PSI_rwlock_operation op)
Record a rwlock instrumentation unlock event.
Definition: psi_rwlock_bits.h:287
void(* unlock_rwlock_v1_t)(struct PSI_rwlock *rwlock)
Record a rwlock instrumentation unlock event.
Definition: psi_rwlock_bits.h:280
Write lock.
Definition: psi_rwlock_bits.h:125
void * m_wait
Internal data.
Definition: psi_rwlock_bits.h:205
Write lock attempt.
Definition: psi_rwlock_bits.h:129
const char * m_documentation
Documentation.
Definition: psi_rwlock_bits.h:176
unsigned int m_flags
Internal state.
Definition: psi_rwlock_bits.h:193
Read lock.
Definition: psi_rwlock_bits.h:123
void(* end_rwlock_rdwait_v1_t)(struct PSI_rwlock_locker *locker, int rc)
Record a rwlock instrumentation read wait end event.
Definition: psi_rwlock_bits.h:252
void(* register_rwlock_v1_t)(const char *category, struct PSI_rwlock_info_v1 *info, int count)
Rwlock registration API.
Definition: psi_rwlock_bits.h:215
unsigned int m_flags
The flags of the rwlock to register.
Definition: psi_rwlock_bits.h:172
const char * m_name
The name of the rwlock to register.
Definition: psi_rwlock_bits.h:167
int m_volatility
Volatility index.
Definition: psi_rwlock_bits.h:174
Rwlock information.
Definition: psi_rwlock_bits.h:159
unsigned int PSI_rwlock_key
Instrumented rwlock key.
Definition: psi_rwlock_bits.h:41
static const char * key
Definition: suite_stubs.c:14
Shared lock.
Definition: psi_rwlock_bits.h:134
struct PSI_rwlock * m_rwlock
Current rwlock.
Definition: psi_rwlock_bits.h:197
Unlock (Read or Write).
Definition: psi_rwlock_bits.h:131
static const char * category
Definition: sha2_password.cc:166
Exclusive lock attempt.
Definition: psi_rwlock_bits.h:144
Exclusive lock.
Definition: psi_rwlock_bits.h:138
Unlock a shared exclusive lock.
Definition: psi_rwlock_bits.h:148
Unlock a shared lock.
Definition: psi_rwlock_bits.h:146
struct PSI_rwlock PSI_rwlock
Definition: psi_rwlock_bits.h:69
std::decay_t< T > identity
Definition: string_view.h:176
unsigned long long m_timer_start
Timer start.
Definition: psi_rwlock_bits.h:201
Log info(cout, "NOTE")
Unlock an exclusive lock.
Definition: psi_rwlock_bits.h:150
State data storage for start_rwlock_rdwait_v1_t, start_rwlock_wrwait_v1_t.
Definition: psi_rwlock_bits.h:191
struct PSI_thread * m_thread
Current thread.
Definition: psi_rwlock_bits.h:199
PSI_rwlock_operation
Operation performed on an instrumented rwlock.
Definition: psi_rwlock_bits.h:121
struct PSI_thread PSI_thread
Definition: psi_thread_bits.h:71
void(* destroy_rwlock_v1_t)(struct PSI_rwlock *rwlock)
Rwlock instrumentation destruction API.
Definition: psi_rwlock_bits.h:232