1 | /* Copyright (c) 2013, 2015, 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 as published by |
5 | the Free Software Foundation; version 2 of the License. |
6 | |
7 | This program is distributed in the hope that it will be useful, |
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | GNU General Public License for more details. |
11 | |
12 | You should have received a copy of the GNU General Public License |
13 | along with this program; if not, write to the Free Software Foundation, |
14 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ |
15 | |
16 | #ifndef MYSQL_PSI_MEMORY_H |
17 | #define MYSQL_PSI_MEMORY_H |
18 | |
19 | #include "psi_base.h" |
20 | |
21 | #ifdef __cplusplus |
22 | extern "C" { |
23 | #endif |
24 | |
25 | /** |
26 | @file mysql/psi/psi_memory.h |
27 | Performance schema instrumentation interface. |
28 | |
29 | @defgroup Instrumentation_interface Instrumentation Interface |
30 | @ingroup Performance_schema |
31 | @{ |
32 | */ |
33 | |
34 | #ifdef HAVE_PSI_INTERFACE |
35 | #ifndef DISABLE_ALL_PSI |
36 | #ifndef DISABLE_PSI_MEMORY |
37 | #define HAVE_PSI_MEMORY_INTERFACE |
38 | #endif /* DISABLE_PSI_MEMORY */ |
39 | #endif /* DISABLE_ALL_PSI */ |
40 | #endif /* HAVE_PSI_INTERFACE */ |
41 | |
42 | struct PSI_thread; |
43 | |
44 | /** |
45 | Instrumented memory key. |
46 | To instrument memory, a memory key must be obtained using @c register_memory. |
47 | Using a zero key always disable the instrumentation. |
48 | */ |
49 | typedef unsigned int PSI_memory_key; |
50 | |
51 | #ifdef HAVE_PSI_1 |
52 | |
53 | /** |
54 | @defgroup Group_PSI_v1 Application Binary Interface, version 1 |
55 | @ingroup Instrumentation_interface |
56 | @{ |
57 | */ |
58 | |
59 | /** |
60 | Memory instrument information. |
61 | @since PSI_VERSION_1 |
62 | This structure is used to register instrumented memory. |
63 | */ |
64 | struct PSI_memory_info_v1 |
65 | { |
66 | /** Pointer to the key assigned to the registered memory. */ |
67 | PSI_memory_key *m_key; |
68 | /** The name of the memory instrument to register. */ |
69 | const char *m_name; |
70 | /** |
71 | The flags of the socket instrument to register. |
72 | @sa PSI_FLAG_GLOBAL |
73 | */ |
74 | int m_flags; |
75 | }; |
76 | typedef struct PSI_memory_info_v1 PSI_memory_info_v1; |
77 | |
78 | /** |
79 | Memory registration API. |
80 | @param category a category name (typically a plugin name) |
81 | @param info an array of memory info to register |
82 | @param count the size of the info array |
83 | */ |
84 | typedef void (*register_memory_v1_t) |
85 | (const char *category, struct PSI_memory_info_v1 *info, int count); |
86 | |
87 | /** |
88 | Instrument memory allocation. |
89 | @param key the memory instrument key |
90 | @param size the size of memory allocated |
91 | @param[out] owner the memory owner |
92 | @return the effective memory instrument key |
93 | */ |
94 | typedef PSI_memory_key (*memory_alloc_v1_t) |
95 | (PSI_memory_key key, size_t size, struct PSI_thread ** owner); |
96 | |
97 | /** |
98 | Instrument memory re allocation. |
99 | @param key the memory instrument key |
100 | @param old_size the size of memory previously allocated |
101 | @param new_size the size of memory re allocated |
102 | @param[in, out] owner the memory owner |
103 | @return the effective memory instrument key |
104 | */ |
105 | typedef PSI_memory_key (*memory_realloc_v1_t) |
106 | (PSI_memory_key key, size_t old_size, size_t new_size, struct PSI_thread ** owner); |
107 | |
108 | /** |
109 | Instrument memory claim. |
110 | @param key the memory instrument key |
111 | @param size the size of memory allocated |
112 | @param[in, out] owner the memory owner |
113 | @return the effective memory instrument key |
114 | */ |
115 | typedef PSI_memory_key (*memory_claim_v1_t) |
116 | (PSI_memory_key key, size_t size, struct PSI_thread ** owner); |
117 | |
118 | /** |
119 | Instrument memory free. |
120 | @param key the memory instrument key |
121 | @param size the size of memory allocated |
122 | @param owner the memory owner |
123 | */ |
124 | typedef void (*memory_free_v1_t) |
125 | (PSI_memory_key key, size_t size, struct PSI_thread * owner); |
126 | |
127 | /** @} (end of group Group_PSI_v1) */ |
128 | |
129 | #endif /* HAVE_PSI_1 */ |
130 | |
131 | #ifdef HAVE_PSI_2 |
132 | struct PSI_memory_info_v2 |
133 | { |
134 | int placeholder; |
135 | }; |
136 | |
137 | #endif /* HAVE_PSI_2 */ |
138 | |
139 | #ifdef USE_PSI_1 |
140 | typedef struct PSI_memory_info_v1 PSI_memory_info; |
141 | #endif |
142 | |
143 | #ifdef USE_PSI_2 |
144 | typedef struct PSI_memory_info_v2 PSI_memory_info; |
145 | #endif |
146 | |
147 | /** @} (end of group Instrumentation_interface) */ |
148 | |
149 | #ifdef __cplusplus |
150 | } |
151 | #endif |
152 | |
153 | |
154 | #endif /* MYSQL_PSI_MEMORY_H */ |
155 | |
156 | |