17
17
*****************************************************************************/
19
/******************************************************
19
/**************************************************//**
20
@file include/buf0buddy.ic
20
21
Binary buddy allocator for compressed pages
22
23
Created December 2006 by Marko Makela
33
34
#include "sync0sync.h"
35
/**************************************************************************
36
/**********************************************************************//**
36
37
Allocate a block. The thread calling this function must hold
37
38
buf_pool_mutex and must not hold buf_pool_zip_mutex or any block->mutex.
38
The buf_pool_mutex may only be released and reacquired if lru != NULL. */
39
The buf_pool_mutex may only be released and reacquired if lru != NULL.
40
@return allocated block, possibly NULL if lru==NULL */
41
43
buf_buddy_alloc_low(
42
44
/*================*/
43
/* out: allocated block,
44
possibly NULL if lru==NULL */
45
ulint i, /* in: index of buf_pool->zip_free[],
45
ulint i, /*!< in: index of buf_pool->zip_free[],
46
46
or BUF_BUDDY_SIZES */
47
ibool* lru) /* in: pointer to a variable that will be assigned
47
ibool* lru) /*!< in: pointer to a variable that will be assigned
48
48
TRUE if storage was allocated from the LRU list
49
49
and buf_pool_mutex was temporarily released,
50
50
or NULL if the LRU list should not be used */
51
51
__attribute__((malloc));
53
/**************************************************************************
53
/**********************************************************************//**
54
54
Deallocate a block. */
57
57
buf_buddy_free_low(
58
58
/*===============*/
59
void* buf, /* in: block to be freed, must not be
59
void* buf, /*!< in: block to be freed, must not be
60
60
pointed to by the buffer pool */
61
ulint i) /* in: index of buf_pool->zip_free[],
61
ulint i) /*!< in: index of buf_pool->zip_free[],
62
62
or BUF_BUDDY_SIZES */
63
63
__attribute__((nonnull));
65
/**************************************************************************
66
Get the index of buf_pool->zip_free[] for a given block size. */
65
/**********************************************************************//**
66
Get the index of buf_pool->zip_free[] for a given block size.
67
@return index of buf_pool->zip_free[], or BUF_BUDDY_SIZES */
69
70
buf_buddy_get_slot(
70
71
/*===============*/
71
/* out: index of buf_pool->zip_free[],
73
ulint size) /* in: block size */
72
ulint size) /*!< in: block size */
85
/**************************************************************************
84
/**********************************************************************//**
86
85
Allocate a block. The thread calling this function must hold
87
86
buf_pool_mutex and must not hold buf_pool_zip_mutex or any
88
87
block->mutex. The buf_pool_mutex may only be released and reacquired
90
89
compressed page frames or control blocks (buf_page_t). Allocated
91
90
control blocks must be properly initialized immediately after
92
91
buf_buddy_alloc() has returned the memory, before releasing
93
@return allocated block, possibly NULL if lru == NULL */
98
/* out: allocated block,
99
possibly NULL if lru == NULL */
100
ulint size, /* in: block size, up to UNIV_PAGE_SIZE */
101
ibool* lru) /* in: pointer to a variable that will be assigned
98
ulint size, /*!< in: block size, up to UNIV_PAGE_SIZE */
99
ibool* lru) /*!< in: pointer to a variable that will be assigned
102
100
TRUE if storage was allocated from the LRU list
103
101
and buf_pool_mutex was temporarily released,
104
102
or NULL if the LRU list should not be used */
108
106
return(buf_buddy_alloc_low(buf_buddy_get_slot(size), lru));
111
/**************************************************************************
109
/**********************************************************************//**
112
110
Deallocate a block. */
117
void* buf, /* in: block to be freed, must not be
115
void* buf, /*!< in: block to be freed, must not be
118
116
pointed to by the buffer pool */
119
ulint size) /* in: block size, up to UNIV_PAGE_SIZE */
117
ulint size) /*!< in: block size, up to UNIV_PAGE_SIZE */
121
119
ut_ad(buf_pool_mutex_own());