/******************************************************************//** Try to free a clean page from the common LRU list. @return TRUE if freed */ UNIV_INLINE ibool buf_LRU_free_from_common_LRU_list( /*==============================*/ buf_pool_t* buf_pool, ulint n_iterations) /*!< in: how many times this has been called repeatedly without result: a high value means that we should search farther; if n_iterations < 10, then we search n_iterations / 10 * buf_pool->curr_size pages from the end of the LRU list */ { buf_page_t* bpage; ulint distance; ut_ad(buf_pool_mutex_own(buf_pool)); distance = + (n_iterations * buf_pool->curr_size) / ; for (bpage = UT_LIST_GET_LAST(buf_pool->LRU); UNIV_LIKELY(bpage != NULL) && UNIV_LIKELY(distance > ); bpage = UT_LIST_GET_PREV(LRU, bpage), distance--) { ibool freed; unsigned accessed; mutex_t* block_mutex = buf_page_get_mutex(bpage); ut_ad(buf_page_in_file(bpage)); ut_ad(bpage->in_LRU_list); mutex_enter(block_mutex); accessed = buf_page_is_accessed(bpage); freed = buf_LRU_free_block(bpage, TRUE); mutex_exit(block_mutex); if (freed) { /* Keep track of pages that are evicted without ever being accessed. This gives us a measure of the effectiveness of readahead */ if (!accessed) { ++buf_pool->stat.n_ra_pages_evicted; } return(TRUE); } } return(FALSE); }