Commit ff5f343b authored by marko's avatar marko

branches/zip: Minor improvements to the buddy allocator.

buf_buddy_alloc(), buf_buddy_alloc_low(): Add parameter "lru" for
enabling allocation from the list of least-recently-used blocks.

buf_buddy_alloc_low(): Release buf_pool->mutex while calling
buf_LRU_get_free_block().
parent 91aae178
......@@ -209,7 +209,8 @@ buf_buddy_alloc_low(
/*================*/
/* out: allocated block, or NULL
if buf_pool->zip_free[] was empty */
ulint i) /* in: index of buf_pool->zip_free[] */
ulint i, /* in: index of buf_pool->zip_free[] */
ibool lru) /* in: TRUE=allocate from the LRU list if needed */
{
buf_block_t* block;
......@@ -233,6 +234,11 @@ buf_buddy_alloc_low(
goto alloc_big;
}
if (!lru) {
return(NULL);
}
/* Try replacing a compressed-only page in the buffer pool. */
block = buf_buddy_alloc_clean_zip(i);
......@@ -243,7 +249,9 @@ buf_buddy_alloc_low(
}
/* Try replacing an uncompressed page in the buffer pool. */
mutex_exit(&buf_pool->mutex);
block = buf_LRU_get_free_block(0);
mutex_enter(&buf_pool->mutex);
alloc_big:
buf_buddy_block_register(block);
......
......@@ -48,7 +48,8 @@ void*
buf_buddy_alloc(
/*============*/
/* out: pointer to the start of the block */
ulint size) /* in: block size, up to UNIV_PAGE_SIZE / 2 */
ulint size, /* in: block size, up to UNIV_PAGE_SIZE / 2 */
ibool lru) /* in: TRUE=allocate from the LRU list if needed */
__attribute__((malloc));
/**************************************************************************
......
......@@ -25,7 +25,8 @@ void*
buf_buddy_alloc_low(
/*================*/
/* out: pointer to the start of the block */
ulint i) /* in: index of buf_pool->zip_free[] */
ulint i, /* in: index of buf_pool->zip_free[] */
ibool lru) /* in: TRUE=allocate from the LRU list if needed */
__attribute__((malloc));
/**************************************************************************
......@@ -84,13 +85,14 @@ void*
buf_buddy_alloc(
/*============*/
/* out: pointer to the start of the block */
ulint size) /* in: block size, up to UNIV_PAGE_SIZE / 2 */
ulint size, /* in: block size, up to UNIV_PAGE_SIZE / 2 */
ibool lru) /* in: TRUE=allocate from the LRU list if needed */
{
#ifdef UNIV_SYNC_DEBUG
ut_a(mutex_own(&buf_pool->mutex));
#endif /* UNIV_SYNC_DEBUG */
return(buf_buddy_alloc_low(buf_buddy_get_slot(size)));
return(buf_buddy_alloc_low(buf_buddy_get_slot(size), lru));
}
/**************************************************************************
......
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