1
/******************************************************
2
Binary buddy allocator for compressed pages
6
Created December 2006 by Marko Makela
7
*******************************************************/
9
#ifdef UNIV_MATERIALIZE
15
#include "buf0buddy.h"
17
#include "sync0sync.h"
19
/**************************************************************************
20
Allocate a block. The thread calling this function must hold
21
buf_pool_mutex and must not hold buf_pool_zip_mutex or any block->mutex.
22
The buf_pool_mutex may only be released and reacquired if lru != NULL. */
27
/* out: allocated block,
28
possibly NULL if lru==NULL */
29
ulint i, /* in: index of buf_pool->zip_free[],
31
ibool* lru) /* in: pointer to a variable that will be assigned
32
TRUE if storage was allocated from the LRU list
33
and buf_pool_mutex was temporarily released,
34
or NULL if the LRU list should not be used */
35
__attribute__((malloc));
37
/**************************************************************************
38
Deallocate a block. */
43
void* buf, /* in: block to be freed, must not be
44
pointed to by the buffer pool */
45
ulint i) /* in: index of buf_pool->zip_free[],
47
__attribute__((nonnull));
49
/**************************************************************************
50
Get the index of buf_pool->zip_free[] for a given block size. */
55
/* out: index of buf_pool->zip_free[],
57
ulint size) /* in: block size */
62
for (i = 0, s = BUF_BUDDY_LOW; s < size; i++, s <<= 1) {};
64
ut_ad(i <= BUF_BUDDY_SIZES);
68
/**************************************************************************
69
Allocate a block. The thread calling this function must hold
70
buf_pool_mutex and must not hold buf_pool_zip_mutex or any
71
block->mutex. The buf_pool_mutex may only be released and reacquired
72
if lru != NULL. This function should only be used for allocating
73
compressed page frames or control blocks (buf_page_t). Allocated
74
control blocks must be properly initialized immediately after
75
buf_buddy_alloc() has returned the memory, before releasing
81
/* out: allocated block,
82
possibly NULL if lru == NULL */
83
ulint size, /* in: block size, up to UNIV_PAGE_SIZE */
84
ibool* lru) /* in: pointer to a variable that will be assigned
85
TRUE if storage was allocated from the LRU list
86
and buf_pool_mutex was temporarily released,
87
or NULL if the LRU list should not be used */
89
ut_ad(buf_pool_mutex_own());
91
return(buf_buddy_alloc_low(buf_buddy_get_slot(size), lru));
94
/**************************************************************************
95
Deallocate a block. */
100
void* buf, /* in: block to be freed, must not be
101
pointed to by the buffer pool */
102
ulint size) /* in: block size, up to UNIV_PAGE_SIZE */
104
ut_ad(buf_pool_mutex_own());
106
buf_buddy_free_low(buf, buf_buddy_get_slot(size));
109
#ifdef UNIV_MATERIALIZE
111
# define UNIV_INLINE UNIV_INLINE_ORIGINAL