MySQL 8.3.0
Source Code Documentation
psi_rwlock_bits.h
Go to the documentation of this file.
1/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
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_BITS_PSI_RWLOCK_BITS_H
24#define COMPONENTS_SERVICES_BITS_PSI_RWLOCK_BITS_H
25
27
28/**
29 @file mysql/components/services/bits/psi_rwlock_bits.h
30 Performance schema instrumentation interface.
31
32 @defgroup psi_abi_rwlock Rwlock Instrumentation (ABI)
33 @ingroup psi_abi
34 @{
35*/
36
37/**
38 Instrumented rwlock key.
39 To instrument a rwlock, a rwlock key must be obtained
40 using @c register_rwlock.
41 Using a zero key always disable the instrumentation.
42*/
43typedef unsigned int PSI_rwlock_key;
44
45/**
46 @def PSI_RWLOCK_VERSION_1
47 Performance Schema Rwlock Interface number for version 1.
48 This version is obsolete.
49*/
50#define PSI_RWLOCK_VERSION_1 1
51
52/**
53 @def PSI_RWLOCK_VERSION_2
54 Performance Schema Rwlock Interface number for version 2.
55 This version is supported.
56*/
57#define PSI_RWLOCK_VERSION_2 2
58
59/**
60 @def PSI_CURRENT_RWLOCK_VERSION
61 Performance Schema Rwlock Interface number for the most recent version.
62 The most current version is @c PSI_RWLOCK_VERSION_2
63*/
64#define PSI_CURRENT_RWLOCK_VERSION 2
65
66/**
67 Interface for an instrumented rwlock.
68 This is an opaque structure.
69*/
71typedef struct PSI_rwlock PSI_rwlock;
72
73/**
74 Interface for an instrumented rwlock operation.
75 This is an opaque structure.
76*/
79
80#if 0
81/*
82 Keeping the original version 1 definition in the source,
83 in case we ever need to provide support for version 1.
84*/
85
86/**
87 Operation performed on an instrumented rwlock.
88 For basic READ / WRITE lock,
89 operations are "READ" or "WRITE".
90 For SX-locks, operations are "SHARED", "SHARED-EXCLUSIVE" or "EXCLUSIVE".
91*/
93 /** Read lock. */
95 /** Write lock. */
97 /** Read lock attempt. */
99 /** Write lock attempt. */
101
102 /** Shared lock. */
104 /** Shared Exclusive lock. */
106 /** Exclusive lock. */
108 /** Shared lock attempt. */
110 /** Shared Exclusive lock attempt. */
112 /** Exclusive lock attempt. */
114};
115#endif
116
117/**
118 Operation performed on an instrumented rwlock.
119 For basic READ / WRITE lock,
120 operations are "READ" or "WRITE".
121 For SX-locks, operations are "SHARED", "SHARED-EXCLUSIVE" or "EXCLUSIVE".
122*/
124 /** Read lock. */
126 /** Write lock. */
128 /** Read lock attempt. */
130 /** Write lock attempt. */
132 /** Unlock (Read or Write). */
134
135 /** Shared lock. */
137 /** Shared Exclusive lock. */
139 /** Exclusive lock. */
141 /** Shared lock attempt. */
143 /** Shared Exclusive lock attempt. */
145 /** Exclusive lock attempt. */
147 /** Unlock a shared lock. */
149 /** Unlock a shared exclusive lock. */
151 /** Unlock an exclusive lock. */
155
156/**
157 Rwlock information.
158 @since PSI_RWLOCK_VERSION_1
159 This structure is used to register an instrumented rwlock.
160*/
162 /**
163 Pointer to the key assigned to the registered rwlock.
164 */
166 /**
167 The name of the rwlock to register.
168 */
169 const char *m_name;
170 /**
171 The flags of the rwlock to register.
172 @sa PSI_FLAG_SINGLETON
173 */
174 unsigned int m_flags;
175 /** Volatility index. */
177 /** Documentation. */
178 const char *m_documentation;
179};
181
182/**
183 State data storage for @c start_rwlock_rdwait_v1_t, @c
184 start_rwlock_wrwait_v1_t.
185 This structure provide temporary storage to a rwlock locker.
186 The content of this structure is considered opaque,
187 the fields are only hints of what an implementation
188 of the psi interface can use.
189 This memory is provided by the instrumented code for performance reasons.
190 @sa start_rwlock_rdwait_v1_t
191 @sa start_rwlock_wrwait_v1_t
192*/
194 /** Internal state. */
195 unsigned int m_flags;
196 /** Current operation. */
198 /** Current rwlock. */
200 /** Current thread. */
202 /** Timer start. */
203 unsigned long long m_timer_start{0};
204 /** Timer function. */
205 unsigned long long (*m_timer)(void);
206 /** Internal data. */
207 void *m_wait{nullptr};
208};
210
211/**
212 Rwlock registration API.
213 @param category a category name (typically a plugin name)
214 @param info an array of rwlock info to register
215 @param count the size of the info array
216*/
217typedef void (*register_rwlock_v1_t)(const char *category,
218 struct PSI_rwlock_info_v1 *info,
219 int count);
220
221/**
222 Rwlock instrumentation initialization API.
223 @param key the registered rwlock key
224 @param identity the address of the rwlock itself
225 @return an instrumented rwlock
226*/
227typedef struct PSI_rwlock *(*init_rwlock_v1_t)(PSI_rwlock_key key,
228 const void *identity);
229
230/**
231 Rwlock instrumentation destruction API.
232 @param rwlock the rwlock to destroy
233*/
234typedef void (*destroy_rwlock_v1_t)(struct PSI_rwlock *rwlock);
235
236/**
237 Record a rwlock instrumentation read wait start event.
238 @param state data storage for the locker
239 @param rwlock the instrumented rwlock to lock
240 @param op the operation to perform
241 @param src_file the source file name
242 @param src_line the source line number
243 @return a rwlock locker, or NULL
244*/
245typedef struct PSI_rwlock_locker *(*start_rwlock_rdwait_v1_t)(
246 struct PSI_rwlock_locker_state_v1 *state, struct PSI_rwlock *rwlock,
247 enum PSI_rwlock_operation op, const char *src_file, unsigned int src_line);
248
249/**
250 Record a rwlock instrumentation read wait end event.
251 @param locker a thread locker for the running thread
252 @param rc 0 if the lock was acquired, 1 if it was not
253*/
254typedef void (*end_rwlock_rdwait_v1_t)(struct PSI_rwlock_locker *locker,
255 int rc);
256
257/**
258 Record a rwlock instrumentation write wait start event.
259 @param state data storage for the locker
260 @param rwlock the instrumented rwlock to lock
261 @param op the operation to perform
262 @param src_file the source file name
263 @param src_line the source line number
264 @return a rwlock locker, or NULL
265*/
266typedef struct PSI_rwlock_locker *(*start_rwlock_wrwait_v1_t)(
267 struct PSI_rwlock_locker_state_v1 *state, struct PSI_rwlock *rwlock,
268 enum PSI_rwlock_operation op, const char *src_file, unsigned int src_line);
269
270/**
271 Record a rwlock instrumentation write wait end event.
272 @param locker a thread locker for the running thread
273 @param rc 0 if the lock was acquired, 1 if it was not
274*/
275typedef void (*end_rwlock_wrwait_v1_t)(struct PSI_rwlock_locker *locker,
276 int rc);
277
278/**
279 Record a rwlock instrumentation unlock event.
280 @param rwlock the rwlock instrumentation
281*/
282typedef void (*unlock_rwlock_v1_t)(struct PSI_rwlock *rwlock);
283
284/**
285 Record a rwlock instrumentation unlock event.
286 @param rwlock the rwlock instrumentation
287 @param op the unlock operation performed
288*/
289typedef void (*unlock_rwlock_v2_t)(struct PSI_rwlock *rwlock,
290 enum PSI_rwlock_operation op);
291
294
295/** @} (end of group psi_abi_rwlock) */
296
297#endif /* COMPONENTS_SERVICES_BITS_PSI_RWLOCK_BITS_H */
void(* unlock_rwlock_v1_t)(struct PSI_rwlock *rwlock)
Record a rwlock instrumentation unlock event.
Definition: psi_rwlock_bits.h:282
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:254
unsigned int PSI_rwlock_key
Instrumented rwlock key.
Definition: psi_rwlock_bits.h:43
struct PSI_rwlock_locker PSI_rwlock_locker
Definition: psi_rwlock_bits.h:78
PSI_rwlock_operation
Operation performed on an instrumented rwlock.
Definition: psi_rwlock_bits.h:123
void(* destroy_rwlock_v1_t)(struct PSI_rwlock *rwlock)
Rwlock instrumentation destruction API.
Definition: psi_rwlock_bits.h:234
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:275
void(* register_rwlock_v1_t)(const char *category, struct PSI_rwlock_info_v1 *info, int count)
Rwlock registration API.
Definition: psi_rwlock_bits.h:217
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:289
@ PSI_RWLOCK_TRYWRITELOCK
Write lock attempt.
Definition: psi_rwlock_bits.h:131
@ PSI_RWLOCK_SHAREDEXCLUSIVEUNLOCK
Unlock a shared exclusive lock.
Definition: psi_rwlock_bits.h:150
@ PSI_RWLOCK_WRITELOCK
Write lock.
Definition: psi_rwlock_bits.h:127
@ PSI_RWLOCK_UNLOCK
Unlock (Read or Write).
Definition: psi_rwlock_bits.h:133
@ PSI_RWLOCK_SHAREDUNLOCK
Unlock a shared lock.
Definition: psi_rwlock_bits.h:148
@ PSI_RWLOCK_SHAREDLOCK
Shared lock.
Definition: psi_rwlock_bits.h:136
@ PSI_RWLOCK_SHAREDEXCLUSIVELOCK
Shared Exclusive lock.
Definition: psi_rwlock_bits.h:138
@ PSI_RWLOCK_EXCLUSIVEUNLOCK
Unlock an exclusive lock.
Definition: psi_rwlock_bits.h:152
@ PSI_RWLOCK_TRYSHAREDEXCLUSIVELOCK
Shared Exclusive lock attempt.
Definition: psi_rwlock_bits.h:144
@ PSI_RWLOCK_TRYSHAREDLOCK
Shared lock attempt.
Definition: psi_rwlock_bits.h:142
@ PSI_RWLOCK_TRYREADLOCK
Read lock attempt.
Definition: psi_rwlock_bits.h:129
@ PSI_RWLOCK_EXCLUSIVELOCK
Exclusive lock.
Definition: psi_rwlock_bits.h:140
@ PSI_RWLOCK_READLOCK
Read lock.
Definition: psi_rwlock_bits.h:125
@ PSI_RWLOCK_TRYEXCLUSIVELOCK
Exclusive lock attempt.
Definition: psi_rwlock_bits.h:146
struct PSI_thread PSI_thread
Definition: psi_thread_bits.h:81
static int count
Definition: myisam_ftdump.cc:44
static const char * category
Definition: sha2_password.cc:169
Performance schema instrumentation interface.
required string key
Definition: replication_asynchronous_connection_failover.proto:59
Instrumented artifact.
Definition: psi_bits.h:176
Rwlock information.
Definition: psi_rwlock_bits.h:161
const char * m_name
The name of the rwlock to register.
Definition: psi_rwlock_bits.h:169
PSI_rwlock_key * m_key
Pointer to the key assigned to the registered rwlock.
Definition: psi_rwlock_bits.h:165
int m_volatility
Volatility index.
Definition: psi_rwlock_bits.h:176
unsigned int m_flags
The flags of the rwlock to register.
Definition: psi_rwlock_bits.h:174
const char * m_documentation
Documentation.
Definition: psi_rwlock_bits.h:178
State data storage for start_rwlock_rdwait_v1_t, start_rwlock_wrwait_v1_t.
Definition: psi_rwlock_bits.h:193
struct PSI_rwlock * m_rwlock
Current rwlock.
Definition: psi_rwlock_bits.h:199
enum PSI_rwlock_operation m_operation
Current operation.
Definition: psi_rwlock_bits.h:197
unsigned long long(* m_timer)(void)
Timer function.
Definition: psi_rwlock_bits.h:205
struct PSI_thread * m_thread
Current thread.
Definition: psi_rwlock_bits.h:201
unsigned long long m_timer_start
Timer start.
Definition: psi_rwlock_bits.h:203
void * m_wait
Internal data.
Definition: psi_rwlock_bits.h:207
unsigned int m_flags
Internal state.
Definition: psi_rwlock_bits.h:195
Interface for an instrumented rwlock.
Definition: psi_rwlock_bits.h:70