MySQL 9.1.0
Source Code Documentation
mysql_memory.h
Go to the documentation of this file.
1/* Copyright (c) 2012, 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 MYSQL_MEMORY_H
25#define MYSQL_MEMORY_H
26
27/**
28 @file include/mysql/psi/mysql_memory.h
29 Instrumentation helpers for memory allocation.
30*/
31
32#include "my_compiler.h"
33#include "my_inttypes.h"
34#include "template_utils.h"
35
36/* HAVE_PSI_*_INTERFACE */
37#include "my_psi_config.h" // IWYU pragma: keep
38
40
41#if defined(MYSQL_SERVER) || defined(PFS_DIRECT_CALL)
42/* PSI_MEMORY_CALL() as direct call. */
43#include "pfs_memory_provider.h" // IWYU pragma: keep
44#endif
45
46#ifndef PSI_MEMORY_CALL
47#define PSI_MEMORY_CALL(M) psi_memory_service->M
48#endif
49
50/**
51 @defgroup psi_api_memory Memory Instrumentation (API)
52 @ingroup psi_api
53 @{
54*/
55
56/**
57 @def mysql_memory_register(P1, P2, P3)
58 Memory registration.
59*/
60#define mysql_memory_register(P1, P2, P3) \
61 inline_mysql_memory_register(P1, P2, P3)
62
65 const char *category, PSI_memory_info *info, int count)
66#else
67 const char *category [[maybe_unused]], void *info [[maybe_unused]],
68 int count [[maybe_unused]])
69#endif
70{
71#ifdef HAVE_PSI_MEMORY_INTERFACE
73#endif
74}
75
76#ifdef HAVE_PSI_MEMORY_INTERFACE
77
78struct my_memory_header {
80 uint m_magic;
81 size_t m_size;
83};
85
86#define PSI_HEADER_SIZE 32
87
88#define PSI_MEMORY_MAGIC 1234
89
90#define PSI_MEM_CNT_BIT ((uint)1 << 31)
91#define PSI_REAL_MEM_KEY(P) ((PSI_memory_key)((P) & ~PSI_MEM_CNT_BIT))
92
93#define USER_TO_HEADER(P) ((my_memory_header *)(((char *)P) - PSI_HEADER_SIZE))
94#define HEADER_TO_USER(P) (((char *)P) + PSI_HEADER_SIZE)
95
96#define USER_TO_HEADER_UINT8_T(P) \
97 (((static_cast<uint8_t *>(P)) - PSI_HEADER_SIZE))
98
99#endif
100
101/** @} (end of group psi_api_memory) */
102
103#endif
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
struct PSI_thread PSI_thread
Definition: psi_thread_bits.h:82
static void inline_mysql_memory_register(const char *category, PSI_memory_info *info, int count)
Definition: mysql_memory.h:63
Header for compiler-dependent features.
Some integer typedefs for easier portability.
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
#define HAVE_PSI_MEMORY_INTERFACE
Definition: my_psi_config.h:209
static int count
Definition: myisam_ftdump.cc:45
#define PSI_MEMORY_CALL(M)
Definition: mysql_memory.h:47
static void register_memory(const char *, PSI_memory_info *, int)
Definition: psi_memory_v2_empty.cc:33
static const char * category
Definition: sha2_password.cc:170
Performance schema instrumentation (declarations).
Performance schema instrumentation interface.
Memory instrument information.
Definition: psi_memory_bits.h:58
Definition: my_memory.cc:49
PSI_thread * m_owner
Definition: my_memory.cc:53
uint m_magic
Definition: mysql_memory.h:80
PSI_memory_key m_key
Definition: my_memory.cc:50
size_t m_size
Definition: my_memory.cc:52