diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-07-02 07:39:33 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-07-02 07:39:33 +0300 |
commit | f347b3e0e6592329b1447fa460aca0a4b1f680b1 (patch) | |
tree | c671aced17dc9f6d0cc6c5a660b73b2e2dcfe841 /storage/innobase/buf | |
parent | b0f836053b094b09999c102d10bf0ad6ed761ac6 (diff) | |
parent | 1df1a6392477ad211b2a66c6eccbe9d5c6316c7e (diff) | |
download | mariadb-git-f347b3e0e6592329b1447fa460aca0a4b1f680b1.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'storage/innobase/buf')
-rw-r--r-- | storage/innobase/buf/buf0buddy.cc | 39 | ||||
-rw-r--r-- | storage/innobase/buf/buf0buf.cc | 23 | ||||
-rw-r--r-- | storage/innobase/buf/buf0dblwr.cc | 5 | ||||
-rw-r--r-- | storage/innobase/buf/buf0flu.cc | 6 | ||||
-rw-r--r-- | storage/innobase/buf/buf0lru.cc | 45 |
5 files changed, 46 insertions, 72 deletions
diff --git a/storage/innobase/buf/buf0buddy.cc b/storage/innobase/buf/buf0buddy.cc index 7a7c3189add..ed36bcb9703 100644 --- a/storage/innobase/buf/buf0buddy.cc +++ b/storage/innobase/buf/buf0buddy.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2018, 2019, MariaDB Corporation. +Copyright (c) 2018, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -81,7 +81,6 @@ enum buf_buddy_state_t { are in use */ }; -#ifdef UNIV_DEBUG_VALGRIND /**********************************************************************//** Invalidate memory area that we won't access while page is free */ UNIV_INLINE @@ -91,15 +90,11 @@ buf_buddy_mem_invalid( buf_buddy_free_t* buf, /*!< in: block to check */ ulint i) /*!< in: index of zip_free[] */ { - const size_t size = BUF_BUDDY_LOW << i; - ut_ad(i <= BUF_BUDDY_SIZES); + ut_ad(i <= BUF_BUDDY_SIZES); - UNIV_MEM_ASSERT_W(buf, size); - UNIV_MEM_INVALID(buf, size); + MEM_CHECK_ADDRESSABLE(buf, BUF_BUDDY_LOW << i); + MEM_UNDEFINED(buf, BUF_BUDDY_LOW << i); } -#else /* UNIV_DEBUG_VALGRIND */ -# define buf_buddy_mem_invalid(buf, i) ut_ad((i) <= BUF_BUDDY_SIZES) -#endif /* UNIV_DEBUG_VALGRIND */ /**********************************************************************//** Check if a buddy is stamped free. @@ -357,11 +352,10 @@ buf_buddy_alloc_zip( if (buf) { /* Trash the page other than the BUF_BUDDY_STAMP_NONFREE. */ - UNIV_MEM_TRASH((void*) buf, ~i, BUF_BUDDY_STAMP_OFFSET); - UNIV_MEM_TRASH(BUF_BUDDY_STAMP_OFFSET + 4 - + buf->stamp.bytes, ~i, - (BUF_BUDDY_LOW << i) - - (BUF_BUDDY_STAMP_OFFSET + 4)); + MEM_UNDEFINED(buf, BUF_BUDDY_STAMP_OFFSET); + MEM_UNDEFINED(BUF_BUDDY_STAMP_OFFSET + 4 + buf->stamp.bytes, + (BUF_BUDDY_LOW << i) + - (BUF_BUDDY_STAMP_OFFSET + 4)); ut_ad(mach_read_from_4(buf->stamp.bytes + BUF_BUDDY_STAMP_OFFSET) == BUF_BUDDY_STAMP_NONFREE); @@ -399,7 +393,9 @@ buf_buddy_block_free( HASH_DELETE(buf_page_t, hash, buf_pool->zip_hash, fold, bpage); ut_d(memset(buf, 0, srv_page_size)); - UNIV_MEM_INVALID(buf, srv_page_size); +#ifdef HAVE_valgrind_or_MSAN + MEM_UNDEFINED(buf, srv_page_size); +#endif /* HAVE_valgrind_or_MSAN */ block = (buf_block_t*) bpage; buf_page_mutex_enter(block); @@ -555,17 +551,16 @@ buf_buddy_relocate( ut_ad(!ut_align_offset(src, size)); ut_ad(!ut_align_offset(dst, size)); ut_ad(i >= buf_buddy_get_slot(UNIV_ZIP_SIZE_MIN)); - UNIV_MEM_ASSERT_W(dst, size); + MEM_CHECK_ADDRESSABLE(dst, size); space = mach_read_from_4((const byte*) src + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); offset = mach_read_from_4((const byte*) src + FIL_PAGE_OFFSET); - /* Suppress Valgrind warnings about conditional jump - on uninitialized value. */ - UNIV_MEM_VALID(&space, sizeof space); - UNIV_MEM_VALID(&offset, sizeof offset); + /* Suppress Valgrind or MSAN warnings. */ + MEM_MAKE_DEFINED(&space, sizeof space); + MEM_MAKE_DEFINED(&offset, sizeof offset); ut_ad(space != BUF_BUDDY_STAMP_FREE); @@ -627,7 +622,7 @@ buf_buddy_relocate( /* The block must have been allocated, but it may contain uninitialized data. */ - UNIV_MEM_ASSERT_W(src, size); + MEM_CHECK_ADDRESSABLE(src, size); BPageMutex* block_mutex = buf_page_get_mutex(bpage); @@ -682,7 +677,7 @@ buf_buddy_free_low( buf_pool->buddy_stat[i].used--; recombine: - UNIV_MEM_ALLOC(buf, BUF_BUDDY_LOW << i); + MEM_UNDEFINED(buf, BUF_BUDDY_LOW << i); if (i == BUF_BUDDY_SIZES) { buf_buddy_block_free(buf_pool, buf); diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index e44110e1387..4aeb4bbd193 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1531,8 +1531,6 @@ buf_block_init( buf_block_t* block, /*!< in: pointer to control block */ byte* frame) /*!< in: pointer to buffer frame */ { - UNIV_MEM_DESC(frame, srv_page_size); - /* This function should only be executed at database startup or by buf_pool_resize(). Either way, adaptive hash index must not exist. */ assert_block_ahi_empty_on_init(block); @@ -1676,7 +1674,7 @@ buf_chunk_init( for (i = chunk->size; i--; ) { buf_block_init(buf_pool, block, frame); - UNIV_MEM_INVALID(block->frame, srv_page_size); + MEM_UNDEFINED(block->frame, srv_page_size); /* Add the block to the free list */ UT_LIST_ADD_LAST(buf_pool->free, &block->page); @@ -2202,8 +2200,6 @@ buf_page_realloc( if (block->page.zip.data != NULL) { ut_ad(block->in_unzip_LRU_list); ut_d(new_block->in_unzip_LRU_list = TRUE); - UNIV_MEM_DESC(&new_block->page.zip.data, - page_zip_get_size(&new_block->page.zip)); buf_block_t* prev_block = UT_LIST_GET_PREV(unzip_LRU, block); UT_LIST_REMOVE(buf_pool->unzip_LRU, block); @@ -2237,7 +2233,7 @@ buf_page_realloc( buf_block_modify_clock_inc(block); memset(block->frame + FIL_PAGE_OFFSET, 0xff, 4); memset(block->frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 0xff, 4); - UNIV_MEM_INVALID(block->frame, srv_page_size); + MEM_UNDEFINED(block->frame, srv_page_size); buf_block_set_state(block, BUF_BLOCK_REMOVE_HASH); block->page.id = page_id_t(ULINT32_UNDEFINED, ULINT32_UNDEFINED); @@ -4640,9 +4636,6 @@ evict_from_pool: block->lock_hash_val = lock_rec_hash(page_id.space(), page_id.page_no()); - UNIV_MEM_DESC(&block->page.zip.data, - page_zip_get_size(&block->page.zip)); - if (buf_page_get_state(&block->page) == BUF_BLOCK_ZIP_PAGE) { #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG UT_LIST_REMOVE(buf_pool->zip_clean, &block->page); @@ -4664,7 +4657,7 @@ evict_from_pool: buf_block_set_io_fix(block, BUF_IO_READ); rw_lock_x_lock_inline(&block->lock, 0, file, line); - UNIV_MEM_INVALID(bpage, sizeof *bpage); + MEM_UNDEFINED(bpage, sizeof *bpage); rw_lock_x_unlock(hash_lock); buf_pool->n_pend_unzip++; @@ -5283,15 +5276,6 @@ buf_page_init( /* Set the state of the block */ buf_block_set_file_page(block, page_id); -#ifdef UNIV_DEBUG_VALGRIND - if (is_system_tablespace(page_id.space())) { - /* Silence valid Valgrind warnings about uninitialized - data being written to data files. There are some unused - bytes on some pages that InnoDB does not initialize. */ - UNIV_MEM_VALID(block->frame, srv_page_size); - } -#endif /* UNIV_DEBUG_VALGRIND */ - buf_block_init_low(block); block->lock_hash_val = lock_rec_hash(page_id.space(), @@ -5512,7 +5496,6 @@ buf_page_init_for_read( bpage->zip.data = (page_zip_t*) data; mutex_enter(&buf_pool->zip_mutex); - UNIV_MEM_DESC(bpage->zip.data, zip_size); buf_page_init_low(bpage); diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 55400136c4a..9c1b305fb6a 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -1149,14 +1149,13 @@ try_again: void * frame = buf_page_get_frame(bpage); if (auto zip_size = bpage->zip_size()) { - UNIV_MEM_ASSERT_RW(bpage->zip.data, zip_size); + MEM_CHECK_DEFINED(bpage->zip.data, zip_size); /* Copy the compressed page and clear the rest. */ memcpy(p, frame, zip_size); memset(p + zip_size, 0x0, srv_page_size - zip_size); } else { ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE); - - UNIV_MEM_ASSERT_RW(frame, srv_page_size); + MEM_CHECK_DEFINED(frame, srv_page_size); memcpy(p, frame, srv_page_size); } diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 77cb4517807..616885ed863 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -431,9 +431,9 @@ buf_flush_insert_into_flush_list( ut_d(block->page.in_flush_list = TRUE); ut_ad(!block->page.oldest_modification); block->page.oldest_modification = lsn; - UNIV_MEM_ASSERT_RW(block->page.zip.data - ? block->page.zip.data : block->frame, - block->physical_size()); + MEM_CHECK_DEFINED(block->page.zip.data + ? block->page.zip.data : block->frame, + block->physical_size()); incr_flush_list_size_in_bytes(block, buf_pool); if (UNIV_LIKELY_NULL(buf_pool->flush_rbt)) { diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index 59986fbca00..6f33a0399f9 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -806,7 +806,7 @@ buf_LRU_get_free_only( assert_block_ahi_empty(block); buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE); - UNIV_MEM_ALLOC(block->frame, srv_page_size); + MEM_UNDEFINED(block->frame, srv_page_size); ut_ad(buf_pool_from_block(block) == buf_pool); @@ -1503,8 +1503,6 @@ func_exit: ut_ad(b->zip_size()); - UNIV_MEM_DESC(b->zip.data, b->zip_size()); - /* The fields in_page_hash and in_LRU_list of the to-be-freed block descriptor should have been cleared in @@ -1604,17 +1602,20 @@ func_exit: The page was declared uninitialized by buf_LRU_block_remove_hashed(). We need to flag the contents of the page valid (which it still is) in - order to avoid bogus Valgrind warnings.*/ + order to avoid bogus Valgrind or MSAN warnings.*/ + buf_block_t* block = reinterpret_cast<buf_block_t*>(bpage); - UNIV_MEM_VALID(((buf_block_t*) bpage)->frame, - srv_page_size); - btr_search_drop_page_hash_index((buf_block_t*) bpage); - UNIV_MEM_INVALID(((buf_block_t*) bpage)->frame, - srv_page_size); +#ifdef HAVE_valgrind_or_MSAN + MEM_MAKE_DEFINED(block->frame, srv_page_size); +#endif /* HAVE_valgrind_or_MSAN */ + btr_search_drop_page_hash_index(block); +#ifdef HAVE_valgrind_or_MSAN + MEM_UNDEFINED(block->frame, srv_page_size); +#endif /* HAVE_valgrind_or_MSAN */ buf_pool_mutex_enter(buf_pool); - if (b != NULL) { + if (b) { mutex_enter(block_mutex); buf_page_unset_sticky(b); @@ -1622,7 +1623,7 @@ func_exit: mutex_exit(block_mutex); } - buf_LRU_block_free_hashed_page((buf_block_t*) bpage); + buf_LRU_block_free_hashed_page(block); return(true); } @@ -1655,15 +1656,12 @@ buf_LRU_block_free_non_file_page( buf_block_set_state(block, BUF_BLOCK_NOT_USED); - UNIV_MEM_ALLOC(block->frame, srv_page_size); -#ifdef UNIV_DEBUG - /* Wipe contents of page to reveal possible stale pointers to it */ - memset(block->frame, '\0', srv_page_size); -#else +#ifdef HAVE_valgrind_or_MSAN + MEM_UNDEFINED(block->frame, srv_page_size); +#endif /* HAVE_valgrind_or_MSAN */ /* Wipe page_no and space_id */ memset(block->frame + FIL_PAGE_OFFSET, 0xfe, 4); memset(block->frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 0xfe, 4); -#endif /* UNIV_DEBUG */ data = block->page.zip.data; if (data != NULL) { @@ -1694,7 +1692,7 @@ buf_LRU_block_free_non_file_page( ut_d(block->page.in_free_list = TRUE); } - UNIV_MEM_FREE(block->frame, srv_page_size); + MEM_NOACCESS(block->frame, srv_page_size); } /******************************************************************//** @@ -1741,9 +1739,9 @@ buf_LRU_block_remove_hashed( switch (buf_page_get_state(bpage)) { case BUF_BLOCK_FILE_PAGE: - UNIV_MEM_ASSERT_W(bpage, sizeof(buf_block_t)); - UNIV_MEM_ASSERT_W(((buf_block_t*) bpage)->frame, - srv_page_size); + MEM_CHECK_ADDRESSABLE(bpage, sizeof(buf_block_t)); + MEM_CHECK_ADDRESSABLE(((buf_block_t*) bpage)->frame, + srv_page_size); buf_block_modify_clock_inc((buf_block_t*) bpage); if (bpage->zip.data) { const page_t* page = ((buf_block_t*) bpage)->frame; @@ -1797,7 +1795,7 @@ buf_LRU_block_remove_hashed( /* fall through */ case BUF_BLOCK_ZIP_PAGE: ut_a(bpage->oldest_modification == 0); - UNIV_MEM_ASSERT_W(bpage->zip.data, bpage->zip_size()); + MEM_CHECK_ADDRESSABLE(bpage->zip.data, bpage->zip_size()); break; case BUF_BLOCK_POOL_WATCH: case BUF_BLOCK_ZIP_DIRTY: @@ -1849,8 +1847,7 @@ buf_LRU_block_remove_hashed( + FIL_PAGE_OFFSET, 0xff, 4); memset(((buf_block_t*) bpage)->frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 0xff, 4); - UNIV_MEM_INVALID(((buf_block_t*) bpage)->frame, - srv_page_size); + MEM_UNDEFINED(((buf_block_t*) bpage)->frame, srv_page_size); buf_page_set_state(bpage, BUF_BLOCK_REMOVE_HASH); /* Question: If we release bpage and hash mutex here |