MySQL 8.0.39
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
35/* HAVE_PSI_*_INTERFACE */
36#include "my_psi_config.h" // IWYU pragma: keep
37
39
40#if defined(MYSQL_SERVER) || defined(PFS_DIRECT_CALL)
41/* PSI_MEMORY_CALL() as direct call. */
42#include "pfs_memory_provider.h" // IWYU pragma: keep
43#endif
44
45#ifndef PSI_MEMORY_CALL
46#define PSI_MEMORY_CALL(M) psi_memory_service->M
47#endif
48
49/**
50 @defgroup psi_api_memory Memory Instrumentation (API)
51 @ingroup psi_api
52 @{
53*/
54
55/**
56 @def mysql_memory_register(P1, P2, P3)
57 Memory registration.
58*/
59#define mysql_memory_register(P1, P2, P3) \
60 inline_mysql_memory_register(P1, P2, P3)
61
64 const char *category, PSI_memory_info *info, int count)
65#else
66 const char *category [[maybe_unused]], void *info [[maybe_unused]],
67 int count [[maybe_unused]])
68#endif
69{
70#ifdef HAVE_PSI_MEMORY_INTERFACE
72#endif
73}
74
75#ifdef HAVE_PSI_MEMORY_INTERFACE
76
77struct my_memory_header {
80 size_t m_size;
82};
84
85#define PSI_HEADER_SIZE 32
86
87#define PSI_MEMORY_MAGIC 1234
88
89#define PSI_MEM_CNT_BIT ((uint)1 << 31)
90#define PSI_REAL_MEM_KEY(P) ((PSI_memory_key)((P) & ~PSI_MEM_CNT_BIT))
91
92#define USER_TO_HEADER(P) ((my_memory_header *)(((char *)P) - PSI_HEADER_SIZE))
93#define HEADER_TO_USER(P) (((char *)P) + PSI_HEADER_SIZE)
94
95#define USER_TO_HEADER_UINT8_T(P) \
96 (((static_cast<uint8_t *>(P)) - PSI_HEADER_SIZE))
97
98#endif
99
100/** @} (end of group psi_api_memory) */
101
102#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:62
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:207
static int count
Definition: myisam_ftdump.cc:43
#define PSI_MEMORY_CALL(M)
Definition: mysql_memory.h:46
Log info(cout, "NOTE")
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:79
PSI_memory_key m_key
Definition: my_memory.cc:50
size_t m_size
Definition: my_memory.cc:52
unsigned int uint
Definition: uca9-dump.cc:75