mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 05:52:27 +01:00
branches/zip: Remove support for AWE (Intel PAE on Win32).
Removal of the variable innobase_buffer_pool_awe_mem_mb requires coordination with MySQL AB.
This commit is contained in:
parent
6c2bc49a36
commit
69fc883be2
15 changed files with 39 additions and 1081 deletions
|
@ -369,7 +369,6 @@ btr_cur_search_to_nth_level(
|
|||
#ifdef PAGE_CUR_LE_OR_EXTENDS
|
||||
&& mode != PAGE_CUR_LE_OR_EXTENDS
|
||||
#endif /* PAGE_CUR_LE_OR_EXTENDS */
|
||||
&& srv_use_adaptive_hash_indexes
|
||||
&& btr_search_guess_on_hash(index, info, tuple, mode,
|
||||
latch_mode, cursor,
|
||||
has_search_latch, mtr)) {
|
||||
|
@ -604,10 +603,7 @@ retry_page_get:
|
|||
cursor->up_bytes = up_bytes;
|
||||
|
||||
#ifdef BTR_CUR_ADAPT
|
||||
if (srv_use_adaptive_hash_indexes) {
|
||||
|
||||
btr_search_info_update(index, cursor);
|
||||
}
|
||||
btr_search_info_update(index, cursor);
|
||||
#endif
|
||||
ut_ad(cursor->up_match != ULINT_UNDEFINED
|
||||
|| mode != PAGE_CUR_GE);
|
||||
|
|
|
@ -197,7 +197,6 @@ btr_pcur_restore_position(
|
|||
mtr_t* mtr) /* in: mtr */
|
||||
{
|
||||
dict_index_t* index;
|
||||
page_t* page;
|
||||
dtuple_t* tuple;
|
||||
ulint mode;
|
||||
ulint old_mode;
|
||||
|
@ -235,15 +234,13 @@ btr_pcur_restore_position(
|
|||
ut_a(cursor->old_rec);
|
||||
ut_a(cursor->old_n_fields);
|
||||
|
||||
page = btr_cur_get_page(btr_pcur_get_btr_cur(cursor));
|
||||
|
||||
if (UNIV_LIKELY(latch_mode == BTR_SEARCH_LEAF)
|
||||
|| UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) {
|
||||
/* Try optimistic restoration */
|
||||
|
||||
if (UNIV_LIKELY(buf_page_optimistic_get(
|
||||
latch_mode,
|
||||
cursor->block_when_stored, page,
|
||||
cursor->block_when_stored,
|
||||
cursor->modify_clock, mtr))) {
|
||||
cursor->pos_state = BTR_PCUR_IS_POSITIONED;
|
||||
#ifdef UNIV_SYNC_DEBUG
|
||||
|
|
258
buf/buf0buf.c
258
buf/buf0buf.c
|
@ -199,27 +199,6 @@ of its random access area (for instance, 32 consecutive pages
|
|||
in a tablespace) have recently been referenced, we may predict
|
||||
that the whole area may be needed in the near future, and issue
|
||||
the read requests for the whole area.
|
||||
|
||||
AWE implementation
|
||||
------------------
|
||||
|
||||
By a 'block' we mean the buffer header of type buf_block_t. By a 'page'
|
||||
we mean the physical 16 kB memory area allocated from RAM for that block.
|
||||
By a 'frame' we mean a 16 kB area in the virtual address space of the
|
||||
process, in the frame_mem of buf_pool.
|
||||
|
||||
We can map pages to the frames of the buffer pool.
|
||||
|
||||
1) A buffer block allocated to use as a non-data page, e.g., to the lock
|
||||
table, is always mapped to a frame.
|
||||
2) A bufferfixed or io-fixed data page is always mapped to a frame.
|
||||
3) When we need to map a block to frame, we look from the list
|
||||
awe_LRU_free_mapped and try to unmap its last block, but note that
|
||||
bufferfixed or io-fixed pages cannot be unmapped.
|
||||
4) For every frame in the buffer pool there is always a block whose page is
|
||||
mapped to it. When we create the buffer pool, we map the first elements
|
||||
in the free list to the frames.
|
||||
5) When we have AWE enabled, we disable adaptive hash indexes.
|
||||
*/
|
||||
|
||||
buf_pool_t* buf_pool = NULL; /* The buffer buf_pool of the database */
|
||||
|
@ -608,8 +587,7 @@ void
|
|||
buf_block_init(
|
||||
/*===========*/
|
||||
buf_block_t* block, /* in: pointer to control block */
|
||||
byte* frame) /* in: pointer to buffer frame, or NULL if in
|
||||
the case of AWE there is no frame */
|
||||
byte* frame) /* in: pointer to buffer frame */
|
||||
{
|
||||
block->magic_n = 0;
|
||||
|
||||
|
@ -617,8 +595,6 @@ buf_block_init(
|
|||
|
||||
block->frame = frame;
|
||||
|
||||
block->awe_info = NULL;
|
||||
|
||||
block->buf_fix_count = 0;
|
||||
block->io_fix = 0;
|
||||
|
||||
|
@ -655,33 +631,16 @@ buf_pool_init(
|
|||
enough memory or error */
|
||||
ulint max_size, /* in: maximum size of the buf_pool in
|
||||
blocks */
|
||||
ulint curr_size, /* in: current size to use, must be <=
|
||||
ulint curr_size) /* in: current size to use, must be <=
|
||||
max_size, currently must be equal to
|
||||
max_size */
|
||||
ulint n_frames) /* in: number of frames; if AWE is used,
|
||||
this is the size of the address space window
|
||||
where physical memory pages are mapped; if
|
||||
AWE is not used then this must be the same
|
||||
as max_size */
|
||||
{
|
||||
byte* frame;
|
||||
ulint i;
|
||||
buf_block_t* block;
|
||||
ulint n_frames = max_size;
|
||||
|
||||
ut_a(max_size == curr_size);
|
||||
ut_a(srv_use_awe || n_frames == max_size);
|
||||
|
||||
if (n_frames > curr_size) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Error: you must specify in my.cnf"
|
||||
" .._awe_mem_mb larger\n"
|
||||
"InnoDB: than .._buffer_pool_size. Now the former"
|
||||
" is %lu pages,\n"
|
||||
"InnoDB: the latter %lu pages.\n",
|
||||
(ulong) curr_size, (ulong) n_frames);
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
buf_pool = mem_alloc(sizeof(buf_pool_t));
|
||||
|
||||
|
@ -691,41 +650,8 @@ buf_pool_init(
|
|||
|
||||
mutex_enter(&(buf_pool->mutex));
|
||||
|
||||
if (srv_use_awe) {
|
||||
/*----------------------------------------*/
|
||||
/* Allocate the virtual address space window, i.e., the
|
||||
buffer pool frames */
|
||||
|
||||
buf_pool->frame_mem = os_awe_allocate_virtual_mem_window(
|
||||
UNIV_PAGE_SIZE * (n_frames + 1));
|
||||
|
||||
/* Allocate the physical memory for AWE and the AWE info array
|
||||
for buf_pool */
|
||||
|
||||
if ((curr_size % ((1024 * 1024) / UNIV_PAGE_SIZE)) != 0) {
|
||||
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Error: physical memory must be"
|
||||
" allocated in full megabytes.\n"
|
||||
"InnoDB: Trying to allocate %lu"
|
||||
" database pages.\n",
|
||||
(ulong) curr_size);
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (!os_awe_allocate_physical_mem(&(buf_pool->awe_info),
|
||||
curr_size
|
||||
/ ((1024 * 1024)
|
||||
/ UNIV_PAGE_SIZE))) {
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
/*----------------------------------------*/
|
||||
} else {
|
||||
buf_pool->frame_mem = os_mem_alloc_large(
|
||||
UNIV_PAGE_SIZE * (n_frames + 1), TRUE, FALSE);
|
||||
}
|
||||
buf_pool->frame_mem = os_mem_alloc_large(
|
||||
UNIV_PAGE_SIZE * (n_frames + 1), TRUE, FALSE);
|
||||
|
||||
if (buf_pool->frame_mem == NULL) {
|
||||
|
||||
|
@ -751,19 +677,6 @@ buf_pool_init(
|
|||
buf_pool->frame_zero = frame;
|
||||
buf_pool->high_end = frame + UNIV_PAGE_SIZE * n_frames;
|
||||
|
||||
if (srv_use_awe) {
|
||||
/*----------------------------------------*/
|
||||
/* Map an initial part of the allocated physical memory to
|
||||
the window */
|
||||
|
||||
os_awe_map_physical_mem_to_window(buf_pool->frame_zero,
|
||||
n_frames
|
||||
* (UNIV_PAGE_SIZE
|
||||
/ OS_AWE_X86_PAGE_SIZE),
|
||||
buf_pool->awe_info);
|
||||
/*----------------------------------------*/
|
||||
}
|
||||
|
||||
buf_pool->blocks_of_frames = ut_malloc(sizeof(void*) * n_frames);
|
||||
|
||||
if (buf_pool->blocks_of_frames == NULL) {
|
||||
|
@ -771,30 +684,18 @@ buf_pool_init(
|
|||
return(NULL);
|
||||
}
|
||||
|
||||
/* Init block structs and assign frames for them; in the case of
|
||||
AWE there are less frames than blocks. Then we assign the frames
|
||||
to the first blocks (we already mapped the memory above). We also
|
||||
init the awe_info for every block. */
|
||||
/* Init block structs and assign frames for them. Then we
|
||||
assign the frames to the first blocks (we already mapped the
|
||||
memory above). */
|
||||
|
||||
for (i = 0; i < max_size; i++) {
|
||||
|
||||
block = buf_pool_get_nth_block(buf_pool, i);
|
||||
|
||||
if (i < n_frames) {
|
||||
frame = buf_pool->frame_zero + i * UNIV_PAGE_SIZE;
|
||||
*(buf_pool->blocks_of_frames + i) = block;
|
||||
} else {
|
||||
frame = NULL;
|
||||
}
|
||||
frame = buf_pool->frame_zero + i * UNIV_PAGE_SIZE;
|
||||
*(buf_pool->blocks_of_frames + i) = block;
|
||||
|
||||
buf_block_init(block, frame);
|
||||
|
||||
if (srv_use_awe) {
|
||||
/*----------------------------------------*/
|
||||
block->awe_info = buf_pool->awe_info
|
||||
+ i * (UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE);
|
||||
/*----------------------------------------*/
|
||||
}
|
||||
}
|
||||
|
||||
buf_pool->page_hash = hash_create(2 * max_size);
|
||||
|
@ -806,14 +707,12 @@ buf_pool_init(
|
|||
buf_pool->n_pages_read = 0;
|
||||
buf_pool->n_pages_written = 0;
|
||||
buf_pool->n_pages_created = 0;
|
||||
buf_pool->n_pages_awe_remapped = 0;
|
||||
|
||||
buf_pool->n_page_gets = 0;
|
||||
buf_pool->n_page_gets_old = 0;
|
||||
buf_pool->n_pages_read_old = 0;
|
||||
buf_pool->n_pages_written_old = 0;
|
||||
buf_pool->n_pages_created_old = 0;
|
||||
buf_pool->n_pages_awe_remapped_old = 0;
|
||||
|
||||
/* 2. Initialize flushing fields
|
||||
-------------------------------- */
|
||||
|
@ -836,8 +735,6 @@ buf_pool_init(
|
|||
|
||||
buf_pool->LRU_old = NULL;
|
||||
|
||||
UT_LIST_INIT(buf_pool->awe_LRU_free_mapped);
|
||||
|
||||
/* Add control blocks to the free list */
|
||||
UT_LIST_INIT(buf_pool->free);
|
||||
|
||||
|
@ -852,14 +749,6 @@ buf_pool_init(
|
|||
#ifdef HAVE_purify
|
||||
memset(block->frame, '\0', UNIV_PAGE_SIZE);
|
||||
#endif
|
||||
if (srv_use_awe) {
|
||||
/* Add to the list of blocks mapped to
|
||||
frames */
|
||||
|
||||
UT_LIST_ADD_LAST(awe_LRU_free_mapped,
|
||||
buf_pool->awe_LRU_free_mapped,
|
||||
block);
|
||||
}
|
||||
}
|
||||
|
||||
UT_LIST_ADD_LAST(free, buf_pool->free, block);
|
||||
|
@ -868,96 +757,11 @@ buf_pool_init(
|
|||
|
||||
mutex_exit(&(buf_pool->mutex));
|
||||
|
||||
if (srv_use_adaptive_hash_indexes) {
|
||||
btr_search_sys_create(curr_size * UNIV_PAGE_SIZE
|
||||
/ sizeof(void*) / 64);
|
||||
} else {
|
||||
/* Create only a small dummy system */
|
||||
btr_search_sys_create(1000);
|
||||
}
|
||||
btr_search_sys_create(curr_size * UNIV_PAGE_SIZE / sizeof(void*) / 64);
|
||||
|
||||
return(buf_pool);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Maps the page of block to a frame, if not mapped yet. Unmaps some page
|
||||
from the end of the awe_LRU_free_mapped. */
|
||||
|
||||
void
|
||||
buf_awe_map_page_to_frame(
|
||||
/*======================*/
|
||||
buf_block_t* block, /* in: block whose page should be
|
||||
mapped to a frame */
|
||||
ibool add_to_mapped_list) /* in: TRUE if we in the case
|
||||
we need to map the page should also
|
||||
add the block to the
|
||||
awe_LRU_free_mapped list */
|
||||
{
|
||||
buf_block_t* bck;
|
||||
|
||||
#ifdef UNIV_SYNC_DEBUG
|
||||
ut_ad(mutex_own(&(buf_pool->mutex)));
|
||||
#endif /* UNIV_SYNC_DEBUG */
|
||||
ut_ad(block);
|
||||
|
||||
if (block->frame) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Scan awe_LRU_free_mapped from the end and try to find a block
|
||||
which is not bufferfixed or io-fixed */
|
||||
|
||||
bck = UT_LIST_GET_LAST(buf_pool->awe_LRU_free_mapped);
|
||||
|
||||
while (bck) {
|
||||
if (bck->state == BUF_BLOCK_FILE_PAGE
|
||||
&& (bck->buf_fix_count != 0 || bck->io_fix != 0)) {
|
||||
|
||||
/* We have to skip this */
|
||||
bck = UT_LIST_GET_PREV(awe_LRU_free_mapped, bck);
|
||||
} else {
|
||||
/* We can map block to the frame of bck */
|
||||
|
||||
os_awe_map_physical_mem_to_window(
|
||||
bck->frame,
|
||||
UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE,
|
||||
block->awe_info);
|
||||
|
||||
block->frame = bck->frame;
|
||||
|
||||
*(buf_pool->blocks_of_frames
|
||||
+ (((ulint)(block->frame
|
||||
- buf_pool->frame_zero))
|
||||
>> UNIV_PAGE_SIZE_SHIFT))
|
||||
= block;
|
||||
|
||||
bck->frame = NULL;
|
||||
UT_LIST_REMOVE(awe_LRU_free_mapped,
|
||||
buf_pool->awe_LRU_free_mapped,
|
||||
bck);
|
||||
|
||||
if (add_to_mapped_list) {
|
||||
UT_LIST_ADD_FIRST(
|
||||
awe_LRU_free_mapped,
|
||||
buf_pool->awe_LRU_free_mapped,
|
||||
block);
|
||||
}
|
||||
|
||||
buf_pool->n_pages_awe_remapped++;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Fatal error: cannot find a page to unmap\n"
|
||||
"InnoDB: awe_LRU_free_mapped list length %lu\n",
|
||||
(ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
|
||||
|
||||
ut_a(0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Moves to the block to the start of the LRU list if there is a danger
|
||||
that the block would drift out of the buffer pool. */
|
||||
|
@ -1247,19 +1051,6 @@ loop:
|
|||
}
|
||||
}
|
||||
|
||||
/* If AWE is enabled and the page is not mapped to a frame, then
|
||||
map it */
|
||||
|
||||
if (block->frame == NULL) {
|
||||
ut_a(srv_use_awe);
|
||||
|
||||
/* We set second parameter TRUE because the block is in the
|
||||
LRU list and we must put it to awe_LRU_free_mapped list once
|
||||
mapped to a frame */
|
||||
|
||||
buf_awe_map_page_to_frame(block, TRUE);
|
||||
}
|
||||
|
||||
#ifdef UNIV_SYNC_DEBUG
|
||||
buf_block_buf_fix_inc_debug(block, file, line);
|
||||
#else
|
||||
|
@ -1374,8 +1165,6 @@ buf_page_optimistic_get_func(
|
|||
/* out: TRUE if success */
|
||||
ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH */
|
||||
buf_block_t* block, /* in: guessed buffer block */
|
||||
buf_frame_t* guess, /* in: guessed frame; note that AWE may move
|
||||
frames */
|
||||
dulint modify_clock,/* in: modify clock value if mode is
|
||||
..._GUESS_ON_CLOCK */
|
||||
const char* file, /* in: file name */
|
||||
|
@ -1391,10 +1180,7 @@ buf_page_optimistic_get_func(
|
|||
|
||||
mutex_enter(&(buf_pool->mutex));
|
||||
|
||||
/* If AWE is used, block may have a different frame now, e.g., NULL */
|
||||
|
||||
if (UNIV_UNLIKELY(block->state != BUF_BLOCK_FILE_PAGE)
|
||||
|| UNIV_UNLIKELY(block->frame != guess)) {
|
||||
if (UNIV_UNLIKELY(block->state != BUF_BLOCK_FILE_PAGE)) {
|
||||
exit_func:
|
||||
mutex_exit(&(buf_pool->mutex));
|
||||
|
||||
|
@ -2441,17 +2227,6 @@ buf_print_io(
|
|||
|
||||
mutex_enter(&(buf_pool->mutex));
|
||||
|
||||
if (srv_use_awe) {
|
||||
fprintf(stderr,
|
||||
"AWE: Buffer pool memory frames %lu\n",
|
||||
(ulong) buf_pool->n_frames);
|
||||
|
||||
fprintf(stderr,
|
||||
"AWE: Database pages and free buffers"
|
||||
" mapped in frames %lu\n",
|
||||
(ulong)
|
||||
UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
|
||||
}
|
||||
fprintf(file,
|
||||
"Buffer pool size %lu\n"
|
||||
"Free buffers %lu\n"
|
||||
|
@ -2488,13 +2263,6 @@ buf_print_io(
|
|||
(buf_pool->n_pages_written - buf_pool->n_pages_written_old)
|
||||
/ time_elapsed);
|
||||
|
||||
if (srv_use_awe) {
|
||||
fprintf(file, "AWE: %.2f page remaps/s\n",
|
||||
(buf_pool->n_pages_awe_remapped
|
||||
- buf_pool->n_pages_awe_remapped_old)
|
||||
/ time_elapsed);
|
||||
}
|
||||
|
||||
if (buf_pool->n_page_gets > buf_pool->n_page_gets_old) {
|
||||
fprintf(file, "Buffer pool hit rate %lu / 1000\n",
|
||||
(ulong)
|
||||
|
@ -2511,7 +2279,6 @@ buf_print_io(
|
|||
buf_pool->n_pages_read_old = buf_pool->n_pages_read;
|
||||
buf_pool->n_pages_created_old = buf_pool->n_pages_created;
|
||||
buf_pool->n_pages_written_old = buf_pool->n_pages_written;
|
||||
buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped;
|
||||
|
||||
mutex_exit(&(buf_pool->mutex));
|
||||
}
|
||||
|
@ -2528,7 +2295,6 @@ buf_refresh_io_stats(void)
|
|||
buf_pool->n_pages_read_old = buf_pool->n_pages_read;
|
||||
buf_pool->n_pages_created_old = buf_pool->n_pages_created;
|
||||
buf_pool->n_pages_written_old = buf_pool->n_pages_written;
|
||||
buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
|
|
@ -640,19 +640,6 @@ buf_flush_try_page(
|
|||
|
||||
block->io_fix = BUF_IO_WRITE;
|
||||
|
||||
/* If AWE is enabled and the page is not mapped to a frame,
|
||||
then map it */
|
||||
|
||||
if (block->frame == NULL) {
|
||||
ut_a(srv_use_awe);
|
||||
|
||||
/* We set second parameter TRUE because the block is
|
||||
in the LRU list and we must put it to
|
||||
awe_LRU_free_mapped list once mapped to a frame */
|
||||
|
||||
buf_awe_map_page_to_frame(block, TRUE);
|
||||
}
|
||||
|
||||
block->flush_type = flush_type;
|
||||
|
||||
if (buf_pool->n_flush[flush_type] == 0) {
|
||||
|
@ -707,19 +694,6 @@ buf_flush_try_page(
|
|||
|
||||
block->io_fix = BUF_IO_WRITE;
|
||||
|
||||
/* If AWE is enabled and the page is not mapped to a frame,
|
||||
then map it */
|
||||
|
||||
if (block->frame == NULL) {
|
||||
ut_a(srv_use_awe);
|
||||
|
||||
/* We set second parameter TRUE because the block is
|
||||
in the LRU list and we must put it to
|
||||
awe_LRU_free_mapped list once mapped to a frame */
|
||||
|
||||
buf_awe_map_page_to_frame(block, TRUE);
|
||||
}
|
||||
|
||||
block->flush_type = flush_type;
|
||||
|
||||
if (buf_pool->n_flush[flush_type] == 0) {
|
||||
|
@ -746,19 +720,6 @@ buf_flush_try_page(
|
|||
|
||||
block->io_fix = BUF_IO_WRITE;
|
||||
|
||||
/* If AWE is enabled and the page is not mapped to a frame,
|
||||
then map it */
|
||||
|
||||
if (block->frame == NULL) {
|
||||
ut_a(srv_use_awe);
|
||||
|
||||
/* We set second parameter TRUE because the block is
|
||||
in the LRU list and we must put it to
|
||||
awe_LRU_free_mapped list once mapped to a frame */
|
||||
|
||||
buf_awe_map_page_to_frame(block, TRUE);
|
||||
}
|
||||
|
||||
block->flush_type = flush_type;
|
||||
|
||||
if (buf_pool->n_flush[block->flush_type] == 0) {
|
||||
|
|
|
@ -227,13 +227,10 @@ buf_LRU_search_and_free_block(
|
|||
|
||||
mutex_exit(&(buf_pool->mutex));
|
||||
|
||||
/* Remove possible adaptive hash index built on the
|
||||
page; in the case of AWE the block may not have a
|
||||
frame at all */
|
||||
/* Remove possible adaptive hash index on the page */
|
||||
|
||||
btr_search_drop_page_hash_index(block);
|
||||
|
||||
if (block->frame) {
|
||||
btr_search_drop_page_hash_index(block);
|
||||
}
|
||||
mutex_enter(&(buf_pool->mutex));
|
||||
|
||||
ut_a(block->buf_fix_count == 0);
|
||||
|
@ -328,9 +325,7 @@ LRU list to the free list. */
|
|||
buf_block_t*
|
||||
buf_LRU_get_free_block(
|
||||
/*===================*/
|
||||
/* out: the free control block; also if AWE is
|
||||
used, it is guaranteed that the block has its
|
||||
page mapped to a frame when we return */
|
||||
/* out: the free control block */
|
||||
ulint zip_size) /* in: compressed page size in bytes,
|
||||
or 0 if uncompressed tablespace */
|
||||
{
|
||||
|
@ -414,22 +409,6 @@ loop:
|
|||
ut_a(block->state != BUF_BLOCK_FILE_PAGE);
|
||||
ut_a(!block->in_LRU_list);
|
||||
|
||||
if (srv_use_awe) {
|
||||
if (block->frame) {
|
||||
/* Remove from the list of mapped pages */
|
||||
|
||||
UT_LIST_REMOVE(awe_LRU_free_mapped,
|
||||
buf_pool->awe_LRU_free_mapped,
|
||||
block);
|
||||
} else {
|
||||
/* We map the page to a frame; second param
|
||||
FALSE below because we do not want it to be
|
||||
added to the awe_LRU_free_mapped list */
|
||||
|
||||
buf_awe_map_page_to_frame(block, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (block->page_zip.size != zip_size) {
|
||||
block->page_zip.size = zip_size;
|
||||
block->page_zip.n_blobs = 0;
|
||||
|
@ -649,13 +628,6 @@ buf_LRU_remove_block(
|
|||
UT_LIST_REMOVE(LRU, buf_pool->LRU, block);
|
||||
block->in_LRU_list = FALSE;
|
||||
|
||||
if (srv_use_awe && block->frame) {
|
||||
/* Remove from the list of mapped pages */
|
||||
|
||||
UT_LIST_REMOVE(awe_LRU_free_mapped,
|
||||
buf_pool->awe_LRU_free_mapped, block);
|
||||
}
|
||||
|
||||
/* If the LRU list is so short that LRU_old not defined, return */
|
||||
if (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN) {
|
||||
|
||||
|
@ -708,13 +680,6 @@ buf_LRU_add_block_to_end_low(
|
|||
UT_LIST_ADD_LAST(LRU, buf_pool->LRU, block);
|
||||
block->in_LRU_list = TRUE;
|
||||
|
||||
if (srv_use_awe && block->frame) {
|
||||
/* Add to the list of mapped pages */
|
||||
|
||||
UT_LIST_ADD_LAST(awe_LRU_free_mapped,
|
||||
buf_pool->awe_LRU_free_mapped, block);
|
||||
}
|
||||
|
||||
if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
|
||||
|
||||
buf_pool->LRU_old_len++;
|
||||
|
@ -763,15 +728,6 @@ buf_LRU_add_block_low(
|
|||
block->old = old;
|
||||
cl = buf_pool_clock_tic();
|
||||
|
||||
if (srv_use_awe && block->frame) {
|
||||
/* Add to the list of mapped pages; for simplicity we always
|
||||
add to the start, even if the user would have set 'old'
|
||||
TRUE */
|
||||
|
||||
UT_LIST_ADD_FIRST(awe_LRU_free_mapped,
|
||||
buf_pool->awe_LRU_free_mapped, block);
|
||||
}
|
||||
|
||||
if (!old || (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN)) {
|
||||
|
||||
UT_LIST_ADD_FIRST(LRU, buf_pool->LRU, block);
|
||||
|
@ -877,15 +833,7 @@ buf_LRU_block_free_non_file_page(
|
|||
UT_LIST_ADD_FIRST(free, buf_pool->free, block);
|
||||
block->in_free_list = TRUE;
|
||||
|
||||
if (srv_use_awe && block->frame) {
|
||||
/* Add to the list of mapped pages */
|
||||
|
||||
UT_LIST_ADD_FIRST(awe_LRU_free_mapped,
|
||||
buf_pool->awe_LRU_free_mapped, block);
|
||||
UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE);
|
||||
} else {
|
||||
UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE);
|
||||
}
|
||||
UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -914,8 +862,6 @@ buf_LRU_block_remove_hashed_page(
|
|||
|
||||
buf_pool->freed_page_clock += 1;
|
||||
|
||||
/* Note that if AWE is enabled the block may not have a frame at all */
|
||||
|
||||
buf_block_modify_clock_inc(block);
|
||||
|
||||
hashed_block = buf_page_hash_get(block->space, block->offset);
|
||||
|
|
|
@ -1536,22 +1536,10 @@ innobase_init(void *p)
|
|||
/* We set srv_pool_size here in units of 1 kB. InnoDB internally
|
||||
changes the value so that it becomes the number of database pages. */
|
||||
|
||||
if (innobase_buffer_pool_awe_mem_mb == 0) {
|
||||
/* Careful here: we first convert the signed long int to ulint
|
||||
and only after that divide */
|
||||
/* Careful here: we first convert the signed long int to ulint
|
||||
and only after that divide */
|
||||
|
||||
srv_pool_size = ((ulint) innobase_buffer_pool_size) / 1024;
|
||||
} else {
|
||||
srv_use_awe = TRUE;
|
||||
srv_pool_size = (ulint)
|
||||
(1024 * innobase_buffer_pool_awe_mem_mb);
|
||||
srv_awe_window_size = (ulint) innobase_buffer_pool_size;
|
||||
|
||||
/* Note that what the user specified as
|
||||
innodb_buffer_pool_size is actually the AWE memory window
|
||||
size in this case, and the real buffer pool size is
|
||||
determined by .._awe_mem_mb. */
|
||||
}
|
||||
srv_pool_size = ((ulint) innobase_buffer_pool_size) / 1024;
|
||||
|
||||
srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
|
||||
|
||||
|
|
|
@ -476,8 +476,7 @@ struct btr_pcur_struct{
|
|||
cursor was on, before, or after the
|
||||
old_rec record */
|
||||
buf_block_t* block_when_stored;/* buffer block when the position was
|
||||
stored; note that if AWE is on, frames
|
||||
may move */
|
||||
stored */
|
||||
dulint modify_clock; /* the modify clock value of the
|
||||
buffer block when the cursor position
|
||||
was stored */
|
||||
|
|
|
@ -75,25 +75,18 @@ buf_pool_init(
|
|||
enough memory or error */
|
||||
ulint max_size, /* in: maximum size of the buf_pool in
|
||||
blocks */
|
||||
ulint curr_size, /* in: current size to use, must be <=
|
||||
ulint curr_size); /* in: current size to use, must be <=
|
||||
max_size, currently must be equal to
|
||||
max_size */
|
||||
ulint n_frames); /* in: number of frames; if AWE is used,
|
||||
this is the size of the address space window
|
||||
where physical memory pages are mapped; if
|
||||
AWE is not used then this must be the same
|
||||
as max_size */
|
||||
/*************************************************************************
|
||||
Gets the current size of buffer buf_pool in bytes. In the case of AWE, the
|
||||
size of AWE window (= the frames). */
|
||||
Gets the current size of buffer buf_pool in bytes. */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
buf_pool_get_curr_size(void);
|
||||
/*========================*/
|
||||
/* out: size in bytes */
|
||||
/*************************************************************************
|
||||
Gets the maximum size of buffer pool in bytes. In the case of AWE, the
|
||||
size of AWE window (= the frames). */
|
||||
Gets the maximum size of buffer pool in bytes. */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
buf_pool_get_max_size(void);
|
||||
|
@ -114,9 +107,7 @@ UNIV_INLINE
|
|||
buf_block_t*
|
||||
buf_block_alloc(
|
||||
/*============*/
|
||||
/* out, own: the allocated block; also if AWE
|
||||
is used it is guaranteed that the page is
|
||||
mapped to a frame */
|
||||
/* out, own: the allocated block */
|
||||
ulint zip_size); /* in: compressed page size in bytes,
|
||||
or 0 if uncompressed tablespace */
|
||||
/************************************************************************
|
||||
|
@ -161,8 +152,8 @@ improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed as LA! */
|
|||
NOTE! The following macros should be used instead of
|
||||
buf_page_optimistic_get_func, to improve debugging. Only values RW_S_LATCH and
|
||||
RW_X_LATCH are allowed as LA! */
|
||||
#define buf_page_optimistic_get(LA, BL, G, MC, MTR) \
|
||||
buf_page_optimistic_get_func(LA, BL, G, MC, __FILE__, __LINE__, MTR)
|
||||
#define buf_page_optimistic_get(LA, BL, MC, MTR) \
|
||||
buf_page_optimistic_get_func(LA, BL, MC, __FILE__, __LINE__, MTR)
|
||||
/************************************************************************
|
||||
This is the general function used to get optimistic access to a database
|
||||
page. */
|
||||
|
@ -173,8 +164,6 @@ buf_page_optimistic_get_func(
|
|||
/* out: TRUE if success */
|
||||
ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH */
|
||||
buf_block_t* block, /* in: guessed block */
|
||||
buf_frame_t* guess, /* in: guessed frame; note that AWE may move
|
||||
frames */
|
||||
dulint modify_clock,/* in: modify clock value if mode is
|
||||
..._GUESS_ON_CLOCK */
|
||||
const char* file, /* in: file name */
|
||||
|
@ -531,19 +520,6 @@ buf_pool_invalidate(void);
|
|||
--------------------------- LOWER LEVEL ROUTINES -------------------------
|
||||
=========================================================================*/
|
||||
|
||||
/************************************************************************
|
||||
Maps the page of block to a frame, if not mapped yet. Unmaps some page
|
||||
from the end of the awe_LRU_free_mapped. */
|
||||
|
||||
void
|
||||
buf_awe_map_page_to_frame(
|
||||
/*======================*/
|
||||
buf_block_t* block, /* in: block whose page should be
|
||||
mapped to a frame */
|
||||
ibool add_to_mapped_list);/* in: TRUE if we in the case
|
||||
we need to map the page should also
|
||||
add the block to the
|
||||
awe_LRU_free_mapped list */
|
||||
#ifdef UNIV_SYNC_DEBUG
|
||||
/*************************************************************************
|
||||
Adds latch level info for the rw-lock protecting the buffer frame. This
|
||||
|
@ -720,16 +696,7 @@ struct buf_block_struct{
|
|||
byte* frame; /* pointer to buffer frame which
|
||||
is of size UNIV_PAGE_SIZE, and
|
||||
aligned to an address divisible by
|
||||
UNIV_PAGE_SIZE; if AWE is used, this
|
||||
will be NULL for the pages which are
|
||||
currently not mapped into the virtual
|
||||
address space window of the buffer
|
||||
pool */
|
||||
os_awe_t* awe_info; /* if AWE is used, then an array of
|
||||
awe page infos for
|
||||
UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE
|
||||
(normally = 4) physical memory
|
||||
pages; otherwise NULL */
|
||||
UNIV_PAGE_SIZE */
|
||||
ulint space; /* space id of the page */
|
||||
ulint offset; /* page number within the space */
|
||||
ulint lock_hash_val; /* hashed value of the page address
|
||||
|
@ -776,10 +743,6 @@ struct buf_block_struct{
|
|||
debugging */
|
||||
UT_LIST_NODE_T(buf_block_t) LRU;
|
||||
/* node of the LRU list */
|
||||
UT_LIST_NODE_T(buf_block_t) awe_LRU_free_mapped;
|
||||
/* in the AWE version node in the
|
||||
list of free and LRU blocks which are
|
||||
mapped to a frame */
|
||||
ibool in_LRU_list; /* TRUE of the page is in the LRU list;
|
||||
used in debugging */
|
||||
ulint LRU_position; /* value which monotonically
|
||||
|
@ -886,10 +849,7 @@ struct buf_pool_struct{
|
|||
struct and control blocks, except the
|
||||
read-write lock in them */
|
||||
byte* frame_mem; /* pointer to the memory area which
|
||||
was allocated for the frames; in AWE
|
||||
this is the virtual address space
|
||||
window where we map pages stored
|
||||
in physical memory */
|
||||
was allocated for the frames */
|
||||
byte* frame_zero; /* pointer to the first buffer frame:
|
||||
this may differ from frame_mem, because
|
||||
this is aligned by the frame size */
|
||||
|
@ -905,12 +865,7 @@ struct buf_pool_struct{
|
|||
frame_zero + UNIV_PAGE_SIZE, ...
|
||||
a control block is always assigned
|
||||
for each frame, even if the frame does
|
||||
not contain any data; note that in AWE
|
||||
there are more control blocks than
|
||||
buffer frames */
|
||||
os_awe_t* awe_info; /* if AWE is used, AWE info for the
|
||||
physical 4 kB memory pages associated
|
||||
with buffer frames */
|
||||
not contain any data */
|
||||
ulint max_size; /* number of control blocks ==
|
||||
maximum pool size in pages */
|
||||
ulint curr_size; /* current pool size in pages;
|
||||
|
@ -932,9 +887,6 @@ struct buf_pool_struct{
|
|||
counted as page gets; this field
|
||||
is NOT protected by the buffer
|
||||
pool mutex */
|
||||
ulint n_pages_awe_remapped; /* if AWE is enabled, the
|
||||
number of remaps of blocks to
|
||||
buffer frames */
|
||||
ulint n_page_gets_old;/* n_page_gets when buf_print was
|
||||
last time called: used to calculate
|
||||
hit rate */
|
||||
|
@ -943,7 +895,6 @@ struct buf_pool_struct{
|
|||
ulint n_pages_written_old;/* number write operations */
|
||||
ulint n_pages_created_old;/* number of pages created in
|
||||
the pool with no read */
|
||||
ulint n_pages_awe_remapped_old;
|
||||
/* 2. Page flushing algorithm fields */
|
||||
|
||||
UT_LIST_BASE_NODE_T(buf_block_t) flush_list;
|
||||
|
@ -976,10 +927,7 @@ struct buf_pool_struct{
|
|||
/* 3. LRU replacement algorithm fields */
|
||||
|
||||
UT_LIST_BASE_NODE_T(buf_block_t) free;
|
||||
/* base node of the free block list;
|
||||
in the case of AWE, at the start are
|
||||
always free blocks for which the
|
||||
physical memory is mapped to a frame */
|
||||
/* base node of the free block list */
|
||||
UT_LIST_BASE_NODE_T(buf_block_t) LRU;
|
||||
/* base node of the LRU list */
|
||||
buf_block_t* LRU_old; /* pointer to the about 3/8 oldest
|
||||
|
@ -991,12 +939,6 @@ struct buf_pool_struct{
|
|||
see buf0lru.c for the restrictions
|
||||
on this value; not defined if
|
||||
LRU_old == NULL */
|
||||
UT_LIST_BASE_NODE_T(buf_block_t) awe_LRU_free_mapped;
|
||||
/* list of those blocks which are
|
||||
in the LRU list or the free list, and
|
||||
where the page is mapped to a frame;
|
||||
thus, frames allocated, e.g., to the
|
||||
locki table, are not in this list */
|
||||
};
|
||||
|
||||
/* States of a control block */
|
||||
|
|
|
@ -32,8 +32,7 @@ buf_block_peek_if_too_old(
|
|||
}
|
||||
|
||||
/*************************************************************************
|
||||
Gets the current size of buffer buf_pool in bytes. In the case of AWE, the
|
||||
size of AWE window (= the frames). */
|
||||
Gets the current size of buffer buf_pool in bytes. */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
buf_pool_get_curr_size(void)
|
||||
|
@ -44,8 +43,7 @@ buf_pool_get_curr_size(void)
|
|||
}
|
||||
|
||||
/*************************************************************************
|
||||
Gets the maximum size of buffer buf_pool in bytes. In the case of AWE, the
|
||||
size of AWE window (= the frames). */
|
||||
Gets the maximum size of buffer buf_pool in bytes. */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
buf_pool_get_max_size(void)
|
||||
|
@ -314,9 +312,7 @@ UNIV_INLINE
|
|||
buf_block_t*
|
||||
buf_block_alloc(
|
||||
/*============*/
|
||||
/* out, own: the allocated block; also if AWE
|
||||
is used it is guaranteed that the page is
|
||||
mapped to a frame */
|
||||
/* out, own: the allocated block */
|
||||
ulint zip_size) /* in: compressed page size in bytes,
|
||||
or 0 if uncompressed tablespace */
|
||||
{
|
||||
|
|
|
@ -87,9 +87,7 @@ LRU list to the free list. */
|
|||
buf_block_t*
|
||||
buf_LRU_get_free_block(
|
||||
/*===================*/
|
||||
/* out: the free control block; also if AWE is
|
||||
used, it is guaranteed that the block has its
|
||||
page mapped to a frame when we return */
|
||||
/* out: the free control block */
|
||||
ulint zip_size); /* in: compressed page size in bytes,
|
||||
or 0 if uncompressed tablespace */
|
||||
|
||||
|
|
|
@ -20,80 +20,10 @@ Created 9/30/1995 Heikki Tuuri
|
|||
typedef void* os_process_t;
|
||||
typedef unsigned long int os_process_id_t;
|
||||
|
||||
/* The cell type in os_awe_allocate_mem page info */
|
||||
#if defined(__WIN2000__) && defined(ULONG_PTR)
|
||||
typedef ULONG_PTR os_awe_t;
|
||||
#else
|
||||
typedef ulint os_awe_t;
|
||||
#endif
|
||||
|
||||
/* Physical page size when Windows AWE is used. This is the normal
|
||||
page size of an Intel x86 processor. We cannot use AWE with 2 MB or 4 MB
|
||||
pages. */
|
||||
#define OS_AWE_X86_PAGE_SIZE 4096
|
||||
|
||||
extern ibool os_use_large_pages;
|
||||
/* Large page size. This may be a boot-time option on some platforms */
|
||||
extern ulint os_large_page_size;
|
||||
|
||||
/********************************************************************
|
||||
Windows AWE support. Tries to enable the "lock pages in memory" privilege for
|
||||
the current process so that the current process can allocate memory-locked
|
||||
virtual address space to act as the window where AWE maps physical memory. */
|
||||
|
||||
ibool
|
||||
os_awe_enable_lock_pages_in_mem(void);
|
||||
/*=================================*/
|
||||
/* out: TRUE if success, FALSE if error;
|
||||
prints error info to stderr if no success */
|
||||
/********************************************************************
|
||||
Allocates physical RAM memory up to 64 GB in an Intel 32-bit x86
|
||||
processor. */
|
||||
|
||||
ibool
|
||||
os_awe_allocate_physical_mem(
|
||||
/*=========================*/
|
||||
/* out: TRUE if success */
|
||||
os_awe_t** page_info, /* out, own: array of opaque data containing
|
||||
the info for allocated physical memory pages;
|
||||
each allocated 4 kB physical memory page has
|
||||
one slot of type os_awe_t in the array */
|
||||
ulint n_megabytes); /* in: number of megabytes to allocate */
|
||||
/********************************************************************
|
||||
Allocates a window in the virtual address space where we can map then
|
||||
pages of physical memory. */
|
||||
|
||||
byte*
|
||||
os_awe_allocate_virtual_mem_window(
|
||||
/*===============================*/
|
||||
/* out, own: allocated memory, or NULL if did not
|
||||
succeed */
|
||||
ulint size); /* in: virtual memory allocation size in bytes, must
|
||||
be < 2 GB */
|
||||
/********************************************************************
|
||||
With this function you can map parts of physical memory allocated with
|
||||
the ..._allocate_physical_mem to the virtual address space allocated with
|
||||
the previous function. Intel implements this so that the process page
|
||||
tables are updated accordingly. A test on a 1.5 GHz AMD processor and XP
|
||||
showed that this takes < 1 microsecond, much better than the estimated 80 us
|
||||
for copying a 16 kB page memory to memory. But, the operation will at least
|
||||
partially invalidate the translation lookaside buffer (TLB) of all
|
||||
processors. Under a real-world load the performance hit may be bigger. */
|
||||
|
||||
ibool
|
||||
os_awe_map_physical_mem_to_window(
|
||||
/*==============================*/
|
||||
/* out: TRUE if success; the function
|
||||
calls exit(1) in case of an error */
|
||||
byte* ptr, /* in: a page-aligned pointer to
|
||||
somewhere in the virtual address
|
||||
space window; we map the physical mem
|
||||
pages here */
|
||||
ulint n_mem_pages, /* in: number of 4 kB mem pages to
|
||||
map */
|
||||
os_awe_t* page_info); /* in: array of page infos for those
|
||||
pages; each page has one slot in the
|
||||
array */
|
||||
/********************************************************************
|
||||
Converts the current process id to a number. It is not guaranteed that the
|
||||
number is unique. In Linux returns the 'process number' of the current
|
||||
|
|
|
@ -85,7 +85,6 @@ extern ulong srv_flush_log_at_trx_commit;
|
|||
extern byte srv_latin1_ordering[256];/* The sort order table of the latin1
|
||||
character set */
|
||||
extern ulint srv_pool_size;
|
||||
extern ulint srv_awe_window_size;
|
||||
extern ulint srv_mem_pool_size;
|
||||
extern ulint srv_lock_table_size;
|
||||
|
||||
|
@ -132,8 +131,6 @@ extern int srv_query_thread_priority;
|
|||
|
||||
extern ulong srv_max_buf_pool_modified_pct;
|
||||
extern ulong srv_max_purge_lag;
|
||||
extern ibool srv_use_awe;
|
||||
extern ibool srv_use_adaptive_hash_indexes;
|
||||
/*-------------------------------------------*/
|
||||
|
||||
extern ulint srv_n_rows_inserted;
|
||||
|
|
495
os/os0proc.c
495
os/os0proc.c
|
@ -15,505 +15,10 @@ Created 9/30/1995 Heikki Tuuri
|
|||
#include "ut0mem.h"
|
||||
#include "ut0byte.h"
|
||||
|
||||
|
||||
/*
|
||||
How to get AWE to compile on Windows?
|
||||
-------------------------------------
|
||||
|
||||
In the project settings of the innobase project the Visual C++ source,
|
||||
__WIN2000__ has to be defined.
|
||||
|
||||
The Visual C++ has to be relatively recent and _WIN32_WINNT has to be
|
||||
defined to a value >= 0x0500 when windows.h is included.
|
||||
|
||||
#define _WIN32_WINNT 0x0500
|
||||
|
||||
Where does AWE work?
|
||||
-------------------
|
||||
|
||||
See the error message in os_awe_allocate_physical_mem().
|
||||
|
||||
How to assign privileges for mysqld to use AWE?
|
||||
-----------------------------------------------
|
||||
|
||||
See the error message in os_awe_enable_lock_pages_in_mem().
|
||||
|
||||
Use Windows AWE functions in this order
|
||||
---------------------------------------
|
||||
|
||||
(1) os_awe_enable_lock_pages_in_mem();
|
||||
(2) os_awe_allocate_physical_mem();
|
||||
(3) os_awe_allocate_virtual_mem_window();
|
||||
(4) os_awe_map_physical_mem_to_window().
|
||||
|
||||
To test 'AWE' in a computer which does not have the AWE API,
|
||||
you can compile with UNIV_SIMULATE_AWE defined in this file.
|
||||
*/
|
||||
|
||||
#ifdef UNIV_SIMULATE_AWE
|
||||
/* If we simulate AWE, we allocate the 'physical memory' here */
|
||||
byte* os_awe_simulate_mem;
|
||||
ulint os_awe_simulate_mem_size;
|
||||
os_awe_t* os_awe_simulate_page_info;
|
||||
byte* os_awe_simulate_window;
|
||||
ulint os_awe_simulate_window_size;
|
||||
/* In simulated AWE the following contains a NULL pointer or a pointer
|
||||
to a mapped 'physical page' for each 4 kB page in the AWE window */
|
||||
byte** os_awe_simulate_map;
|
||||
#endif
|
||||
|
||||
#ifdef __WIN2000__
|
||||
os_awe_t* os_awe_page_info;
|
||||
ulint os_awe_n_pages;
|
||||
byte* os_awe_window;
|
||||
ulint os_awe_window_size;
|
||||
#endif
|
||||
|
||||
ibool os_use_large_pages;
|
||||
/* Large page size. This may be a boot-time option on some platforms */
|
||||
ulint os_large_page_size;
|
||||
|
||||
/********************************************************************
|
||||
Windows AWE support. Tries to enable the "lock pages in memory" privilege for
|
||||
the current process so that the current process can allocate memory-locked
|
||||
virtual address space to act as the window where AWE maps physical memory. */
|
||||
|
||||
ibool
|
||||
os_awe_enable_lock_pages_in_mem(void)
|
||||
/*=================================*/
|
||||
/* out: TRUE if success, FALSE if error;
|
||||
prints error info to stderr if no success */
|
||||
{
|
||||
#ifdef UNIV_SIMULATE_AWE
|
||||
|
||||
return(TRUE);
|
||||
|
||||
#elif defined(__WIN2000__)
|
||||
struct {
|
||||
DWORD Count;
|
||||
LUID_AND_ATTRIBUTES Privilege[1];
|
||||
} Info;
|
||||
HANDLE hProcess;
|
||||
HANDLE Token;
|
||||
BOOL Result;
|
||||
|
||||
hProcess = GetCurrentProcess();
|
||||
|
||||
/* Open the token of the current process */
|
||||
|
||||
Result = OpenProcessToken(hProcess,
|
||||
TOKEN_ADJUST_PRIVILEGES, &Token);
|
||||
if (Result != TRUE) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Cannot open process token, error %lu\n",
|
||||
(ulint)GetLastError());
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
Info.Count = 1;
|
||||
|
||||
Info.Privilege[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
/* Get the local unique identifier (LUID) of the SE_LOCK_MEMORY
|
||||
privilege */
|
||||
|
||||
Result = LookupPrivilegeValue(NULL, SE_LOCK_MEMORY_NAME,
|
||||
&(Info.Privilege[0].Luid));
|
||||
if (Result != TRUE) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Cannot get local privilege"
|
||||
" value for %s, error %lu.\n",
|
||||
SE_LOCK_MEMORY_NAME, (ulint)GetLastError());
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* Try to adjust the privilege */
|
||||
|
||||
Result = AdjustTokenPrivileges(Token, FALSE,
|
||||
(PTOKEN_PRIVILEGES)&Info,
|
||||
0, NULL, NULL);
|
||||
/* Check the result */
|
||||
|
||||
if (Result != TRUE) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Cannot adjust process token privileges,"
|
||||
" error %u.\n",
|
||||
GetLastError());
|
||||
return(FALSE);
|
||||
} else if (GetLastError() != ERROR_SUCCESS) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Cannot enable SE_LOCK_MEMORY privilege,"
|
||||
" error %lu.\n"
|
||||
"InnoDB: In Windows XP Home you cannot use AWE."
|
||||
" In Windows 2000 and XP\n"
|
||||
"InnoDB: Professional you must go to the"
|
||||
" Control Panel, to\n"
|
||||
"InnoDB: Security Settings, to Local Policies,"
|
||||
" and enable\n"
|
||||
"InnoDB: the 'lock pages in memory' privilege"
|
||||
" for the user who runs\n"
|
||||
"InnoDB: the MySQL server.\n", GetLastError());
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
CloseHandle(Token);
|
||||
|
||||
return(TRUE);
|
||||
#else
|
||||
#ifdef __WIN__
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Error: to use AWE you must use"
|
||||
" a ...-nt MySQL executable.\n");
|
||||
#endif
|
||||
return(FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
Allocates physical RAM memory up to 64 GB in an Intel 32-bit x86
|
||||
processor. */
|
||||
|
||||
ibool
|
||||
os_awe_allocate_physical_mem(
|
||||
/*=========================*/
|
||||
/* out: TRUE if success */
|
||||
os_awe_t** page_info, /* out, own: array of opaque data containing
|
||||
the info for allocated physical memory pages;
|
||||
each allocated 4 kB physical memory page has
|
||||
one slot of type os_awe_t in the array */
|
||||
ulint n_megabytes) /* in: number of megabytes to allocate */
|
||||
{
|
||||
#ifdef UNIV_SIMULATE_AWE
|
||||
os_awe_simulate_page_info = ut_malloc
|
||||
(sizeof(os_awe_t) * n_megabytes
|
||||
* ((1024 * 1024) / OS_AWE_X86_PAGE_SIZE));
|
||||
|
||||
os_awe_simulate_mem
|
||||
= ut_align(ut_malloc(4096 + 1024 * 1024 * n_megabytes), 4096);
|
||||
os_awe_simulate_mem_size = n_megabytes * 1024 * 1024;
|
||||
|
||||
*page_info = os_awe_simulate_page_info;
|
||||
|
||||
return(TRUE);
|
||||
|
||||
#elif defined(__WIN2000__)
|
||||
BOOL bResult;
|
||||
os_awe_t NumberOfPages; /* Question: why does Windows
|
||||
use the name ULONG_PTR for
|
||||
a scalar integer type? Maybe
|
||||
because we may also refer to
|
||||
&NumberOfPages? */
|
||||
os_awe_t NumberOfPagesInitial;
|
||||
SYSTEM_INFO sSysInfo;
|
||||
int PFNArraySize;
|
||||
|
||||
if (n_megabytes > 64 * 1024) {
|
||||
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Error: tried to allocate %lu MB.\n"
|
||||
"InnoDB: AWE cannot allocate more than"
|
||||
" 64 GB in any computer.\n", n_megabytes);
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
GetSystemInfo(&sSysInfo); /* fill the system information structure */
|
||||
|
||||
if ((ulint)OS_AWE_X86_PAGE_SIZE != (ulint)sSysInfo.dwPageSize) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Error: this computer has a page size"
|
||||
" of %lu.\n"
|
||||
"InnoDB: Should be 4096 bytes for"
|
||||
" InnoDB AWE support to work.\n",
|
||||
(ulint)sSysInfo.dwPageSize);
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* Calculate the number of pages of memory to request */
|
||||
|
||||
NumberOfPages = n_megabytes * ((1024 * 1024) / OS_AWE_X86_PAGE_SIZE);
|
||||
|
||||
/* Calculate the size of page_info for allocated physical pages */
|
||||
|
||||
PFNArraySize = NumberOfPages * sizeof(os_awe_t);
|
||||
|
||||
*page_info = (os_awe_t*)HeapAlloc(GetProcessHeap(), 0, PFNArraySize);
|
||||
|
||||
if (*page_info == NULL) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Failed to allocate page info"
|
||||
" array from process heap, error %lu\n",
|
||||
(ulint)GetLastError());
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
ut_total_allocated_memory += PFNArraySize;
|
||||
|
||||
/* Enable this process' privilege to lock pages to physical memory */
|
||||
|
||||
if (!os_awe_enable_lock_pages_in_mem()) {
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* Allocate the physical memory */
|
||||
|
||||
NumberOfPagesInitial = NumberOfPages;
|
||||
|
||||
os_awe_page_info = *page_info;
|
||||
os_awe_n_pages = (ulint)NumberOfPages;
|
||||
|
||||
/* Compilation note: if the compiler complains the function is not
|
||||
defined, see the note at the start of this file */
|
||||
|
||||
bResult = AllocateUserPhysicalPages(GetCurrentProcess(),
|
||||
&NumberOfPages, *page_info);
|
||||
if (bResult != TRUE) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Cannot allocate physical pages,"
|
||||
" error %lu.\n",
|
||||
(ulint)GetLastError());
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
if (NumberOfPagesInitial != NumberOfPages) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Error: allocated only %lu pages"
|
||||
" of %lu requested.\n"
|
||||
"InnoDB: Check that you have enough free RAM.\n"
|
||||
"InnoDB: In Windows XP Professional and"
|
||||
" 2000 Professional\n"
|
||||
"InnoDB: Windows PAE size is max 4 GB."
|
||||
" In 2000 and .NET\n"
|
||||
"InnoDB: Advanced Servers and 2000 Datacenter Server"
|
||||
" it is 32 GB,\n"
|
||||
"InnoDB: and in .NET Datacenter Server it is 64 GB.\n"
|
||||
"InnoDB: A Microsoft web page said that"
|
||||
" the processor must be an Intel\n"
|
||||
"InnoDB: processor.\n",
|
||||
(ulint)NumberOfPages,
|
||||
(ulint)NumberOfPagesInitial);
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"InnoDB: Using Address Windowing Extensions (AWE);"
|
||||
" allocated %lu MB\n",
|
||||
n_megabytes);
|
||||
|
||||
return(TRUE);
|
||||
#else
|
||||
UT_NOT_USED(n_megabytes);
|
||||
UT_NOT_USED(page_info);
|
||||
|
||||
return(FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
Allocates a window in the virtual address space where we can map then
|
||||
pages of physical memory. */
|
||||
|
||||
byte*
|
||||
os_awe_allocate_virtual_mem_window(
|
||||
/*===============================*/
|
||||
/* out, own: allocated memory, or NULL if did not
|
||||
succeed */
|
||||
ulint size) /* in: virtual memory allocation size in bytes, must
|
||||
be < 2 GB */
|
||||
{
|
||||
#ifdef UNIV_SIMULATE_AWE
|
||||
ulint i;
|
||||
|
||||
os_awe_simulate_window = ut_align(ut_malloc(4096 + size), 4096);
|
||||
os_awe_simulate_window_size = size;
|
||||
|
||||
os_awe_simulate_map = ut_malloc(sizeof(byte*) * (size / 4096));
|
||||
|
||||
for (i = 0; i < (size / 4096); i++) {
|
||||
*(os_awe_simulate_map + i) = NULL;
|
||||
}
|
||||
|
||||
return(os_awe_simulate_window);
|
||||
|
||||
#elif defined(__WIN2000__)
|
||||
byte* ptr;
|
||||
|
||||
if (size > (ulint)0x7FFFFFFFUL) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Cannot allocate %lu bytes"
|
||||
" of virtual memory\n", size);
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
ptr = VirtualAlloc(NULL, (SIZE_T)size, MEM_RESERVE | MEM_PHYSICAL,
|
||||
PAGE_READWRITE);
|
||||
if (ptr == NULL) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Cannot allocate %lu bytes"
|
||||
" of virtual memory, error %lu\n",
|
||||
size, (ulint)GetLastError());
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
os_awe_window = ptr;
|
||||
os_awe_window_size = size;
|
||||
|
||||
ut_total_allocated_memory += size;
|
||||
|
||||
return(ptr);
|
||||
#else
|
||||
UT_NOT_USED(size);
|
||||
|
||||
return(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
With this function you can map parts of physical memory allocated with
|
||||
the ..._allocate_physical_mem to the virtual address space allocated with
|
||||
the previous function. Intel implements this so that the process page
|
||||
tables are updated accordingly. A test on a 1.5 GHz AMD processor and XP
|
||||
showed that this takes < 1 microsecond, much better than the estimated 80 us
|
||||
for copying a 16 kB page memory to memory. But, the operation will at least
|
||||
partially invalidate the translation lookaside buffer (TLB) of all
|
||||
processors. Under a real-world load the performance hit may be bigger. */
|
||||
|
||||
ibool
|
||||
os_awe_map_physical_mem_to_window(
|
||||
/*==============================*/
|
||||
/* out: TRUE if success; the function
|
||||
calls exit(1) in case of an error */
|
||||
byte* ptr, /* in: a page-aligned pointer to
|
||||
somewhere in the virtual address
|
||||
space window; we map the physical mem
|
||||
pages here */
|
||||
ulint n_mem_pages, /* in: number of 4 kB mem pages to
|
||||
map */
|
||||
os_awe_t* page_info) /* in: array of page infos for those
|
||||
pages; each page has one slot in the
|
||||
array */
|
||||
{
|
||||
#ifdef UNIV_SIMULATE_AWE
|
||||
ulint i;
|
||||
byte** map;
|
||||
byte* page;
|
||||
byte* phys_page;
|
||||
|
||||
ut_a(ptr >= os_awe_simulate_window);
|
||||
ut_a(ptr < os_awe_simulate_window + os_awe_simulate_window_size);
|
||||
ut_a(page_info >= os_awe_simulate_page_info);
|
||||
ut_a(page_info < os_awe_simulate_page_info
|
||||
+ (os_awe_simulate_mem_size / 4096));
|
||||
|
||||
/* First look if some other 'physical pages' are mapped at ptr,
|
||||
and copy them back to where they were if yes */
|
||||
|
||||
map = os_awe_simulate_map
|
||||
+ ((ulint)(ptr - os_awe_simulate_window)) / 4096;
|
||||
page = ptr;
|
||||
|
||||
for (i = 0; i < n_mem_pages; i++) {
|
||||
if (*map != NULL) {
|
||||
ut_memcpy(*map, page, 4096);
|
||||
}
|
||||
map++;
|
||||
page += 4096;
|
||||
}
|
||||
|
||||
/* Then copy to ptr the 'physical pages' determined by page_info; we
|
||||
assume page_info is a segment of the array we created at the start */
|
||||
|
||||
phys_page = os_awe_simulate_mem
|
||||
+ (ulint)(page_info - os_awe_simulate_page_info)
|
||||
* 4096;
|
||||
|
||||
ut_memcpy(ptr, phys_page, n_mem_pages * 4096);
|
||||
|
||||
/* Update the map */
|
||||
|
||||
map = os_awe_simulate_map
|
||||
+ ((ulint)(ptr - os_awe_simulate_window)) / 4096;
|
||||
|
||||
for (i = 0; i < n_mem_pages; i++) {
|
||||
*map = phys_page;
|
||||
|
||||
map++;
|
||||
phys_page += 4096;
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
|
||||
#elif defined(__WIN2000__)
|
||||
BOOL bResult;
|
||||
os_awe_t n_pages;
|
||||
|
||||
n_pages = (os_awe_t)n_mem_pages;
|
||||
|
||||
if (!(ptr >= os_awe_window)) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Error: trying to map to address %lx"
|
||||
" but AWE window start %lx\n",
|
||||
(ulint)ptr, (ulint)os_awe_window);
|
||||
ut_a(0);
|
||||
}
|
||||
|
||||
if (!(ptr <= os_awe_window + os_awe_window_size - UNIV_PAGE_SIZE)) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Error: trying to map to address %lx"
|
||||
" but AWE window end %lx\n",
|
||||
(ulint)ptr, (ulint)os_awe_window + os_awe_window_size);
|
||||
ut_a(0);
|
||||
}
|
||||
|
||||
if (!(page_info >= os_awe_page_info)) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Error: trying to map page info"
|
||||
" at %lx but array start %lx\n",
|
||||
(ulint)page_info, (ulint)os_awe_page_info);
|
||||
ut_a(0);
|
||||
}
|
||||
|
||||
if (!(page_info <= os_awe_page_info + (os_awe_n_pages - 4))) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: AWE: Error: trying to map page info"
|
||||
" at %lx but array end %lx\n",
|
||||
(ulint)page_info,
|
||||
(ulint)(os_awe_page_info + os_awe_n_pages));
|
||||
ut_a(0);
|
||||
}
|
||||
|
||||
bResult = MapUserPhysicalPages((PVOID)ptr, n_pages, page_info);
|
||||
|
||||
if (bResult != TRUE) {
|
||||
ut_print_timestamp(stderr);
|
||||
fprintf(stderr,
|
||||
" InnoDB: AWE: Mapping of %lu physical pages"
|
||||
" to address %lx failed,\n"
|
||||
"InnoDB: error %lu.\n"
|
||||
"InnoDB: Cannot continue operation.\n",
|
||||
n_mem_pages, (ulint)ptr, (ulint)GetLastError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
#else
|
||||
UT_NOT_USED(ptr);
|
||||
UT_NOT_USED(n_mem_pages);
|
||||
UT_NOT_USED(page_info);
|
||||
|
||||
return(FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
Converts the current process id to a number. It is not guaranteed that the
|
||||
number is unique. In Linux returns the 'process number' of the current
|
||||
|
|
|
@ -163,10 +163,6 @@ ulint srv_pool_size = ULINT_MAX; /* size in pages; MySQL inits
|
|||
this to size in kilobytes but
|
||||
we normalize this to pages in
|
||||
srv_boot() */
|
||||
ulint srv_awe_window_size = 0; /* size in pages; MySQL inits
|
||||
this to bytes, but we
|
||||
normalize it to pages in
|
||||
srv_boot() */
|
||||
ulint srv_mem_pool_size = ULINT_MAX; /* size in bytes */
|
||||
ulint srv_lock_table_size = ULINT_MAX;
|
||||
|
||||
|
@ -323,11 +319,6 @@ ibool srv_use_checksums = TRUE;
|
|||
ibool srv_set_thread_priorities = TRUE;
|
||||
int srv_query_thread_priority = 0;
|
||||
|
||||
/* TRUE if the Address Windowing Extensions of Windows are used; then we must
|
||||
disable adaptive hash indexes */
|
||||
ibool srv_use_awe = FALSE;
|
||||
ibool srv_use_adaptive_hash_indexes = TRUE;
|
||||
|
||||
/*-------------------------------------------*/
|
||||
ulong srv_n_spin_wait_rounds = 20;
|
||||
ulong srv_n_free_tickets_to_enter = 500;
|
||||
|
@ -1244,17 +1235,7 @@ srv_normalize_init_values(void)
|
|||
|
||||
srv_pool_size = srv_pool_size / (UNIV_PAGE_SIZE / 1024);
|
||||
|
||||
srv_awe_window_size = srv_awe_window_size / UNIV_PAGE_SIZE;
|
||||
|
||||
if (srv_use_awe) {
|
||||
/* If we are using AWE we must save memory in the 32-bit
|
||||
address space of the process, and cannot bind the lock
|
||||
table size to the real buffer pool size. */
|
||||
|
||||
srv_lock_table_size = 20 * srv_awe_window_size;
|
||||
} else {
|
||||
srv_lock_table_size = 5 * srv_pool_size;
|
||||
}
|
||||
srv_lock_table_size = 5 * srv_pool_size;
|
||||
|
||||
return(DB_SUCCESS);
|
||||
}
|
||||
|
@ -1702,13 +1683,6 @@ srv_printf_innodb_monitor(
|
|||
fprintf(file, "Dictionary memory allocated " ULINTPF "\n",
|
||||
dict_sys->size);
|
||||
|
||||
if (srv_use_awe) {
|
||||
fprintf(file,
|
||||
"In addition to that %lu MB of AWE memory allocated\n",
|
||||
(ulong) (srv_pool_size
|
||||
/ ((1024 * 1024) / UNIV_PAGE_SIZE)));
|
||||
}
|
||||
|
||||
buf_print_io(file);
|
||||
|
||||
fputs("--------------\n"
|
||||
|
|
|
@ -1035,10 +1035,6 @@ innobase_start_or_create_for_mysql(void)
|
|||
"InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n");
|
||||
#endif
|
||||
|
||||
#ifdef UNIV_SIMULATE_AWE
|
||||
fprintf(stderr,
|
||||
"InnoDB: !!!!!!!! UNIV_SIMULATE_AWE switched on !!!!!!!!!\n");
|
||||
#endif
|
||||
if (srv_sizeof_trx_t_in_ha_innodb_cc != (ulint)sizeof(trx_t)) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: Error: trx_t size is %lu in ha_innodb.cc"
|
||||
|
@ -1077,21 +1073,6 @@ innobase_start_or_create_for_mysql(void)
|
|||
srv_startup_is_before_trx_rollback_phase = TRUE;
|
||||
os_aio_use_native_aio = FALSE;
|
||||
|
||||
#if !defined(__WIN2000__) && !defined(UNIV_SIMULATE_AWE)
|
||||
if (srv_use_awe) {
|
||||
|
||||
fprintf(stderr,
|
||||
"InnoDB: Error: You have specified"
|
||||
" innodb_buffer_pool_awe_mem_mb\n"
|
||||
"InnoDB: in my.cnf, but AWE can only"
|
||||
" be used in Windows 2000 and later.\n"
|
||||
"InnoDB: To use AWE, InnoDB must"
|
||||
" be compiled with __WIN2000__ defined.\n");
|
||||
|
||||
return(DB_ERROR);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __WIN__
|
||||
if (os_get_os_version() == OS_WIN95
|
||||
|| os_get_os_version() == OS_WIN31
|
||||
|
@ -1249,25 +1230,7 @@ innobase_start_or_create_for_mysql(void)
|
|||
|
||||
fil_init(srv_max_n_open_files);
|
||||
|
||||
if (srv_use_awe) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: Using AWE: Memory window is %lu MB"
|
||||
" and AWE memory is %lu MB\n",
|
||||
(ulong) (srv_awe_window_size / ((1024 * 1024)
|
||||
/ UNIV_PAGE_SIZE)),
|
||||
(ulong) (srv_pool_size / ((1024 * 1024)
|
||||
/ UNIV_PAGE_SIZE)));
|
||||
|
||||
/* We must disable adaptive hash indexes because they do not
|
||||
tolerate remapping of pages in AWE */
|
||||
|
||||
srv_use_adaptive_hash_indexes = FALSE;
|
||||
ret = buf_pool_init(srv_pool_size, srv_pool_size,
|
||||
srv_awe_window_size);
|
||||
} else {
|
||||
ret = buf_pool_init(srv_pool_size, srv_pool_size,
|
||||
srv_pool_size);
|
||||
}
|
||||
ret = buf_pool_init(srv_pool_size, srv_pool_size);
|
||||
|
||||
if (ret == NULL) {
|
||||
fprintf(stderr,
|
||||
|
|
Loading…
Reference in a new issue