MySQL 9.0.0
Source Code Documentation
psi_cond_bits.h
Go to the documentation of this file.
1/* Copyright (c) 2008, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef COMPONENTS_SERVICES_BITS_PSI_COND_BITS_H
25#define COMPONENTS_SERVICES_BITS_PSI_COND_BITS_H
26
28
29/**
30 @file mysql/components/services/bits/psi_cond_bits.h
31 Performance schema instrumentation interface.
32
33 @defgroup psi_abi_cond Cond Instrumentation (ABI)
34 @ingroup psi_abi
35 @{
36*/
37
38/**
39 Instrumented cond key.
40 To instrument a condition, a condition key must be obtained
41 using @c register_cond.
42 Using a zero key always disable the instrumentation.
43*/
44typedef unsigned int PSI_cond_key;
45
46/**
47 @def PSI_COND_VERSION_1
48 Performance Schema Cond Interface number for version 1.
49 This version is supported.
50*/
51#define PSI_COND_VERSION_1 1
52
53/**
54 @def PSI_CURRENT_COND_VERSION
55 Performance Schema Cond Interface number for the most recent version.
56 The most current version is @c PSI_COND_VERSION_1
57*/
58#define PSI_CURRENT_COND_VERSION 1
59
60/**
61 Interface for an instrumented condition.
62 This is an opaque structure.
63*/
64struct PSI_cond : PSI_instr {};
65typedef struct PSI_cond PSI_cond;
66
67/**
68 Interface for an instrumented condition operation.
69 This is an opaque structure.
70*/
71struct PSI_cond_locker;
73
74/** Operation performed on an instrumented condition. */
76 /** Wait. */
78 /** Wait, with timeout. */
80};
82
83/**
84 Condition information.
85 @since PSI_COND_VERSION_1
86 This structure is used to register an instrumented cond.
87*/
89 /**
90 Pointer to the key assigned to the registered cond.
91 */
93 /**
94 The name of the cond to register.
95 */
96 const char *m_name;
97 /**
98 The flags of the cond to register.
99 @sa PSI_FLAG_SINGLETON
100 */
101 unsigned int m_flags;
102 /** Volatility index. */
104 /** Documentation. */
105 const char *m_documentation;
106};
108
109/**
110 State data storage for @c start_cond_wait_v1_t.
111 This structure provide temporary storage to a condition locker.
112 The content of this structure is considered opaque,
113 the fields are only hints of what an implementation
114 of the psi interface can use.
115 This memory is provided by the instrumented code for performance reasons.
116 @sa start_cond_wait_v1_t
117*/
119 /** Internal state. */
120 unsigned int m_flags;
121 /** Current operation. */
123 /** Current condition. */
125 /** Current mutex. */
127 /** Current thread. */
128 struct PSI_thread *m_thread{nullptr};
129 /** Timer start. */
130 unsigned long long m_timer_start{0ULL};
131 /** Timer function. */
132 unsigned long long (*m_timer)(void);
133 /** Internal data. */
134 void *m_wait{nullptr};
135};
137
138/**
139 Cond registration API.
140 @param category a category name (typically a plugin name)
141 @param info an array of cond info to register
142 @param count the size of the info array
143*/
144typedef void (*register_cond_v1_t)(const char *category,
145 struct PSI_cond_info_v1 *info, int count);
146
147/**
148 Cond instrumentation initialisation API.
149 @param key the registered key
150 @param identity the address of the cond itself
151 @return an instrumented cond
152*/
153typedef struct PSI_cond *(*init_cond_v1_t)(PSI_cond_key key,
154 const void *identity);
155
156/**
157 Cond instrumentation destruction API.
158 @param cond the rcond to destroy
159*/
160typedef void (*destroy_cond_v1_t)(struct PSI_cond *cond);
161
162/**
163 Record a condition instrumentation signal event.
164 @param cond the cond instrumentation
165*/
166typedef void (*signal_cond_v1_t)(struct PSI_cond *cond);
167
168/**
169 Record a condition instrumentation broadcast event.
170 @param cond the cond instrumentation
171*/
172typedef void (*broadcast_cond_v1_t)(struct PSI_cond *cond);
173
174/**
175 Record a condition instrumentation wait start event.
176 @param state data storage for the locker
177 @param cond the instrumented cond to lock
178 @param mutex the instrumented mutex associated with the condition
179 @param op the operation to perform
180 @param src_file the source file name
181 @param src_line the source line number
182 @return a cond locker, or NULL
183*/
184typedef struct PSI_cond_locker *(*start_cond_wait_v1_t)(
185 struct PSI_cond_locker_state_v1 *state, struct PSI_cond *cond,
186 struct PSI_mutex *mutex, enum PSI_cond_operation op, const char *src_file,
187 unsigned int src_line);
188
189/**
190 Record a condition instrumentation wait end event.
191 @param locker a thread locker for the running thread
192 @param rc the wait operation return code
193*/
194typedef void (*end_cond_wait_v1_t)(struct PSI_cond_locker *locker, int rc);
195
198
199/** @} (end of group psi_abi_cond) */
200
201#endif /* COMPONENTS_SERVICES_BITS_PSI_COND_BITS_H */
struct PSI_cond_locker PSI_cond_locker
Definition: psi_cond_bits.h:72
PSI_cond_operation
Operation performed on an instrumented condition.
Definition: psi_cond_bits.h:75
void(* register_cond_v1_t)(const char *category, struct PSI_cond_info_v1 *info, int count)
Cond registration API.
Definition: psi_cond_bits.h:144
void(* broadcast_cond_v1_t)(struct PSI_cond *cond)
Record a condition instrumentation broadcast event.
Definition: psi_cond_bits.h:172
void(* destroy_cond_v1_t)(struct PSI_cond *cond)
Cond instrumentation destruction API.
Definition: psi_cond_bits.h:160
void(* signal_cond_v1_t)(struct PSI_cond *cond)
Record a condition instrumentation signal event.
Definition: psi_cond_bits.h:166
void(* end_cond_wait_v1_t)(struct PSI_cond_locker *locker, int rc)
Record a condition instrumentation wait end event.
Definition: psi_cond_bits.h:194
unsigned int PSI_cond_key
Instrumented cond key.
Definition: psi_cond_bits.h:44
@ PSI_COND_WAIT
Wait.
Definition: psi_cond_bits.h:77
@ PSI_COND_TIMEDWAIT
Wait, with timeout.
Definition: psi_cond_bits.h:79
struct PSI_thread PSI_thread
Definition: psi_thread_bits.h:82
static int count
Definition: myisam_ftdump.cc:45
static const char * category
Definition: sha2_password.cc:170
Performance schema instrumentation interface.
required string key
Definition: replication_asynchronous_connection_failover.proto:60
Condition information.
Definition: psi_cond_bits.h:88
PSI_cond_key * m_key
Pointer to the key assigned to the registered cond.
Definition: psi_cond_bits.h:92
int m_volatility
Volatility index.
Definition: psi_cond_bits.h:103
unsigned int m_flags
The flags of the cond to register.
Definition: psi_cond_bits.h:101
const char * m_documentation
Documentation.
Definition: psi_cond_bits.h:105
const char * m_name
The name of the cond to register.
Definition: psi_cond_bits.h:96
State data storage for start_cond_wait_v1_t.
Definition: psi_cond_bits.h:118
unsigned long long(* m_timer)(void)
Timer function.
Definition: psi_cond_bits.h:132
enum PSI_cond_operation m_operation
Current operation.
Definition: psi_cond_bits.h:122
struct PSI_cond * m_cond
Current condition.
Definition: psi_cond_bits.h:124
struct PSI_thread * m_thread
Current thread.
Definition: psi_cond_bits.h:128
unsigned long long m_timer_start
Timer start.
Definition: psi_cond_bits.h:130
struct PSI_mutex * m_mutex
Current mutex.
Definition: psi_cond_bits.h:126
unsigned int m_flags
Internal state.
Definition: psi_cond_bits.h:120
void * m_wait
Internal data.
Definition: psi_cond_bits.h:134
Interface for an instrumented condition.
Definition: psi_cond_bits.h:64
Instrumented artifact.
Definition: psi_bits.h:177
Interface for an instrumented mutex.
Definition: psi_mutex_bits.h:97