Commit 7ac6a343 authored by marko's avatar marko

branches/zip: Add instrumentation for prohibiting the release of

the buffer pool mutex.  The instrumentation can be activated by
defining UNIV_DEBUG or UNIV_BUF_DEBUG at compilation time.

buf_pool_mutex_exit_forbidden: New variable.  When this is nonzero,
an assertion will fail in buf_pool_mutex_exit().

buf_pool_mutex_exit_forbid(): Macro for declaring that the buffer pool
mutex must not be released.  Calls may be nested.

buf_pool_mutex_exit_allow(): Macro for declaring that the buffer pool
mutex may be released.  Calls may be nested.

buf_LRU_search_and_free_block(): Prohibit buf_pool_mutex_exit() in the
scope of the function.

buf_LRU_free_block(): Prohibit buf_pool_mutex_exit() in buf_buddy_alloc()
and buf_buddy_free().

buf_LRU_block_remove_hashed_page(): Prohibit buf_pool_mutex_exit()
in buf_buddy_free().
parent cdb5b464
...@@ -235,6 +235,9 @@ mutex_t buf_pool_zip_mutex; ...@@ -235,6 +235,9 @@ mutex_t buf_pool_zip_mutex;
static ulint buf_dbg_counter = 0; /* This is used to insert validation static ulint buf_dbg_counter = 0; /* This is used to insert validation
operations in excution in the operations in excution in the
debug version */ debug version */
/** Flag to forbid the release of the buffer pool mutex.
Protected by buf_pool->mutex. */
ulint buf_pool_mutex_exit_forbidden = 0;
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
ibool buf_debug_prints = FALSE; /* If this is set TRUE, ibool buf_debug_prints = FALSE; /* If this is set TRUE,
......
...@@ -267,6 +267,7 @@ buf_LRU_search_and_free_block( ...@@ -267,6 +267,7 @@ buf_LRU_search_and_free_block(
ibool freed; ibool freed;
buf_pool_mutex_enter(); buf_pool_mutex_enter();
buf_pool_mutex_exit_forbid();
freed = FALSE; freed = FALSE;
bpage = UT_LIST_GET_LAST(buf_pool->LRU); bpage = UT_LIST_GET_LAST(buf_pool->LRU);
...@@ -355,6 +356,7 @@ func_exit: ...@@ -355,6 +356,7 @@ func_exit:
if (!freed) { if (!freed) {
buf_pool->LRU_flush_ended = 0; buf_pool->LRU_flush_ended = 0;
} }
buf_pool_mutex_exit_allow();
buf_pool_mutex_exit(); buf_pool_mutex_exit();
return(freed); return(freed);
...@@ -983,7 +985,9 @@ buf_LRU_free_block( ...@@ -983,7 +985,9 @@ buf_LRU_free_block(
If it cannot be allocated (without freeing a block If it cannot be allocated (without freeing a block
from the LRU list), refuse to free bpage. */ from the LRU list), refuse to free bpage. */
alloc: alloc:
buf_pool_mutex_exit_forbid();
b = buf_buddy_alloc(sizeof *b, NULL); b = buf_buddy_alloc(sizeof *b, NULL);
buf_pool_mutex_exit_allow();
if (UNIV_UNLIKELY(!b)) { if (UNIV_UNLIKELY(!b)) {
return(FALSE); return(FALSE);
...@@ -1155,7 +1159,9 @@ buf_LRU_block_free_non_file_page( ...@@ -1155,7 +1159,9 @@ buf_LRU_block_free_non_file_page(
if (data) { if (data) {
block->page.zip.data = NULL; block->page.zip.data = NULL;
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
buf_pool_mutex_exit_forbid();
buf_buddy_free(data, page_zip_get_size(&block->page.zip)); buf_buddy_free(data, page_zip_get_size(&block->page.zip));
buf_pool_mutex_exit_allow();
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
page_zip_set_size(&block->page.zip, 0); page_zip_set_size(&block->page.zip, 0);
} }
...@@ -1305,9 +1311,11 @@ buf_LRU_block_remove_hashed_page( ...@@ -1305,9 +1311,11 @@ buf_LRU_block_remove_hashed_page(
UT_LIST_REMOVE(list, buf_pool->zip_clean, bpage); UT_LIST_REMOVE(list, buf_pool->zip_clean, bpage);
mutex_exit(&buf_pool_zip_mutex); mutex_exit(&buf_pool_zip_mutex);
buf_pool_mutex_exit_forbid();
buf_buddy_free(bpage->zip.data, buf_buddy_free(bpage->zip.data,
page_zip_get_size(&bpage->zip)); page_zip_get_size(&bpage->zip));
buf_buddy_free(bpage, sizeof(*bpage)); buf_buddy_free(bpage, sizeof(*bpage));
buf_pool_mutex_exit_allow();
UNIV_MEM_UNDESC(bpage); UNIV_MEM_UNDESC(bpage);
return(BUF_BLOCK_ZIP_FREE); return(BUF_BLOCK_ZIP_FREE);
......
...@@ -1277,8 +1277,35 @@ buf_pool_mutex directly. */ ...@@ -1277,8 +1277,35 @@ buf_pool_mutex directly. */
ut_ad(!mutex_own(&buf_pool_zip_mutex)); \ ut_ad(!mutex_own(&buf_pool_zip_mutex)); \
mutex_enter(&buf_pool_mutex); \ mutex_enter(&buf_pool_mutex); \
} while (0) } while (0)
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/** Flag to forbid the release of the buffer pool mutex.
Protected by buf_pool_mutex. */
extern ulint buf_pool_mutex_exit_forbidden;
/* Forbid the release of the buffer pool mutex. */
# define buf_pool_mutex_exit_forbid() do { \
ut_ad(buf_pool_mutex_own()); \
buf_pool_mutex_exit_forbidden++; \
} while (0)
/* Allow the release of the buffer pool mutex. */
# define buf_pool_mutex_exit_allow() do { \
ut_ad(buf_pool_mutex_own()); \
ut_a(buf_pool_mutex_exit_forbidden); \
buf_pool_mutex_exit_forbidden--; \
} while (0)
/* Release the buffer pool mutex. */ /* Release the buffer pool mutex. */
#define buf_pool_mutex_exit() mutex_exit(&buf_pool_mutex) # define buf_pool_mutex_exit() do { \
ut_a(!buf_pool_mutex_exit_forbidden); \
mutex_exit(&buf_pool_mutex); \
} while (0)
#else
/* Forbid the release of the buffer pool mutex. */
# define buf_pool_mutex_exit_forbid() ((void) 0)
/* Allow the release of the buffer pool mutex. */
# define buf_pool_mutex_exit_allow() ((void) 0)
/* Release the buffer pool mutex. */
# define buf_pool_mutex_exit() mutex_exit(&buf_pool_mutex)
#endif
/************************************************************************ /************************************************************************
Let us list the consistency conditions for different control block states. Let us list the consistency conditions for different control block states.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment