diff options
author | Vasil Dimov <vasil.dimov@oracle.com> | 2010-04-12 18:20:41 +0300 |
---|---|---|
committer | Vasil Dimov <vasil.dimov@oracle.com> | 2010-04-12 18:20:41 +0300 |
commit | c877ff39bceb4df96acf3e54f7c98a2bed12b8ee (patch) | |
tree | 04211a3e5734b73e9f94cff511a4a74ff87075f0 /storage/innobase/mem | |
parent | fe0828b3b8193e086abe740572c9b0cb2b7da671 (diff) | |
parent | 410e23a6af8b597cdda0890d6ed9008355edee7a (diff) | |
download | mariadb-git-c877ff39bceb4df96acf3e54f7c98a2bed12b8ee.tar.gz |
Import branches/innodb+ from SVN on top of storage/innobase.
Diffstat (limited to 'storage/innobase/mem')
-rw-r--r-- | storage/innobase/mem/mem0dbg.c | 16 | ||||
-rw-r--r-- | storage/innobase/mem/mem0mem.c | 20 | ||||
-rw-r--r-- | storage/innobase/mem/mem0pool.c | 7 |
3 files changed, 38 insertions, 5 deletions
diff --git a/storage/innobase/mem/mem0dbg.c b/storage/innobase/mem/mem0dbg.c index 01eda20ec45..d91e610a08a 100644 --- a/storage/innobase/mem/mem0dbg.c +++ b/storage/innobase/mem/mem0dbg.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -29,7 +29,13 @@ Created 6/9/1994 Heikki Tuuri /* The mutex which protects in the debug version the hash table containing the list of live memory heaps, and also the global variables below. */ -UNIV_INTERN mutex_t mem_hash_mutex; +UNIV_INTERN mutex_t mem_hash_mutex; + +#ifdef UNIV_PFS_MUTEX +/* Key to register mem_hash_mutex with performance schema */ +UNIV_INTERN mysql_pfs_key_t mem_hash_mutex_key; +#endif /* UNIV_PFS_MUTEX */ + # endif /* !UNIV_HOTBACKUP */ /* The following variables contain information about the @@ -149,7 +155,7 @@ mem_init( /* Initialize the hash table */ ut_a(FALSE == mem_hash_initialized); - mutex_create(&mem_hash_mutex, SYNC_MEM_HASH); + mutex_create(mem_hash_mutex_key, &mem_hash_mutex, SYNC_MEM_HASH); for (i = 0; i < MEM_HASH_SIZE; i++) { UT_LIST_INIT(*mem_hash_get_nth_cell(i)); @@ -180,6 +186,10 @@ mem_close(void) { mem_pool_free(mem_comm_pool); mem_comm_pool = NULL; +#ifdef UNIV_MEM_DEBUG + mutex_free(&mem_hash_mutex); + mem_hash_initialized = FALSE; +#endif /* UNIV_MEM_DEBUG */ } #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/innobase/mem/mem0mem.c b/storage/innobase/mem/mem0mem.c index ccb2fd8a7b4..c0ce8a3e1ac 100644 --- a/storage/innobase/mem/mem0mem.c +++ b/storage/innobase/mem/mem0mem.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -383,6 +383,20 @@ mem_heap_create_block( mem_block_set_free(block, MEM_BLOCK_HEADER_SIZE); mem_block_set_start(block, MEM_BLOCK_HEADER_SIZE); + if (UNIV_UNLIKELY(heap == NULL)) { + /* This is the first block of the heap. The field + total_size should be initialized here */ + block->total_size = len; + } else { + /* Not the first allocation for the heap. This block's + total_length field should be set to undefined. */ + ut_d(block->total_size = ULINT_UNDEFINED); + UNIV_MEM_INVALID(&block->total_size, + sizeof block->total_size); + + heap->total_size += len; + } + ut_ad((ulint)MEM_BLOCK_HEADER_SIZE < len); return(block); @@ -471,6 +485,10 @@ mem_heap_block_free( mem_pool_mutex_exit(); #endif + + ut_ad(heap->total_size >= block->len); + heap->total_size -= block->len; + type = heap->type; len = block->len; block->magic_n = MEM_FREED_BLOCK_MAGIC_N; diff --git a/storage/innobase/mem/mem0pool.c b/storage/innobase/mem/mem0pool.c index c4f8af607e0..cb33e788bee 100644 --- a/storage/innobase/mem/mem0pool.c +++ b/storage/innobase/mem/mem0pool.c @@ -114,6 +114,11 @@ struct mem_pool_struct{ /** The common memory pool */ UNIV_INTERN mem_pool_t* mem_comm_pool = NULL; +#ifdef UNIV_PFS_MUTEX +/* Key to register mutex in mem_pool_struct with performance schema */ +UNIV_INTERN mysql_pfs_key_t mem_pool_mutex_key; +#endif /* UNIV_PFS_MUTEX */ + /* We use this counter to check that the mem pool mutex does not leak; this is to track a strange assertion failure reported at mysql@lists.mysql.com */ @@ -219,7 +224,7 @@ mem_pool_create( pool->buf = ut_malloc_low(size, FALSE, TRUE); pool->size = size; - mutex_create(&pool->mutex, SYNC_MEM_POOL); + mutex_create(mem_pool_mutex_key, &pool->mutex, SYNC_MEM_POOL); /* Initialize the free lists */ |