summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2020-01-29 13:50:26 +0100
committerSergei Golubchik <serg@mariadb.org>2020-03-10 19:24:22 +0100
commit7c58e97bf6f80a251046c5b3e7bce826fe058bd6 (patch)
tree7d32d26b320cf83296ee0ede2ea164ad116c4de8 /mysys
parent2ac3121af2767186c489054db5d4871d04b8eef4 (diff)
downloadmariadb-git-7c58e97bf6f80a251046c5b3e7bce826fe058bd6.tar.gz
perfschema memory related instrumentation changes
Diffstat (limited to 'mysys')
-rw-r--r--mysys/array.c25
-rw-r--r--mysys/charset.c6
-rw-r--r--mysys/file_logger.c3
-rw-r--r--mysys/get_password.c4
-rw-r--r--mysys/hash.c7
-rw-r--r--mysys/lf_alloc-pin.c6
-rw-r--r--mysys/lf_dynarray.c14
-rw-r--r--mysys/lf_hash.c6
-rw-r--r--mysys/list.c2
-rw-r--r--mysys/ma_dyncol.c37
-rw-r--r--mysys/mf_iocache.c4
-rw-r--r--mysys/mf_keycache.c18
-rw-r--r--mysys/mf_sort.c3
-rw-r--r--mysys/mf_tempdir.c5
-rw-r--r--mysys/mulalloc.c8
-rw-r--r--mysys/my_alloc.c42
-rw-r--r--mysys/my_bitmap.c3
-rw-r--r--mysys/my_compress.c13
-rw-r--r--mysys/my_default.c7
-rw-r--r--mysys/my_error.c3
-rw-r--r--mysys/my_file.c3
-rw-r--r--mysys/my_fopen.c7
-rw-r--r--mysys/my_getopt.c8
-rw-r--r--mysys/my_lib.c18
-rw-r--r--mysys/my_likely.c5
-rw-r--r--mysys/my_malloc.c176
-rw-r--r--mysys/my_open.c2
-rw-r--r--mysys/my_safehash.c6
-rw-r--r--mysys/my_static.c30
-rw-r--r--mysys/my_windac.c4
-rw-r--r--mysys/mysys_priv.h30
-rw-r--r--mysys/queues.c5
-rw-r--r--mysys/string.c12
-rw-r--r--mysys/thr_alarm.c3
-rw-r--r--mysys/thr_mutex.c20
-rw-r--r--mysys/tree.c4
-rw-r--r--mysys/waiting_threads.c6
37 files changed, 311 insertions, 244 deletions
diff --git a/mysys/array.c b/mysys/array.c
index 07abc460de7..20767efdf9e 100644
--- a/mysys/array.c
+++ b/mysys/array.c
@@ -40,9 +40,9 @@
FALSE Ok
*/
-my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
- void *init_buffer, uint init_alloc,
- uint alloc_increment, myf my_flags)
+my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, PSI_memory_key psi_key,
+ uint element_size, void *init_buffer,
+ uint init_alloc, uint alloc_increment, myf my_flags)
{
DBUG_ENTER("init_dynamic_array2");
if (!alloc_increment)
@@ -55,6 +55,7 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
array->max_element=init_alloc;
array->alloc_increment=alloc_increment;
array->size_of_element=element_size;
+ array->m_psi_key= psi_key;
array->malloc_flags= my_flags;
DBUG_ASSERT((my_flags & MY_INIT_BUFFER_USED) == 0);
if ((array->buffer= init_buffer))
@@ -67,7 +68,7 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
should not throw an error
*/
if (init_alloc &&
- !(array->buffer= (uchar*) my_malloc(element_size*init_alloc,
+ !(array->buffer= (uchar*) my_malloc(psi_key, element_size*init_alloc,
MYF(my_flags))))
array->max_element=0;
DBUG_RETURN(FALSE);
@@ -133,7 +134,8 @@ void *alloc_dynamic(DYNAMIC_ARRAY *array)
In this scenario, the buffer is statically preallocated,
so we have to create an all-new malloc since we overflowed
*/
- if (!(new_ptr= (char *) my_malloc((array->max_element+
+ if (!(new_ptr= (char *) my_malloc(array->m_psi_key,
+ (array->max_element+
array->alloc_increment) *
array->size_of_element,
MYF(array->malloc_flags | MY_WME))))
@@ -143,8 +145,8 @@ void *alloc_dynamic(DYNAMIC_ARRAY *array)
array->malloc_flags&= ~MY_INIT_BUFFER_USED;
}
else if (!(new_ptr=(char*)
- my_realloc(array->buffer,(array->max_element+
- array->alloc_increment)*
+ my_realloc(array->m_psi_key, array->buffer,
+ (array->max_element+ array->alloc_increment) *
array->size_of_element,
MYF(MY_WME | MY_ALLOW_ZERO_PTR |
array->malloc_flags))))
@@ -241,7 +243,7 @@ my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements)
In this senerio, the buffer is statically preallocated,
so we have to create an all-new malloc since we overflowed
*/
- if (!(new_ptr= (uchar *) my_malloc(size *
+ if (!(new_ptr= (uchar *) my_malloc(array->m_psi_key, size *
array->size_of_element,
MYF(array->malloc_flags | MY_WME))))
DBUG_RETURN(0);
@@ -249,7 +251,8 @@ my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements)
array->elements * array->size_of_element);
array->malloc_flags&= ~MY_INIT_BUFFER_USED;
}
- else if (!(new_ptr= (uchar*) my_realloc(array->buffer,size*
+ else if (!(new_ptr= (uchar*) my_realloc(array->m_psi_key,
+ array->buffer,size *
array->size_of_element,
MYF(MY_WME | MY_ALLOW_ZERO_PTR |
array->malloc_flags))))
@@ -362,8 +365,8 @@ void freeze_size(DYNAMIC_ARRAY *array)
elements= MY_MAX(array->elements, 1);
if (array->buffer && array->max_element > elements)
{
- array->buffer=(uchar*) my_realloc(array->buffer,
- elements*array->size_of_element,
+ array->buffer=(uchar*) my_realloc(array->m_psi_key, array->buffer,
+ elements * array->size_of_element,
MYF(MY_WME | array->malloc_flags));
array->max_element= elements;
}
diff --git a/mysys/charset.c b/mysys/charset.c
index 9c61fa85481..5e999c8435d 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -463,12 +463,12 @@ my_once_alloc_c(size_t size)
static void *
my_malloc_c(size_t size)
-{ return my_malloc(size, MYF(MY_WME)); }
+{ return my_malloc(key_memory_charset_loader, size, MYF(MY_WME)); }
static void *
my_realloc_c(void *old, size_t size)
-{ return my_realloc(old, size, MYF(MY_WME|MY_ALLOW_ZERO_PTR)); }
+{ return my_realloc(key_memory_charset_loader, old, size, MYF(MY_WME|MY_ALLOW_ZERO_PTR)); }
/**
@@ -506,7 +506,7 @@ my_read_charset_file(MY_CHARSET_LOADER *loader,
if (!my_stat(filename, &stat_info, MYF(myflags)) ||
((len= (uint)stat_info.st_size) > MY_MAX_ALLOWED_BUF) ||
- !(buf= (uchar*) my_malloc(len,myflags)))
+ !(buf= (uchar*) my_malloc(key_memory_charset_loader,len,myflags)))
return TRUE;
if ((fd= mysql_file_open(key_file_charset, filename, O_RDONLY, myflags)) < 0)
diff --git a/mysys/file_logger.c b/mysys/file_logger.c
index 71394be7afc..eb5579fb8a9 100644
--- a/mysys/file_logger.c
+++ b/mysys/file_logger.c
@@ -84,7 +84,8 @@ LOGGER_HANDLE *logger_open(const char *path,
return 0;
}
- if (!(l_perm= (LOGGER_HANDLE *) my_malloc(sizeof(LOGGER_HANDLE), MYF(0))))
+ if (!(l_perm= (LOGGER_HANDLE *) my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(LOGGER_HANDLE), MYF(0))))
{
my_close(new_log.file, MYF(0));
new_log.file= -1;
diff --git a/mysys/get_password.c b/mysys/get_password.c
index e20800f4213..2a5ddc9a4d7 100644
--- a/mysys/get_password.c
+++ b/mysys/get_password.c
@@ -90,7 +90,7 @@ char *get_tty_password(const char *opt_message)
pos--; /* Allow dummy space at end */
*pos=0;
_cputs("\n");
- DBUG_RETURN(my_strdup(to,MYF(MY_FAE)));
+ DBUG_RETURN(my_strdup(PSI_INSTRUMENT_ME, to,MYF(MY_FAE)));
}
#else
@@ -201,7 +201,7 @@ char *get_tty_password(const char *opt_message)
fputc('\n',stderr);
#endif /* HAVE_GETPASS */
- DBUG_RETURN(my_strdup(buff,MYF(MY_FAE)));
+ DBUG_RETURN(my_strdup(PSI_INSTRUMENT_ME, buff, MYF(MY_FAE)));
}
#endif /*__WIN__*/
diff --git a/mysys/hash.c b/mysys/hash.c
index ba2aa8fc30e..ddb146af5e0 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -80,7 +80,7 @@ my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset,
ulong size, size_t key_offset, size_t key_length,
my_hash_get_key get_key,
my_hash_function hash_function,
- void (*free_element)(void*), uint flags)
+ void (*free_element)(void*), uint flags, PSI_memory_key psi_key)
{
my_bool res;
DBUG_ENTER("my_hash_init2");
@@ -95,7 +95,7 @@ my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset,
hash->free=free_element;
hash->flags=flags;
hash->charset=charset;
- res= init_dynamic_array2(&hash->array, sizeof(HASH_LINK), NULL, size,
+ res= init_dynamic_array2(&hash->array, psi_key, sizeof(HASH_LINK), NULL, size,
growth_size, MYF((flags & HASH_THREAD_SPECIFIC ?
MY_THREAD_SPECIFIC : 0)));
DBUG_RETURN(res);
@@ -890,7 +890,8 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
printf("my_hash_init\n");
if (my_hash_init2(&hash_test, 100, &my_charset_bin, 20,
- 0, 0, (my_hash_get_key) test_get_key, 0, 0, HASH_UNIQUE))
+ 0, 0, (my_hash_get_key) test_get_key, 0, 0, HASH_UNIQUE,
+ PSI_INSTRUMENT_ME))
{
fprintf(stderr, "hash init failed\n");
exit(1);
diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c
index b98684556c3..86464b3eaeb 100644
--- a/mysys/lf_alloc-pin.c
+++ b/mysys/lf_alloc-pin.c
@@ -99,8 +99,7 @@
between THD's (LF_PINS::stack_ends_here being a primary reason
for this limitation).
*/
-#include <my_global.h>
-#include <my_sys.h>
+#include "mysys_priv.h"
#include <lf.h>
/*
@@ -500,7 +499,8 @@ void *lf_alloc_new(LF_PINS *pins)
} while (node != allocator->top && LF_BACKOFF());
if (!node)
{
- node= (void *)my_malloc(allocator->element_size, MYF(MY_WME));
+ node= (void *)my_malloc(key_memory_lf_node, allocator->element_size,
+ MYF(MY_WME));
if (allocator->constructor)
allocator->constructor(node);
#ifdef MY_LF_EXTRA_DEBUG
diff --git a/mysys/lf_dynarray.c b/mysys/lf_dynarray.c
index be23690c70b..6a4ea3d3d96 100644
--- a/mysys/lf_dynarray.c
+++ b/mysys/lf_dynarray.c
@@ -35,9 +35,8 @@
Actually, it's wait-free, not lock-free ;-)
*/
-#include <my_global.h>
+#include "mysys_priv.h"
#include <m_string.h>
-#include <my_sys.h>
#include <lf.h>
void lf_dynarray_init(LF_DYNARRAY *array, uint element_size)
@@ -106,8 +105,8 @@ void *lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
{
if (!(ptr= *ptr_ptr))
{
- void *alloc= my_malloc(LF_DYNARRAY_LEVEL_LENGTH * sizeof(void *),
- MYF(MY_WME|MY_ZEROFILL));
+ void *alloc= my_malloc(key_memory_lf_dynarray, LF_DYNARRAY_LEVEL_LENGTH *
+ sizeof(void *), MYF(MY_WME|MY_ZEROFILL));
if (unlikely(!alloc))
return(NULL);
if (my_atomic_casptr(ptr_ptr, &ptr, alloc))
@@ -121,9 +120,10 @@ void *lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
if (!(ptr= *ptr_ptr))
{
uchar *alloc, *data;
- alloc= my_malloc(LF_DYNARRAY_LEVEL_LENGTH * array->size_of_element +
- MY_MAX(array->size_of_element, sizeof(void *)),
- MYF(MY_WME|MY_ZEROFILL));
+ alloc= my_malloc(key_memory_lf_dynarray,
+ LF_DYNARRAY_LEVEL_LENGTH * array->size_of_element +
+ MY_MAX(array->size_of_element, sizeof(void *)),
+ MYF(MY_WME|MY_ZEROFILL));
if (unlikely(!alloc))
return(NULL);
/* reserve the space for free() address */
diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c
index 73b9f874598..6a1e69f529f 100644
--- a/mysys/lf_hash.c
+++ b/mysys/lf_hash.c
@@ -22,9 +22,8 @@
for non-unique hash, count only _distinct_ values
(but how to do it in lf_hash_delete ?)
*/
-#include <my_global.h>
+#include "mysys_priv.h"
#include <m_string.h>
-#include <my_sys.h>
#include <mysys_err.h>
#include <my_bit.h>
#include <lf.h>
@@ -543,7 +542,8 @@ static int initialize_bucket(LF_HASH *hash, LF_SLIST * volatile *node,
uint bucket, LF_PINS *pins)
{
uint parent= my_clear_highest_bit(bucket);
- LF_SLIST *dummy= (LF_SLIST *)my_malloc(sizeof(LF_SLIST), MYF(MY_WME));
+ LF_SLIST *dummy= (LF_SLIST *)my_malloc(key_memory_lf_slist,
+ sizeof(LF_SLIST), MYF(MY_WME));
LF_SLIST **tmp= 0, *cur;
LF_SLIST * volatile *el= lf_dynarray_lvalue(&hash->array, parent);
if (unlikely(!el || !dummy))
diff --git a/mysys/list.c b/mysys/list.c
index 10dfd7ec6ef..1770b201dd4 100644
--- a/mysys/list.c
+++ b/mysys/list.c
@@ -70,7 +70,7 @@ void list_free(LIST *root, uint free_data)
LIST *list_cons(void *data, LIST *list)
{
- LIST *new_charset=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
+ LIST *new_charset=(LIST*) my_malloc(key_memory_LIST, sizeof(LIST),MYF(MY_FAE));
if (!new_charset)
return 0;
new_charset->data=data;
diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c
index 2068d0d818c..edd476b4188 100644
--- a/mysys/ma_dyncol.c
+++ b/mysys/ma_dyncol.c
@@ -2417,8 +2417,8 @@ dynamic_column_list(DYNAMIC_COLUMN *str, DYNAMIC_ARRAY *array_of_uint)
str->length)
return ER_DYNCOL_FORMAT;
- if (my_init_dynamic_array(array_of_uint, sizeof(uint), header.column_count,
- 0, MYF(0)))
+ if (my_init_dynamic_array(array_of_uint, PSI_INSTRUMENT_ME,
+ sizeof(uint), header.column_count, 0, MYF(0)))
return ER_DYNCOL_RESOURCE;
for (i= 0, read= header.header;
@@ -2463,7 +2463,7 @@ mariadb_dyncol_list_num(DYNAMIC_COLUMN *str, uint *count, uint **nums)
str->length)
return ER_DYNCOL_FORMAT;
- if (!((*nums)= my_malloc(sizeof(uint) * header.column_count, MYF(0))))
+ if (!((*nums)= my_malloc(PSI_INSTRUMENT_ME, sizeof(uint) * header.column_count, MYF(0))))
return ER_DYNCOL_RESOURCE;
for (i= 0, read= header.header;
@@ -2510,12 +2510,17 @@ mariadb_dyncol_list_named(DYNAMIC_COLUMN *str, uint *count, LEX_STRING **names)
str->length)
return ER_DYNCOL_FORMAT;
- if (header.format == dyncol_fmt_num)
- *names= my_malloc(sizeof(LEX_STRING) * header.column_count +
- DYNCOL_NUM_CHAR * header.column_count, MYF(0));
- else
- *names= my_malloc(sizeof(LEX_STRING) * header.column_count +
- header.nmpool_size + header.column_count, MYF(0));
+ {
+ size_t size;
+ if (header.format == dyncol_fmt_num)
+ size= DYNCOL_NUM_CHAR * header.column_count;
+ else
+ size= header.nmpool_size + header.column_count;
+
+ *names= my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(LEX_STRING) * header.column_count + size, MYF(0));
+ }
+
if (!(*names))
return ER_DYNCOL_RESOURCE;
pool= ((char *)(*names)) + sizeof(LEX_STRING) * header.column_count;
@@ -3327,7 +3332,8 @@ dynamic_column_update_many_fmt(DYNAMIC_COLUMN *str,
if (IN_PLACE_PLAN > add_column_count)
plan= in_place_plan;
else if (!(alloc_plan= plan=
- my_malloc(sizeof(PLAN) * (add_column_count + 1), MYF(0))))
+ my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(PLAN) * (add_column_count + 1), MYF(0))))
return ER_DYNCOL_RESOURCE;
not_null= add_column_count;
@@ -3923,7 +3929,7 @@ mariadb_dyncol_val_str(DYNAMIC_STRING *str, DYNAMIC_COLUMN_VALUE *val,
&dummy_errors);
return ER_DYNCOL_OK;
}
- if ((alloc= (char *)my_malloc(bufflen, MYF(0))))
+ if ((alloc= (char *)my_malloc(PSI_INSTRUMENT_ME, bufflen, MYF(0))))
{
len= my_convert(alloc, bufflen, cs, from, (uint32)len,
val->x.string.charset, &dummy_errors);
@@ -4298,16 +4304,19 @@ mariadb_dyncol_unpack(DYNAMIC_COLUMN *str,
str->length)
return ER_DYNCOL_FORMAT;
- *vals= my_malloc(sizeof(DYNAMIC_COLUMN_VALUE)* header.column_count, MYF(0));
+ *vals= my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(DYNAMIC_COLUMN_VALUE)* header.column_count, MYF(0));
if (header.format == dyncol_fmt_num)
{
- *names= my_malloc(sizeof(LEX_STRING) * header.column_count +
+ *names= my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(LEX_STRING) * header.column_count +
DYNCOL_NUM_CHAR * header.column_count, MYF(0));
nm= (char *)((*names) + header.column_count);
}
else
{
- *names= my_malloc(sizeof(LEX_STRING) * header.column_count, MYF(0));
+ *names= my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(LEX_STRING) * header.column_count, MYF(0));
nm= 0;
}
if (!(*vals) || !(*names))
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 54b89007b4c..a9d4270cc71 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -244,7 +244,7 @@ int init_io_cache(IO_CACHE *info, File file, size_t cachesize,
if (cachesize == min_cache)
flags|= (myf) MY_WME;
- if ((info->buffer= (uchar*) my_malloc(buffer_block, flags)) != 0)
+ if ((info->buffer= (uchar*) my_malloc(key_memory_IO_CACHE, buffer_block, flags)) != 0)
{
if (type == SEQ_READ_APPEND)
info->write_buffer= info->buffer + cachesize;
@@ -324,7 +324,7 @@ int init_slave_io_cache(IO_CACHE *master, IO_CACHE *slave)
DBUG_ASSERT(!master->share);
DBUG_ASSERT(master->alloced_buffer);
- if (!(slave_buf= (uchar*)my_malloc(master->buffer_length, MYF(0))))
+ if (!(slave_buf= (uchar*)my_malloc(PSI_INSTRUMENT_ME, master->buffer_length, MYF(0))))
{
return 1;
}
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 07dd8f3e1ef..94b720b1006 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -554,7 +554,7 @@ int init_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
Allocate memory for blocks, hash_links and hash entries;
For each block 2 hash links are allocated
*/
- if (my_multi_malloc_large(MYF(MY_ZEROFILL),
+ if (my_multi_malloc_large(key_memory_KEY_CACHE, MYF(MY_ZEROFILL),
&keycache->block_root,
(ulonglong) (blocks * sizeof(BLOCK_LINK)),
&keycache->hash_root,
@@ -3949,8 +3949,8 @@ static int flush_key_blocks_int(SIMPLE_KEY_CACHE_CB *keycache,
changed blocks appear while we need to wait for something.
*/
if ((count > FLUSH_CACHE) &&
- !(cache= (BLOCK_LINK**) my_malloc(sizeof(BLOCK_LINK*)*count,
- MYF(0))))
+ !(cache= (BLOCK_LINK**) my_malloc(key_memory_KEY_CACHE,
+ sizeof(BLOCK_LINK*)*count, MYF(0))))
cache= cache_buff;
/*
After a restart there could be more changed blocks than now.
@@ -5113,7 +5113,8 @@ int init_partitioned_key_cache(PARTITIONED_KEY_CACHE_CB *keycache,
else
{
if(!(partition_ptr=
- (SIMPLE_KEY_CACHE_CB **) my_malloc(sizeof(SIMPLE_KEY_CACHE_CB *) *
+ (SIMPLE_KEY_CACHE_CB **) my_malloc(key_memory_KEY_CACHE,
+ sizeof(SIMPLE_KEY_CACHE_CB *) *
partitions, MYF(MY_WME))))
DBUG_RETURN(-1);
bzero(partition_ptr, sizeof(SIMPLE_KEY_CACHE_CB *) * partitions);
@@ -5131,7 +5132,8 @@ int init_partitioned_key_cache(PARTITIONED_KEY_CACHE_CB *keycache,
else
{
if (!(partition=
- (SIMPLE_KEY_CACHE_CB *) my_malloc(sizeof(SIMPLE_KEY_CACHE_CB),
+ (SIMPLE_KEY_CACHE_CB *) my_malloc(key_memory_KEY_CACHE,
+ sizeof(SIMPLE_KEY_CACHE_CB),
MYF(MY_WME))))
continue;
partition->key_cache_inited= 0;
@@ -5909,7 +5911,8 @@ int init_key_cache_internal(KEY_CACHE *keycache, uint key_cache_block_size,
{
if (partitions == 0)
{
- if (!(keycache_cb= (void *) my_malloc(sizeof(SIMPLE_KEY_CACHE_CB),
+ if (!(keycache_cb= (void *) my_malloc(key_memory_KEY_CACHE,
+ sizeof(SIMPLE_KEY_CACHE_CB),
MYF(0))))
return 0;
((SIMPLE_KEY_CACHE_CB *) keycache_cb)->key_cache_inited= 0;
@@ -5918,7 +5921,8 @@ int init_key_cache_internal(KEY_CACHE *keycache, uint key_cache_block_size,
}
else
{
- if (!(keycache_cb= (void *) my_malloc(sizeof(PARTITIONED_KEY_CACHE_CB),
+ if (!(keycache_cb= (void *) my_malloc(key_memory_KEY_CACHE,
+ sizeof(PARTITIONED_KEY_CACHE_CB),
MYF(0))))
return 0;
((PARTITIONED_KEY_CACHE_CB *) keycache_cb)->key_cache_inited= 0;
diff --git a/mysys/mf_sort.c b/mysys/mf_sort.c
index 3cbad020cb1..24e875b813e 100644
--- a/mysys/mf_sort.c
+++ b/mysys/mf_sort.c
@@ -24,7 +24,8 @@ void my_string_ptr_sort(uchar *base, uint items, size_t size)
uchar **ptr=0;
if (radixsort_is_appliccable(items, size) &&
- (ptr= (uchar**) my_malloc(items*sizeof(char*),MYF(0))))
+ (ptr= (uchar**) my_malloc(PSI_NOT_INSTRUMENTED,
+ items * sizeof(char*),MYF(0))))
{
radixsort_for_str_ptr((uchar**) base,items,size,ptr);
my_free(ptr);
diff --git a/mysys/mf_tempdir.c b/mysys/mf_tempdir.c
index 39de3570fad..1883c5578f8 100644
--- a/mysys/mf_tempdir.c
+++ b/mysys/mf_tempdir.c
@@ -30,7 +30,8 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist)
DBUG_PRINT("enter", ("pathlist: %s", pathlist ? pathlist : "NULL"));
mysql_mutex_init(key_TMPDIR_mutex, &tmpdir->mutex, MY_MUTEX_INIT_FAST);
- if (my_init_dynamic_array(&tmpdir->full_list, sizeof(char*), 1, 5, MYF(0)))
+ if (my_init_dynamic_array(&tmpdir->full_list, key_memory_MY_TMPDIR_full_list,
+ sizeof(char*), 1, 5, MYF(0)))
goto err;
if (!pathlist || !pathlist[0])
{
@@ -51,7 +52,7 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist)
end=strcend(pathlist, DELIM);
strmake(buff, pathlist, (uint) (end-pathlist));
length= cleanup_dirname(buff, buff);
- if (!(copy= my_strndup(buff, length, MYF(MY_WME))) ||
+ if (!(copy= my_strndup(key_memory_MY_TMPDIR_full_list, buff, length, MYF(MY_WME))) ||
insert_dynamic(&tmpdir->full_list, (uchar*) &copy))
DBUG_RETURN(TRUE);
pathlist=end+1;
diff --git a/mysys/mulalloc.c b/mysys/mulalloc.c
index 26f8253bc87..357f9315f2b 100644
--- a/mysys/mulalloc.c
+++ b/mysys/mulalloc.c
@@ -32,7 +32,7 @@
NULL
*/
-void* my_multi_malloc(myf myFlags, ...)
+void* my_multi_malloc(PSI_memory_key key, myf myFlags, ...)
{
va_list args;
char **ptr,*start,*res;
@@ -48,7 +48,7 @@ void* my_multi_malloc(myf myFlags, ...)
}
va_end(args);
- if (!(start=(char *) my_malloc(tot_length,myFlags)))
+ if (!(start=(char *) my_malloc(key, tot_length,myFlags)))
DBUG_RETURN(0); /* purecov: inspected */
va_start(args,myFlags);
@@ -76,7 +76,7 @@ void* my_multi_malloc(myf myFlags, ...)
NULL
*/
-void *my_multi_malloc_large(myf myFlags, ...)
+void *my_multi_malloc_large(PSI_memory_key key, myf myFlags, ...)
{
va_list args;
char **ptr,*start,*res;
@@ -92,7 +92,7 @@ void *my_multi_malloc_large(myf myFlags, ...)
}
va_end(args);
- if (!(start=(char *) my_malloc((size_t) tot_length, myFlags)))
+ if (!(start=(char *) my_malloc(key, (size_t) tot_length, myFlags)))
DBUG_RETURN(0); /* purecov: inspected */
va_start(args,myFlags);
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index 79e4ba9d563..3120ee50a59 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -54,35 +54,32 @@
Because of this, we store in MY_THREAD_SPECIFIC as bit 1 in block_size
*/
-void init_alloc_root(MEM_ROOT *mem_root, const char *name, size_t block_size,
+void init_alloc_root(PSI_memory_key key, MEM_ROOT *mem_root, size_t block_size,
size_t pre_alloc_size __attribute__((unused)),
myf my_flags)
{
DBUG_ENTER("init_alloc_root");
- DBUG_PRINT("enter",("root: %p name: %s prealloc: %zu", mem_root,
- name, pre_alloc_size));
+ DBUG_PRINT("enter",("root: %p prealloc: %zu", mem_root, pre_alloc_size));
mem_root->free= mem_root->used= mem_root->pre_alloc= 0;
mem_root->min_malloc= 32;
mem_root->block_size= (block_size - ALLOC_ROOT_MIN_BLOCK_SIZE) & ~1;
- if (MY_TEST(my_flags & MY_THREAD_SPECIFIC))
+ if (my_flags & MY_THREAD_SPECIFIC)
mem_root->block_size|= 1;
mem_root->error_handler= 0;
mem_root->block_num= 4; /* We shift this with >>2 */
mem_root->first_block_usage= 0;
- mem_root->total_alloc= 0;
- mem_root->name= name;
+ mem_root->m_psi_key= key;
#if !(defined(HAVE_valgrind) && defined(EXTRA_DEBUG))
if (pre_alloc_size)
{
+ size_t size= pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM));
if ((mem_root->free= mem_root->pre_alloc=
- (USED_MEM*) my_malloc(pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM)),
- MYF(my_flags))))
+ (USED_MEM*) my_malloc(key, size, MYF(my_flags))))
{
- mem_root->free->size= pre_alloc_size+ALIGN_SIZE(sizeof(USED_MEM));
- mem_root->total_alloc= pre_alloc_size+ALIGN_SIZE(sizeof(USED_MEM));
+ mem_root->free->size= size;
mem_root->free->left= pre_alloc_size;
mem_root->free->next= 0;
TRASH_MEM(mem_root->free);
@@ -141,19 +138,17 @@ void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
{
/* remove block from the list and free it */
*prev= mem->next;
- mem_root->total_alloc-= mem->size;
my_free(mem);
}
else
prev= &mem->next;
}
/* Allocate new prealloc block and add it to the end of free list */
- if ((mem= (USED_MEM *) my_malloc(size,
+ if ((mem= (USED_MEM *) my_malloc(mem_root->m_psi_key, size,
MYF(MALLOC_FLAG(mem_root->
block_size)))))
{
mem->size= size;
- mem_root->total_alloc+= size;
mem->left= pre_alloc_size;
mem->next= *prev;
*prev= mem_root->pre_alloc= mem;
@@ -178,7 +173,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
#if defined(HAVE_valgrind) && defined(EXTRA_DEBUG)
reg1 USED_MEM *next;
DBUG_ENTER("alloc_root");
- DBUG_PRINT("enter",("root: %p name: %s", mem_root, mem_root->name));
+ DBUG_PRINT("enter",("root: %p name: %s", mem_root, root_name(mem_root)));
DBUG_ASSERT(alloc_root_inited(mem_root));
@@ -203,10 +198,8 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
next->left= 0;
next->size= length;
mem_root->used= next;
- mem_root->total_alloc+= length;
- DBUG_PRINT("exit",("ptr: %p", (((char*) next)+
- ALIGN_SIZE(sizeof(USED_MEM)))));
- DBUG_RETURN((uchar*) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM))));
+ DBUG_PRINT("exit",("ptr: %p", (((char*)next)+ALIGN_SIZE(sizeof(USED_MEM)))));
+ DBUG_RETURN((((uchar*) next)+ALIGN_SIZE(sizeof(USED_MEM))));
#else
size_t get_size, block_size;
uchar* point;
@@ -214,7 +207,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
reg2 USED_MEM **prev;
size_t original_length = length;
DBUG_ENTER("alloc_root");
- DBUG_PRINT("enter",("root: %p name: %s", mem_root, mem_root->name));
+ DBUG_PRINT("enter",("root: %p name: %s", mem_root, root_name(mem_root)));
DBUG_ASSERT(alloc_root_inited(mem_root));
DBUG_EXECUTE_IF("simulate_out_of_memory",
@@ -247,7 +240,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
get_size= MY_MAX(get_size, block_size);
- if (!(next = (USED_MEM*) my_malloc(get_size,
+ if (!(next = (USED_MEM*) my_malloc(mem_root->m_psi_key, get_size,
MYF(MY_WME | ME_FATAL |
MALLOC_FLAG(mem_root->
block_size)))))
@@ -257,7 +250,6 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
DBUG_RETURN((void*) 0); /* purecov: inspected */
}
mem_root->block_num++;
- mem_root->total_alloc+= get_size;
next->next= *prev;
next->size= get_size;
next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM));
@@ -394,7 +386,7 @@ void free_root(MEM_ROOT *root, myf MyFlags)
{
reg1 USED_MEM *next,*old;
DBUG_ENTER("free_root");
- DBUG_PRINT("enter",("root: %p name: %s flags: %u", root, root->name,
+ DBUG_PRINT("enter",("root: %p name: %s flags: %u", root, root_name(root),
(uint) MyFlags));
#if !(defined(HAVE_valgrind) && defined(EXTRA_DEBUG))
@@ -415,19 +407,13 @@ void free_root(MEM_ROOT *root, myf MyFlags)
{
old=next; next= next->next ;
if (old != root->pre_alloc)
- {
- root->total_alloc-= old->size;
my_free(old);
- }
}
for (next=root->free ; next ;)
{
old=next; next= next->next;
if (old != root->pre_alloc)
- {
- root->total_alloc-= old->size;
my_free(old);
- }
}
root->used=root->free=0;
if (root->pre_alloc)
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index 8059b909788..b671d87a933 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -173,7 +173,8 @@ my_bool my_bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits,
size_in_bytes= ALIGN_SIZE(size_in_bytes);
extra= sizeof(mysql_mutex_t);
}
- if (!(buf= (my_bitmap_map*) my_malloc(size_in_bytes+extra, MYF(MY_WME))))
+ if (!(buf= (my_bitmap_map*) my_malloc(key_memory_MY_BITMAP_bitmap,
+ size_in_bytes+extra, MYF(MY_WME))))
DBUG_RETURN(1);
if (thread_safe)
{
diff --git a/mysys/my_compress.c b/mysys/my_compress.c
index 7cd85d57dd8..11603e7ba24 100644
--- a/mysys/my_compress.c
+++ b/mysys/my_compress.c
@@ -15,7 +15,7 @@
/* Written by Sinisa Milivojevic <sinisa@mysql.com> */
-#include <my_global.h>
+#include <mysys_priv.h>
#ifdef HAVE_COMPRESS
#include <my_sys.h>
#ifndef SCO
@@ -84,7 +84,8 @@ my_bool my_compress(uchar *packet, size_t *len, size_t *complen)
void *my_az_allocator(void *dummy __attribute__((unused)), unsigned int items,
unsigned int size)
{
- return my_malloc((size_t)items*(size_t)size, IF_VALGRIND(MY_ZEROFILL, MYF(0)));
+ return my_malloc(key_memory_my_compress_alloc, (size_t)items*(size_t)size,
+ IF_VALGRIND(MY_ZEROFILL, MYF(0)));
}
void my_az_free(void *dummy __attribute__((unused)), void *address)
@@ -133,8 +134,9 @@ uchar *my_compress_alloc(const uchar *packet, size_t *len, size_t *complen)
int res;
*complen= *len * 120 / 100 + 12;
- if (!(compbuf= (uchar *) my_malloc(*complen, MYF(MY_WME))))
- return 0; /* Not enough memory */
+ if (!(compbuf= (uchar *) my_malloc(key_memory_my_compress_alloc,
+ *complen, MYF(MY_WME))))
+ return 0;
res= my_compress_buffer(compbuf, complen, packet, *len);
@@ -180,7 +182,8 @@ my_bool my_uncompress(uchar *packet, size_t len, size_t *complen)
if (*complen) /* If compressed */
{
- uchar *compbuf= (uchar *) my_malloc(*complen,MYF(MY_WME));
+ uchar *compbuf= (uchar *) my_malloc(key_memory_my_compress_alloc,
+ *complen,MYF(MY_WME));
int error;
if (!compbuf)
DBUG_RETURN(1); /* Not enough memory */
diff --git a/mysys/my_default.c b/mysys/my_default.c
index 30c76c7f5ed..885bc6449fc 100644
--- a/mysys/my_default.c
+++ b/mysys/my_default.c
@@ -410,13 +410,14 @@ int my_load_defaults(const char *conf_file, const char **groups, int *argc,
const char **dirs;
DBUG_ENTER("my_load_defaults");
- init_alloc_root(&alloc, "my_load_defaults", 512, 0, MYF(0));
+ init_alloc_root(key_memory_defaults, &alloc, 512, 0, MYF(0));
if ((dirs= init_default_directories(&alloc)) == NULL)
goto err;
args_used= get_defaults_options(*argv);
- if (my_init_dynamic_array(&args, sizeof(char*), 128, 64, MYF(0)))
+ if (my_init_dynamic_array(&args, key_memory_defaults, sizeof(char*), 128, 64,
+ MYF(0)))
goto err;
insert_dynamic(&args, *argv);/* Name MUST be set, even by embedded library */
@@ -879,7 +880,7 @@ void my_print_default_files(const char *conf_file)
{
const char **dirs;
MEM_ROOT alloc;
- init_alloc_root(&alloc, "my_print_defaults", 512, 0, MYF(0));
+ init_alloc_root(key_memory_defaults, &alloc, 512, 0, MYF(0));
if ((dirs= init_default_directories(&alloc)) == NULL)
{
diff --git a/mysys/my_error.c b/mysys/my_error.c
index cb1fbfe1c04..4c3cd1435ac 100644
--- a/mysys/my_error.c
+++ b/mysys/my_error.c
@@ -224,7 +224,8 @@ int my_error_register(const char** (*get_errmsgs)(int error), uint first,
struct my_err_head **search_meh_pp;
/* Allocate a new header structure. */
- if (! (meh_p= (struct my_err_head*) my_malloc(sizeof(struct my_err_head),
+ if (! (meh_p= (struct my_err_head*) my_malloc(key_memory_my_err_head,
+ sizeof(struct my_err_head),
MYF(MY_WME))))
return 1;
meh_p->get_errmsgs= get_errmsgs;
diff --git a/mysys/my_file.c b/mysys/my_file.c
index 17b2493962a..c2b358f5e1e 100644
--- a/mysys/my_file.c
+++ b/mysys/my_file.c
@@ -102,7 +102,8 @@ uint my_set_max_open_files(uint files)
if (files <= MY_NFILE)
DBUG_RETURN(files);
- if (!(tmp= (struct st_my_file_info*) my_malloc(sizeof(*tmp) * files,
+ if (!(tmp= (struct st_my_file_info*) my_malloc(key_memory_my_file_info,
+ sizeof(*tmp) * files,
MYF(MY_WME))))
DBUG_RETURN(MY_NFILE);
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index ea13dfb6ee4..e7a94da5040 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -64,7 +64,7 @@ FILE *my_fopen(const char *filename, int flags, myf MyFlags)
statistic_increment(my_stream_opened,&THR_LOCK_open);
DBUG_RETURN(fd); /* safeguard */
}
- my_file_info[filedesc].name= (char*) my_strdup(filename,MyFlags);
+ my_file_info[filedesc].name= my_strdup(key_memory_my_file_info, filename, MyFlags);
statistic_increment(my_stream_opened, &THR_LOCK_open);
statistic_increment(my_file_total_opened, &THR_LOCK_open);
my_file_info[filedesc].type= STREAM_BY_FOPEN;
@@ -226,9 +226,10 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
}
else
{
- my_file_info[Filedes].name= my_strdup(name,MyFlags);
+ my_file_info[Filedes].name= my_strdup(key_memory_my_file_info,
+ name, MyFlags);
}
- my_file_info[Filedes].type = STREAM_BY_FDOPEN;
+ my_file_info[Filedes].type= STREAM_BY_FDOPEN;
}
}
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 9ebf63bf6ef..5576c8b5d5d 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -15,11 +15,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
-#include <my_global.h>
+#include <mysys_priv.h>
#include <my_default.h>
#include <m_string.h>
#include <stdlib.h>
-#include <my_sys.h>
#include <mysys_err.h>
#include <my_getopt.h>
#include <errno.h>
@@ -754,7 +753,8 @@ static int setval(const struct my_option *opts, void *value, char *argument,
break;
case GET_STR_ALLOC:
my_free(*((char**) value));
- if (!(*((char**) value)= my_strdup(argument == enabled_my_option ? "" :
+ if (!(*((char**) value)= my_strdup(key_memory_defaults,
+ argument == enabled_my_option ? "" :
argument, MYF(MY_WME))))
{
res= EXIT_OUT_OF_MEMORY;
@@ -1343,7 +1343,7 @@ static void init_one_value(const struct my_option *option, void *variable,
{
char **pstr= (char **) variable;
my_free(*pstr);
- *pstr= my_strdup((char*) (intptr) value, MYF(MY_WME));
+ *pstr= my_strdup(key_memory_defaults, (char*) (intptr) value, MYF(MY_WME));
}
break;
default: /* dummy default to avoid compiler warnings */
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 8715c4a3333..14431b3ae73 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -124,16 +124,17 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
if (!(dirp= opendir(tmp_path)))
goto error;
- if (!(dirh= my_malloc(sizeof(*dirh), MyFlags | MY_ZEROFILL)))
+ if (!(dirh= my_malloc(key_memory_MY_DIR, sizeof(*dirh),
+ MYF(MyFlags | MY_ZEROFILL))))
goto error;
- if (my_init_dynamic_array(&dirh->array, sizeof(FILEINFO),
+ if (my_init_dynamic_array(&dirh->array, key_memory_MY_DIR, sizeof(FILEINFO),
ENTRIES_START_SIZE, ENTRIES_INCREMENT,
MYF(MyFlags)))
goto error;
- init_alloc_root(&dirh->root, "dir", NAMES_START_SIZE, NAMES_START_SIZE,
- MYF(MyFlags));
+ init_alloc_root(key_memory_MY_DIR, &dirh->root, NAMES_START_SIZE,
+ NAMES_START_SIZE, MYF(MyFlags));
dp= (struct dirent*) dirent_tmp;
@@ -227,15 +228,15 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
tmp_file[2]='*';
tmp_file[3]='\0';
- if (!(dirh= my_malloc(sizeof(*dirh), MyFlags | MY_ZEROFILL)))
+ if (!(dirh= my_malloc(PSI_INSTRUMENT_ME, sizeof(*dirh), MyFlags | MY_ZEROFILL)))
goto error;
- if (my_init_dynamic_array(&dirh->array, sizeof(FILEINFO),
+ if (my_init_dynamic_array(&dirh->array, PSI_INSTRUMENT_ME, sizeof(FILEINFO),
ENTRIES_START_SIZE, ENTRIES_INCREMENT,
MYF(MyFlags)))
goto error;
- init_alloc_root(&dirh->root, "dir", NAMES_START_SIZE, NAMES_START_SIZE,
+ init_alloc_root(PSI_INSTRUMENT_ME, &dirh->root, NAMES_START_SIZE, NAMES_START_SIZE,
MYF(MyFlags));
if ((handle=_findfirst(tmp_path,&find)) == -1L)
@@ -341,7 +342,8 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
stat_area, my_flags));
if ((m_used= (stat_area == NULL)))
- if (!(stat_area= (MY_STAT *) my_malloc(sizeof(MY_STAT), my_flags)))
+ if (!(stat_area= (MY_STAT *) my_malloc(key_memory_MY_STAT, sizeof(MY_STAT),
+ my_flags)))
goto error;
#ifndef _WIN32
if (! stat((char *) path, (struct stat *) stat_area) )
diff --git a/mysys/my_likely.c b/mysys/my_likely.c
index c6fca5b7146..5b6c781ad06 100644
--- a/mysys/my_likely.c
+++ b/mysys/my_likely.c
@@ -48,10 +48,9 @@ HASH likely_hash;
void init_my_likely()
{
/* Allocate big enough to avoid malloc calls */
- my_hash_init2(&likely_hash, 10000, &my_charset_bin,
- 1024, 0, 0,
+ my_hash_init2(&likely_hash, 10000, &my_charset_bin, 1024, 0, 0,
(my_hash_get_key) get_likely_key, 0,
- free, HASH_UNIQUE);
+ free, HASH_UNIQUE, PSI_INSTRUMENT_ME);
likely_inited= 1;
pthread_mutex_init(&likely_mutex, MY_MUTEX_INIT_FAST);
}
diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c
index d54270a7f20..33880f023a9 100644
--- a/mysys/my_malloc.c
+++ b/mysys/my_malloc.c
@@ -19,35 +19,17 @@
#include "mysys_err.h"
#include <m_string.h>
-/* If we have our own safemalloc (for debugging) */
-#if defined(SAFEMALLOC)
-#define MALLOC_SIZE_AND_FLAG(p,b) sf_malloc_usable_size(p,b)
-#define MALLOC_PREFIX_SIZE 0
-#define MALLOC_STORE_SIZE(a,b,c,d)
-#define MALLOC_FIX_POINTER_FOR_FREE(a) a
-#else
-/*
- * We use double as prefix size as this guarantees the correct
- * alignment on all platforms and will optimize things for
- * memcpy(), memcmp() etc.
- */
-#define MALLOC_PREFIX_SIZE (sizeof(double))
-#define MALLOC_SIZE(p) (*(size_t*) ((char*)(p) - MALLOC_PREFIX_SIZE))
-#define MALLOC_STORE_SIZE(p, type_of_p, size, flag) \
-{\
- *(size_t*) p= (size) | (flag); \
- (p)= (type_of_p) (((char*) (p)) + MALLOC_PREFIX_SIZE); \
-}
-static inline size_t malloc_size_and_flag(void *p, my_bool *is_thread_specific)
+struct my_memory_header
{
- size_t size= MALLOC_SIZE(p);
- *is_thread_specific= (size & 1);
- return size & ~ (ulonglong) 1;
-}
-#define MALLOC_SIZE_AND_FLAG(p,b) malloc_size_and_flag(p, b);
-#define MALLOC_FIX_POINTER_FOR_FREE(p) (((char*) (p)) - MALLOC_PREFIX_SIZE)
-#endif /* SAFEMALLOC */
+ PSI_thread *m_owner;
+ size_t m_size;
+ PSI_memory_key m_key;
+};
+typedef struct my_memory_header my_memory_header;
+#define HEADER_SIZE 24
+#define USER_TO_HEADER(P) ((my_memory_header*)((char *)(P) - HEADER_SIZE))
+#define HEADER_TO_USER(P) ((char*)(P) + HEADER_SIZE)
/**
Inform application that memory usage has changed
@@ -82,12 +64,13 @@ void set_malloc_size_cb(MALLOC_SIZE_CB func)
@return A pointer to the allocated memory block, or NULL on failure.
*/
-void *my_malloc(size_t size, myf my_flags)
+void *my_malloc(PSI_memory_key key, size_t size, myf my_flags)
{
- void* point;
+ my_memory_header *mh;
+ void *point;
DBUG_ENTER("my_malloc");
- DBUG_PRINT("my",("size: %lu my_flags: %lu", (ulong) size, my_flags));
- compile_time_assert(sizeof(size_t) <= sizeof(double));
+ DBUG_PRINT("my",("size: %zu flags: %lu", size, my_flags));
+ compile_time_assert(sizeof(my_memory_header) <= HEADER_SIZE);
if (!(my_flags & (MY_WME | MY_FAE)))
my_flags|= my_global_flags;
@@ -96,11 +79,15 @@ void *my_malloc(size_t size, myf my_flags)
if (!size)
size=1;
- /* We have to align size to be able to store markers in it */
+ /* We have to align size as we store MY_THREAD_SPECIFIC flag in the LSB */
size= ALIGN_SIZE(size);
- point= sf_malloc(size + MALLOC_PREFIX_SIZE, my_flags);
- if (point == NULL)
+ if (DBUG_EVALUATE_IF("simulate_out_of_memory", 1, 0))
+ mh= NULL;
+ else
+ mh= (my_memory_header*) sf_malloc(size + HEADER_SIZE, my_flags);
+
+ if (mh == NULL)
{
my_errno=errno;
if (my_flags & MY_FAE)
@@ -109,22 +96,19 @@ void *my_malloc(size_t size, myf my_flags)
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_ERROR_LOG+ME_FATAL),size);
if (my_flags & MY_FAE)
abort();
+ point= NULL;
}
else
{
- MALLOC_STORE_SIZE(point, void*, size,
- MY_TEST(my_flags & MY_THREAD_SPECIFIC));
- update_malloc_size(size + MALLOC_PREFIX_SIZE,
- MY_TEST(my_flags & MY_THREAD_SPECIFIC));
- TRASH_ALLOC(point, size);
- DBUG_EXECUTE_IF("simulate_out_of_memory",
- {
- /* my_free() handles memory accounting */
- my_free(point);
- point= NULL;
- });
+ int flag= MY_TEST(my_flags & MY_THREAD_SPECIFIC);
+ mh->m_size= size | flag;
+ mh->m_key= PSI_CALL_memory_alloc(key, size, & mh->m_owner);
+ update_malloc_size(size + HEADER_SIZE, flag);
+ point= HEADER_TO_USER(mh);
if (my_flags & MY_ZEROFILL)
bzero(point, size);
+ else
+ TRASH_ALLOC(point, size);
}
DBUG_PRINT("exit",("ptr: %p", point));
DBUG_RETURN(point);
@@ -134,62 +118,57 @@ void *my_malloc(size_t size, myf my_flags)
/**
@brief wrapper around realloc()
- @param oldpoint pointer to currently allocated area
+ @param old_point pointer to currently allocated area
@param size new size requested, must be >0
@param my_flags flags
@note if size==0 realloc() may return NULL; my_realloc() treats this as an
error which is not the intention of realloc()
*/
-void *my_realloc(void *oldpoint, size_t size, myf my_flags)
+void *my_realloc(PSI_memory_key key, void *old_point, size_t size, myf my_flags)
{
+ my_memory_header *old_mh, *mh;
void *point;
size_t old_size;
my_bool old_flags;
DBUG_ENTER("my_realloc");
- DBUG_PRINT("my",("ptr: %p size: %lu my_flags: %lu", oldpoint,
- (ulong) size, my_flags));
+ DBUG_PRINT("my",("ptr: %p size: %zu flags: %lu", old_point, size, my_flags));
DBUG_ASSERT(size > 0);
- if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
- DBUG_RETURN(my_malloc(size, my_flags));
+ if (!old_point && (my_flags & MY_ALLOW_ZERO_PTR))
+ DBUG_RETURN(my_malloc(key, size, my_flags));
+
+ old_mh= USER_TO_HEADER(old_point);
+ old_size= old_mh->m_size & ~1;
+ old_flags= old_mh->m_size & 1;
+
+ DBUG_ASSERT(old_mh->m_key == key || old_mh->m_key == PSI_NOT_INSTRUMENTED);
+ DBUG_ASSERT(old_flags == MY_TEST(my_flags & MY_THREAD_SPECIFIC));
size= ALIGN_SIZE(size);
- old_size= MALLOC_SIZE_AND_FLAG(oldpoint, &old_flags);
- /*
- Test that the new and old area are the same, if not MY_THREAD_MOVE is
- given
- */
- DBUG_ASSERT((MY_TEST(my_flags & MY_THREAD_SPECIFIC) == old_flags) ||
- (my_flags & MY_THREAD_MOVE));
- if ((point= sf_realloc(MALLOC_FIX_POINTER_FOR_FREE(oldpoint),
- size + MALLOC_PREFIX_SIZE, my_flags)) == NULL)
+ mh= sf_realloc(old_mh, size + HEADER_SIZE, my_flags);
+
+ if (mh == NULL)
{
+ if (size < old_size)
+ DBUG_RETURN(old_point);
+ my_errno=errno;
if (my_flags & MY_FREE_ON_ERROR)
{
/* my_free will take care of size accounting */
- my_free(oldpoint);
- oldpoint= 0;
+ my_free(old_point);
+ old_point= 0;
}
- if (my_flags & MY_HOLD_ON_ERROR)
- DBUG_RETURN(oldpoint);
- my_errno=errno;
if (my_flags & (MY_FAE+MY_WME))
my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_FATAL), size);
+ point= NULL;
}
else
{
- MALLOC_STORE_SIZE(point, void*, size,
- MY_TEST(my_flags & MY_THREAD_SPECIFIC));
- if (MY_TEST(my_flags & MY_THREAD_SPECIFIC) != old_flags)
- {
- /* memory moved between system and thread specific */
- update_malloc_size(-(longlong) old_size - MALLOC_PREFIX_SIZE, old_flags);
- update_malloc_size((longlong) size + MALLOC_PREFIX_SIZE,
- MY_TEST(my_flags & MY_THREAD_SPECIFIC));
- }
- else
- update_malloc_size((longlong)size - (longlong)old_size, old_flags);
+ mh->m_size= size | old_flags;
+ mh->m_key= PSI_CALL_memory_realloc(key, old_size, size, & mh->m_owner);
+ update_malloc_size((longlong)size - (longlong)old_size, old_flags);
+ point= HEADER_TO_USER(mh);
}
DBUG_PRINT("exit",("ptr: %p", point));
@@ -204,56 +183,63 @@ void *my_realloc(void *oldpoint, size_t size, myf my_flags)
*/
void my_free(void *ptr)
{
+ my_memory_header *mh;
+ size_t old_size;
+ my_bool old_flags;
DBUG_ENTER("my_free");
DBUG_PRINT("my",("ptr: %p", ptr));
- if (ptr)
- {
- size_t old_size;
- my_bool old_flags;
- old_size= MALLOC_SIZE_AND_FLAG(ptr, &old_flags);
- update_malloc_size(- (longlong) old_size - MALLOC_PREFIX_SIZE, old_flags);
+
+ if (ptr == NULL)
+ DBUG_VOID_RETURN;
+
+ mh= USER_TO_HEADER(ptr);
+ old_size= mh->m_size & ~1;
+ old_flags= mh->m_size & 1;
+ PSI_CALL_memory_free(mh->m_key, old_size, mh->m_owner);
+
+ update_malloc_size(- (longlong) old_size - HEADER_SIZE, old_flags);
+
#ifndef SAFEMALLOC
- /*
- Trash memory if not safemalloc. We don't have to do this if safemalloc
- is used as safemalloc will also do trashing
- */
- TRASH_FREE(ptr, old_size);
+ /*
+ Trash memory if not safemalloc. We don't have to do this if safemalloc
+ is used as safemalloc will also do trashing
+ */
+ TRASH_FREE(ptr, old_size);
#endif
- sf_free(MALLOC_FIX_POINTER_FOR_FREE(ptr));
- }
+ sf_free(mh);
DBUG_VOID_RETURN;
}
-void *my_memdup(const void *from, size_t length, myf my_flags)
+void *my_memdup(PSI_memory_key key, const void *from, size_t length, myf my_flags)
{
void *ptr;
DBUG_ENTER("my_memdup");
- if ((ptr= my_malloc(length,my_flags)) != 0)
+ if ((ptr= my_malloc(key, length,my_flags)) != 0)
memcpy(ptr, from, length);
DBUG_RETURN(ptr);
}
-char *my_strdup(const char *from, myf my_flags)
+char *my_strdup(PSI_memory_key key, const char *from, myf my_flags)
{
char *ptr;
size_t length= strlen(from)+1;
DBUG_ENTER("my_strdup");
- if ((ptr= (char*) my_malloc(length, my_flags)))
+ if ((ptr= (char*) my_malloc(key, length, my_flags)))
memcpy(ptr, from, length);
DBUG_RETURN(ptr);
}
-char *my_strndup(const char *from, size_t length, myf my_flags)
+char *my_strndup(PSI_memory_key key, const char *from, size_t length, myf my_flags)
{
char *ptr;
DBUG_ENTER("my_strndup");
- if ((ptr= (char*) my_malloc(length+1, my_flags)))
+ if ((ptr= (char*) my_malloc(key, length+1, my_flags)))
{
memcpy(ptr, from, length);
ptr[length]= 0;
diff --git a/mysys/my_open.c b/mysys/my_open.c
index 04324d13d71..a6cbffa0806 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -136,7 +136,7 @@ File my_register_filename(File fd, const char *FileName, enum file_type
thread_safe_increment32(&my_file_opened);
if ((uint) fd >= my_file_limit)
DBUG_RETURN(fd);
- my_file_info[fd].name = (char*) my_strdup(FileName, MyFlags);
+ my_file_info[fd].name = my_strdup(key_memory_my_file_info, FileName, MyFlags);
statistic_increment(my_file_total_opened,&THR_LOCK_open);
my_file_info[fd].type = type_of_file;
DBUG_PRINT("exit",("fd: %d",fd));
diff --git a/mysys/my_safehash.c b/mysys/my_safehash.c
index 7555f73fb30..39b73d603ef 100644
--- a/mysys/my_safehash.c
+++ b/mysys/my_safehash.c
@@ -102,7 +102,8 @@ my_bool safe_hash_init(SAFE_HASH *hash, uint elements,
DBUG_ENTER("safe_hash_init");
if (my_hash_init(&hash->hash, &my_charset_bin, elements,
0, 0, (my_hash_get_key) safe_hash_entry_get,
- (void (*)(void*)) safe_hash_entry_free, 0))
+ (void (*)(void*)) safe_hash_entry_free, 0,
+ key_memory_SAFE_HASH_ENTRY))
{
hash->default_value= 0;
DBUG_RETURN(1);
@@ -224,7 +225,8 @@ my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length,
}
else
{
- if (!(entry= (SAFE_HASH_ENTRY *) my_malloc(sizeof(*entry) + length,
+ if (!(entry= (SAFE_HASH_ENTRY *) my_malloc(key_memory_SAFE_HASH_ENTRY,
+ sizeof(*entry) + length,
MYF(MY_WME))))
{
error= 1;
diff --git a/mysys/my_static.c b/mysys/my_static.c
index 7474b789839..a18b7adef61 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -24,6 +24,36 @@
#include "my_alarm.h"
+PSI_memory_key key_memory_DYNAMIC_STRING;
+PSI_memory_key key_memory_IO_CACHE;
+PSI_memory_key key_memory_KEY_CACHE;
+PSI_memory_key key_memory_LIST;
+PSI_memory_key key_memory_MY_BITMAP_bitmap;
+PSI_memory_key key_memory_MY_DIR;
+PSI_memory_key key_memory_MY_STAT;
+PSI_memory_key key_memory_MY_TMPDIR_full_list;
+PSI_memory_key key_memory_QUEUE;
+PSI_memory_key key_memory_SAFE_HASH_ENTRY;
+PSI_memory_key key_memory_THD_ALARM;
+PSI_memory_key key_memory_TREE;
+PSI_memory_key key_memory_charset_file;
+PSI_memory_key key_memory_charset_loader;
+PSI_memory_key key_memory_defaults;
+PSI_memory_key key_memory_lf_dynarray;
+PSI_memory_key key_memory_lf_node;
+PSI_memory_key key_memory_lf_slist;
+PSI_memory_key key_memory_max_alloca;
+PSI_memory_key key_memory_my_compress_alloc;
+PSI_memory_key key_memory_my_err_head;
+PSI_memory_key key_memory_my_file_info;
+PSI_memory_key key_memory_pack_frm;
+
+#ifdef _WIN32
+PSI_memory_key key_memory_win_SECURITY_ATTRIBUTES;
+PSI_memory_key key_memory_win_PACL;
+PSI_memory_key key_memory_win_IP_ADAPTER_ADDRESSES;
+#endif /* _WIN32 */
+
/* from my_init */
char *home_dir=0;
char *mysql_data_home= (char*) ".";
diff --git a/mysys/my_windac.c b/mysys/my_windac.c
index 9a2686a44f4..d53f34f20e7 100644
--- a/mysys/my_windac.c
+++ b/mysys/my_windac.c
@@ -96,7 +96,7 @@ int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
}
GetTokenInformation(htoken, TokenUser, 0, 0, &owner_token_length);
- if (! my_multi_malloc(MYF(MY_WME),
+ if (! my_multi_malloc(MYF(MY_WME), PSI_INSTRUMENT_ME,
&sa, ALIGN_SIZE(sizeof(SECURITY_ATTRIBUTES)) +
sizeof(My_security_attr),
&sd, sizeof(SECURITY_DESCRIPTOR),
@@ -126,7 +126,7 @@ int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
GetLengthSid(everyone_sid) + GetLengthSid(owner_sid);
/* Create an ACL */
- if (! (dacl= (PACL) my_malloc(dacl_length, MYF(MY_ZEROFILL|MY_WME))))
+ if (! (dacl= (PACL) my_malloc(PSI_INSTRUMENT_ME, dacl_length, MYF(MY_ZEROFILL|MY_WME))))
{
*perror= "Failed to allocate memory for DACL";
goto error;
diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h
index 0fa6a4c553f..240d66a3b51 100644
--- a/mysys/mysys_priv.h
+++ b/mysys/mysys_priv.h
@@ -64,6 +64,36 @@ extern PSI_rwlock_key key_SAFEHASH_mutex;
extern PSI_stage_info stage_waiting_for_table_level_lock;
+/* These keys are always defined. */
+
+extern PSI_memory_key key_memory_DYNAMIC_STRING;
+extern PSI_memory_key key_memory_IO_CACHE;
+extern PSI_memory_key key_memory_KEY_CACHE;
+extern PSI_memory_key key_memory_LIST;
+extern PSI_memory_key key_memory_MY_BITMAP_bitmap;
+extern PSI_memory_key key_memory_MY_DIR;
+extern PSI_memory_key key_memory_MY_STAT;
+extern PSI_memory_key key_memory_MY_TMPDIR_full_list;
+extern PSI_memory_key key_memory_QUEUE;
+extern PSI_memory_key key_memory_SAFE_HASH_ENTRY;
+extern PSI_memory_key key_memory_TREE;
+extern PSI_memory_key key_memory_charset_file;
+extern PSI_memory_key key_memory_charset_loader;
+extern PSI_memory_key key_memory_defaults;
+extern PSI_memory_key key_memory_lf_dynarray;
+extern PSI_memory_key key_memory_lf_node;
+extern PSI_memory_key key_memory_lf_slist;
+extern PSI_memory_key key_memory_my_compress_alloc;
+extern PSI_memory_key key_memory_my_err_head;
+extern PSI_memory_key key_memory_my_file_info;
+extern PSI_memory_key key_memory_pack_frm;
+
+#ifdef _WIN32
+extern PSI_memory_key key_memory_win_SECURITY_ATTRIBUTES;
+extern PSI_memory_key key_memory_win_PACL;
+extern PSI_memory_key key_memory_win_IP_ADAPTER_ADDRESSES;
+#endif
+
extern mysql_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache;
extern mysql_mutex_t THR_LOCK_lock, THR_LOCK_net;
extern mysql_mutex_t THR_LOCK_charset;
diff --git a/mysys/queues.c b/mysys/queues.c
index 5d09ce2063f..aac70a4825d 100644
--- a/mysys/queues.c
+++ b/mysys/queues.c
@@ -76,7 +76,8 @@ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
{
DBUG_ENTER("init_queue");
- if ((queue->root= (uchar **) my_malloc((max_elements + 1) * sizeof(void*),
+ if ((queue->root= (uchar **) my_malloc(key_memory_QUEUE,
+ (max_elements + 1) * sizeof(void*),
MYF(MY_WME))) == 0)
DBUG_RETURN(1);
queue->elements= 0;
@@ -148,7 +149,7 @@ int resize_queue(QUEUE *queue, uint max_elements)
DBUG_ENTER("resize_queue");
if (queue->max_elements == max_elements)
DBUG_RETURN(0);
- if ((new_root= (uchar **) my_realloc((void *)queue->root,
+ if ((new_root= (uchar **) my_realloc(key_memory_QUEUE, (void *)queue->root,
(max_elements + 1)* sizeof(void*),
MYF(MY_WME))) == 0)
DBUG_RETURN(1);
diff --git a/mysys/string.c b/mysys/string.c
index 7c56b95af25..b346393d91e 100644
--- a/mysys/string.c
+++ b/mysys/string.c
@@ -36,7 +36,8 @@ my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
if (!init_alloc)
init_alloc=alloc_increment;
- if (!(str->str=(char*) my_malloc(init_alloc,MYF(MY_WME))))
+ if (!(str->str=(char*) my_malloc(key_memory_DYNAMIC_STRING,
+ init_alloc, MYF(MY_WME))))
DBUG_RETURN(TRUE);
str->length=length-1;
if (init_str)
@@ -58,7 +59,8 @@ my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str)
str->alloc_increment;
if (!str->max_length)
str->max_length=str->alloc_increment;
- if (!(str->str=(char*) my_realloc(str->str,str->max_length,MYF(MY_WME))))
+ if (!(str->str=(char*) my_realloc(key_memory_DYNAMIC_STRING,
+ str->str, str->max_length, MYF(MY_WME))))
DBUG_RETURN(TRUE);
}
if (init_str)
@@ -81,7 +83,8 @@ my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size)
{
str->max_length=((str->length + additional_size+str->alloc_increment-1)/
str->alloc_increment)*str->alloc_increment;
- if (!(str->str=(char*) my_realloc(str->str,str->max_length,MYF(MY_WME))))
+ if (!(str->str=(char*) my_realloc(key_memory_DYNAMIC_STRING, str->str,
+ str->max_length, MYF(MY_WME))))
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE);
@@ -104,7 +107,8 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
size_t new_length=(str->length+length+str->alloc_increment)/
str->alloc_increment;
new_length*=str->alloc_increment;
- if (!(new_ptr=(char*) my_realloc(str->str,new_length,MYF(MY_WME))))
+ if (!(new_ptr=(char*) my_realloc(key_memory_DYNAMIC_STRING, str->str,
+ new_length, MYF(MY_WME))))
DBUG_RETURN(TRUE);
str->str=new_ptr;
str->max_length=new_length;
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 9bc70b283cb..92a471075c6 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -185,7 +185,8 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data)
now= my_time(0);
if (!alarm_data)
{
- if (!(alarm_data=(ALARM*) my_malloc(sizeof(ALARM),MYF(MY_WME))))
+ if (!(alarm_data=(ALARM*) my_malloc(PSI_INSTRUMENT_ME, sizeof(ALARM),
+ MYF(MY_WME))))
goto abort_no_unlock;
alarm_data->malloced= 1;
}
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index 568ed3ecb46..1b0ad56a6d5 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -156,7 +156,7 @@ static inline void remove_from_active_list(safe_mutex_t *mp)
static int safe_mutex_lazy_init_deadlock_detection(safe_mutex_t *mp)
{
- if (!my_multi_malloc(MY_FAE | MY_WME,
+ if (!my_multi_malloc(PSI_NOT_INSTRUMENTED, MY_FAE | MY_WME,
&mp->locked_mutex, sizeof(*mp->locked_mutex),
&mp->used_mutex, sizeof(*mp->used_mutex), NullS))
{
@@ -169,16 +169,12 @@ static int safe_mutex_lazy_init_deadlock_detection(safe_mutex_t *mp)
pthread_mutex_lock(&THR_LOCK_mutex);
mp->id= ++safe_mutex_id;
pthread_mutex_unlock(&THR_LOCK_mutex);
- my_hash_init2(mp->locked_mutex, 64, &my_charset_bin,
- 128,
- offsetof(safe_mutex_deadlock_t, id),
- sizeof(mp->id),
- 0, 0, 0, HASH_UNIQUE);
- my_hash_init2(mp->used_mutex, 64, &my_charset_bin,
- 128,
- offsetof(safe_mutex_t, id),
- sizeof(mp->id),
- 0, 0, 0, HASH_UNIQUE);
+ my_hash_init2(mp->locked_mutex, 64, &my_charset_bin, 128,
+ offsetof(safe_mutex_deadlock_t, id), sizeof(mp->id), 0, 0, 0,
+ HASH_UNIQUE, PSI_NOT_INSTRUMENTED);
+ my_hash_init2(mp->used_mutex, 64, &my_charset_bin, 128,
+ offsetof(safe_mutex_t, id), sizeof(mp->id), 0, 0, 0,
+ HASH_UNIQUE, PSI_NOT_INSTRUMENTED);
return 0;
}
@@ -341,7 +337,7 @@ int safe_mutex_lock(safe_mutex_t *mp, myf my_flags, const char *file,
safe_mutex_t *mutex;
/* Create object to store mutex info */
- if (!(deadlock= my_malloc(sizeof(*deadlock),
+ if (!(deadlock= my_malloc(PSI_NOT_INSTRUMENTED, sizeof(*deadlock),
MYF(MY_ZEROFILL | MY_WME | MY_FAE))))
goto abort_loop;
deadlock->name= mp->name;
diff --git a/mysys/tree.c b/mysys/tree.c
index 8cae30e2d3e..cd44f779e6f 100644
--- a/mysys/tree.c
+++ b/mysys/tree.c
@@ -128,7 +128,7 @@ void init_tree(TREE *tree, size_t default_alloc_size, size_t memory_limit,
}
if (!(tree->with_delete= MY_TEST(my_flags & MY_TREE_WITH_DELETE)))
{
- init_alloc_root(&tree->mem_root, "tree", default_alloc_size, 0,
+ init_alloc_root(key_memory_TREE, &tree->mem_root, default_alloc_size, 0,
MYF(my_flags));
tree->mem_root.min_malloc= sizeof(TREE_ELEMENT)+tree->size_of_element;
}
@@ -275,7 +275,7 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size,
key_size+=tree->size_of_element;
if (tree->with_delete)
- element=(TREE_ELEMENT *) my_malloc(alloc_size,
+ element=(TREE_ELEMENT *) my_malloc(key_memory_TREE, alloc_size,
MYF(tree->my_flags | MY_WME));
else
element=(TREE_ELEMENT *) alloc_root(&tree->mem_root,alloc_size);
diff --git a/mysys/waiting_threads.c b/mysys/waiting_threads.c
index 4564059b31a..a930e1d203b 100644
--- a/mysys/waiting_threads.c
+++ b/mysys/waiting_threads.c
@@ -394,7 +394,8 @@ static void wt_resource_create(uchar *arg)
bzero(rc, sizeof(*rc));
rc_rwlock_init(rc);
mysql_cond_init(key_WT_RESOURCE_cond, &rc->cond, 0);
- my_init_dynamic_array(&rc->owners, sizeof(WT_THD *), 0, 5, MYF(0));
+ my_init_dynamic_array(&rc->owners, PSI_INSTRUMENT_ME,
+ sizeof(WT_THD *), 0, 5, MYF(0));
DBUG_VOID_RETURN;
}
@@ -507,7 +508,8 @@ void wt_thd_lazy_init(WT_THD *thd, const ulong *ds, const ulong *ts,
thd->deadlock_search_depth_long= dl;
thd->timeout_long= tl;
/* dynamic array is also initialized lazily - without memory allocations */
- my_init_dynamic_array(&thd->my_resources, sizeof(WT_RESOURCE *), 0, 5, MYF(0));
+ my_init_dynamic_array(&thd->my_resources, PSI_INSTRUMENT_ME,
+ sizeof(WT_RESOURCE *), 0, 5, MYF(0));
#ifndef DBUG_OFF
thd->name= my_thread_name();
#endif