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