~drizzle-trunk/drizzle/development

641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
1
/*****************************************************************************
2
3
Copyright (c) 2006, 2009, Innobase Oy. All Rights Reserved.
4
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
8
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
16
17
*****************************************************************************/
18
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
19
/******************************************************
20
Binary buddy allocator for compressed pages
21
22
Created December 2006 by Marko Makela
23
*******************************************************/
24
25
#ifndef buf0buddy_h
26
#define buf0buddy_h
27
28
#ifdef UNIV_MATERIALIZE
29
# undef UNIV_INLINE
30
# define UNIV_INLINE
31
#endif
32
33
#include "univ.i"
34
#include "buf0types.h"
35
36
/**************************************************************************
37
Allocate a block.  The thread calling this function must hold
38
buf_pool_mutex and must not hold buf_pool_zip_mutex or any
39
block->mutex.  The buf_pool_mutex may only be released and reacquired
40
if lru != NULL.  This function should only be used for allocating
41
compressed page frames or control blocks (buf_page_t).  Allocated
42
control blocks must be properly initialized immediately after
43
buf_buddy_alloc() has returned the memory, before releasing
44
buf_pool_mutex. */
45
UNIV_INLINE
46
void*
47
buf_buddy_alloc(
48
/*============*/
49
			/* out: allocated block,
50
			possibly NULL if lru == NULL */
51
	ulint	size,	/* in: block size, up to UNIV_PAGE_SIZE */
52
	ibool*	lru)	/* in: pointer to a variable that will be assigned
53
			TRUE if storage was allocated from the LRU list
54
			and buf_pool_mutex was temporarily released,
55
			or NULL if the LRU list should not be used */
56
	__attribute__((malloc));
57
58
/**************************************************************************
59
Release a block. */
60
UNIV_INLINE
61
void
62
buf_buddy_free(
63
/*===========*/
64
	void*	buf,	/* in: block to be freed, must not be
65
			pointed to by the buffer pool */
66
	ulint	size)	/* in: block size, up to UNIV_PAGE_SIZE */
67
	__attribute__((nonnull));
68
69
/** Statistics of buddy blocks of a given size. */
70
struct buf_buddy_stat_struct {
71
	/** Number of blocks allocated from the buddy system. */
72
	ulint		used;
73
	/** Number of blocks relocated by the buddy system. */
74
	ib_uint64_t	relocated;
75
	/** Total duration of block relocations, in microseconds. */
76
	ib_uint64_t	relocated_usec;
77
};
78
79
typedef struct buf_buddy_stat_struct buf_buddy_stat_t;
80
81
/** Statistics of the buddy system, indexed by block size.
82
Protected by buf_pool_mutex. */
83
extern buf_buddy_stat_t buf_buddy_stat[BUF_BUDDY_SIZES + 1];
84
85
#ifndef UNIV_NONINL
86
# include "buf0buddy.ic"
87
#endif
88
89
#endif /* buf0buddy_h */