Commit 4f4a4cf9 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-23399 fixup: Use plain pthread_cond

The condition variables that were introduced in
commit 7cffb5f6 (MDEV-23399)
are never instrumented with PERFORMANCE_SCHEMA.
Let us avoid the storage overhead and dead code.
parent 7ce64378
...@@ -1462,9 +1462,9 @@ bool buf_pool_t::create() ...@@ -1462,9 +1462,9 @@ bool buf_pool_t::create()
mysql_mutex_init(flush_list_mutex_key, &flush_list_mutex, mysql_mutex_init(flush_list_mutex_key, &flush_list_mutex,
MY_MUTEX_INIT_FAST); MY_MUTEX_INIT_FAST);
mysql_cond_init(0, &done_flush_LRU, nullptr); pthread_cond_init(&done_flush_LRU, nullptr);
mysql_cond_init(0, &done_flush_list, nullptr); pthread_cond_init(&done_flush_list, nullptr);
mysql_cond_init(0, &do_flush_list, nullptr); pthread_cond_init(&do_flush_list, nullptr);
try_LRU_scan= true; try_LRU_scan= true;
...@@ -1525,9 +1525,9 @@ void buf_pool_t::close() ...@@ -1525,9 +1525,9 @@ void buf_pool_t::close()
allocator.deallocate_large_dodump(chunk->mem, &chunk->mem_pfx); allocator.deallocate_large_dodump(chunk->mem, &chunk->mem_pfx);
} }
mysql_cond_destroy(&done_flush_LRU); pthread_cond_destroy(&done_flush_LRU);
mysql_cond_destroy(&done_flush_list); pthread_cond_destroy(&done_flush_list);
mysql_cond_destroy(&do_flush_list); pthread_cond_destroy(&do_flush_list);
ut_free(chunks); ut_free(chunks);
chunks= nullptr; chunks= nullptr;
...@@ -3694,8 +3694,8 @@ buf_page_create(fil_space_t *space, uint32_t offset, ...@@ -3694,8 +3694,8 @@ buf_page_create(fil_space_t *space, uint32_t offset,
We must not hold buf_pool.mutex while waiting. */ We must not hold buf_pool.mutex while waiting. */
timespec abstime; timespec abstime;
set_timespec_nsec(abstime, 1000000); set_timespec_nsec(abstime, 1000000);
mysql_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex, my_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex.m_mutex,
&abstime); &abstime);
} }
mtr_memo_push(mtr, block, MTR_MEMO_PAGE_X_FIX); mtr_memo_push(mtr, block, MTR_MEMO_PAGE_X_FIX);
} }
...@@ -3719,8 +3719,8 @@ buf_page_create(fil_space_t *space, uint32_t offset, ...@@ -3719,8 +3719,8 @@ buf_page_create(fil_space_t *space, uint32_t offset,
/* Wait for buf_page_write_complete() to release the I/O fix. */ /* Wait for buf_page_write_complete() to release the I/O fix. */
timespec abstime; timespec abstime;
set_timespec_nsec(abstime, 1000000); set_timespec_nsec(abstime, 1000000);
mysql_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex, my_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex.m_mutex,
&abstime); &abstime);
goto loop; goto loop;
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2020, MariaDB Corporation. Copyright (c) 2013, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -58,7 +58,7 @@ inline void buf_dblwr_t::init(const byte *header) ...@@ -58,7 +58,7 @@ inline void buf_dblwr_t::init(const byte *header)
ut_ad(!batch_running); ut_ad(!batch_running);
mysql_mutex_init(buf_dblwr_mutex_key, &mutex, nullptr); mysql_mutex_init(buf_dblwr_mutex_key, &mutex, nullptr);
mysql_cond_init(0, &cond, nullptr); pthread_cond_init(&cond, nullptr);
block1= page_id_t(0, mach_read_from_4(header + TRX_SYS_DOUBLEWRITE_BLOCK1)); block1= page_id_t(0, mach_read_from_4(header + TRX_SYS_DOUBLEWRITE_BLOCK1));
block2= page_id_t(0, mach_read_from_4(header + TRX_SYS_DOUBLEWRITE_BLOCK2)); block2= page_id_t(0, mach_read_from_4(header + TRX_SYS_DOUBLEWRITE_BLOCK2));
...@@ -452,7 +452,7 @@ void buf_dblwr_t::close() ...@@ -452,7 +452,7 @@ void buf_dblwr_t::close()
ut_ad(!active_slot->first_free); ut_ad(!active_slot->first_free);
ut_ad(!batch_running); ut_ad(!batch_running);
mysql_cond_destroy(&cond); pthread_cond_destroy(&cond);
for (int i= 0; i < 2; i++) for (int i= 0; i < 2; i++)
{ {
aligned_free(slots[i].write_buf); aligned_free(slots[i].write_buf);
...@@ -489,7 +489,7 @@ void buf_dblwr_t::write_completed() ...@@ -489,7 +489,7 @@ void buf_dblwr_t::write_completed()
/* We can now reuse the doublewrite memory buffer: */ /* We can now reuse the doublewrite memory buffer: */
flush_slot->first_free= 0; flush_slot->first_free= 0;
batch_running= false; batch_running= false;
mysql_cond_broadcast(&cond); pthread_cond_broadcast(&cond);
} }
mysql_mutex_unlock(&mutex); mysql_mutex_unlock(&mutex);
...@@ -566,7 +566,7 @@ bool buf_dblwr_t::flush_buffered_writes(const ulint size) ...@@ -566,7 +566,7 @@ bool buf_dblwr_t::flush_buffered_writes(const ulint size)
return false; return false;
if (!batch_running) if (!batch_running)
break; break;
mysql_cond_wait(&cond, &mutex); my_cond_wait(&cond, &mutex.m_mutex);
} }
ut_ad(active_slot->reserved == active_slot->first_free); ut_ad(active_slot->reserved == active_slot->first_free);
......
...@@ -138,7 +138,7 @@ inline void buf_pool_t::page_cleaner_wakeup() ...@@ -138,7 +138,7 @@ inline void buf_pool_t::page_cleaner_wakeup()
srv_max_buf_pool_modified_pct <= dirty_pct) srv_max_buf_pool_modified_pct <= dirty_pct)
{ {
page_cleaner_is_idle= false; page_cleaner_is_idle= false;
mysql_cond_signal(&do_flush_list); pthread_cond_signal(&do_flush_list);
} }
} }
...@@ -396,12 +396,12 @@ void buf_page_write_complete(const IORequest &request) ...@@ -396,12 +396,12 @@ void buf_page_write_complete(const IORequest &request)
{ {
buf_LRU_free_page(bpage, true); buf_LRU_free_page(bpage, true);
if (!--buf_pool.n_flush_LRU) if (!--buf_pool.n_flush_LRU)
mysql_cond_broadcast(&buf_pool.done_flush_LRU); pthread_cond_broadcast(&buf_pool.done_flush_LRU);
} }
else else
{ {
if (!--buf_pool.n_flush_list) if (!--buf_pool.n_flush_list)
mysql_cond_broadcast(&buf_pool.done_flush_list); pthread_cond_broadcast(&buf_pool.done_flush_list);
} }
mysql_mutex_unlock(&buf_pool.mutex); mysql_mutex_unlock(&buf_pool.mutex);
...@@ -1512,11 +1512,11 @@ void buf_flush_wait_batch_end(bool lru) ...@@ -1512,11 +1512,11 @@ void buf_flush_wait_batch_end(bool lru)
tpool::tpool_wait_begin(); tpool::tpool_wait_begin();
thd_wait_begin(nullptr, THD_WAIT_DISKIO); thd_wait_begin(nullptr, THD_WAIT_DISKIO);
do do
mysql_cond_wait(cond, &buf_pool.mutex); my_cond_wait(cond, &buf_pool.mutex.m_mutex);
while (n_flush); while (n_flush);
tpool::tpool_wait_end(); tpool::tpool_wait_end();
thd_wait_end(nullptr); thd_wait_end(nullptr);
mysql_cond_broadcast(cond); pthread_cond_broadcast(cond);
} }
} }
...@@ -1571,7 +1571,7 @@ ulint buf_flush_lists(ulint max_n, lsn_t lsn) ...@@ -1571,7 +1571,7 @@ ulint buf_flush_lists(ulint max_n, lsn_t lsn)
if (running || (lsn && !UT_LIST_GET_LEN(buf_pool.flush_list))) if (running || (lsn && !UT_LIST_GET_LEN(buf_pool.flush_list)))
{ {
if (!running) if (!running)
mysql_cond_broadcast(cond); pthread_cond_broadcast(cond);
mysql_mutex_unlock(&buf_pool.mutex); mysql_mutex_unlock(&buf_pool.mutex);
return 0; return 0;
} }
...@@ -1588,7 +1588,7 @@ ulint buf_flush_lists(ulint max_n, lsn_t lsn) ...@@ -1588,7 +1588,7 @@ ulint buf_flush_lists(ulint max_n, lsn_t lsn)
mysql_mutex_unlock(&buf_pool.mutex); mysql_mutex_unlock(&buf_pool.mutex);
if (!n_flushing) if (!n_flushing)
mysql_cond_broadcast(cond); pthread_cond_broadcast(cond);
buf_dblwr.flush_buffered_writes(); buf_dblwr.flush_buffered_writes();
...@@ -1749,14 +1749,15 @@ ATTRIBUTE_COLD void buf_flush_wait_flushed(lsn_t sync_lsn) ...@@ -1749,14 +1749,15 @@ ATTRIBUTE_COLD void buf_flush_wait_flushed(lsn_t sync_lsn)
if (buf_flush_sync_lsn < sync_lsn) if (buf_flush_sync_lsn < sync_lsn)
{ {
buf_flush_sync_lsn= sync_lsn; buf_flush_sync_lsn= sync_lsn;
mysql_cond_signal(&buf_pool.do_flush_list); pthread_cond_signal(&buf_pool.do_flush_list);
} }
do do
{ {
tpool::tpool_wait_begin(); tpool::tpool_wait_begin();
thd_wait_begin(nullptr, THD_WAIT_DISKIO); thd_wait_begin(nullptr, THD_WAIT_DISKIO);
mysql_cond_wait(&buf_pool.done_flush_list, &buf_pool.flush_list_mutex); my_cond_wait(&buf_pool.done_flush_list,
&buf_pool.flush_list_mutex.m_mutex);
thd_wait_end(nullptr); thd_wait_end(nullptr);
tpool::tpool_wait_end(); tpool::tpool_wait_end();
...@@ -1788,7 +1789,7 @@ void buf_flush_ahead(lsn_t lsn) ...@@ -1788,7 +1789,7 @@ void buf_flush_ahead(lsn_t lsn)
if (buf_flush_sync_lsn < lsn) if (buf_flush_sync_lsn < lsn)
{ {
buf_flush_sync_lsn= lsn; buf_flush_sync_lsn= lsn;
mysql_cond_signal(&buf_pool.do_flush_list); pthread_cond_signal(&buf_pool.do_flush_list);
} }
mysql_mutex_unlock(&buf_pool.flush_list_mutex); mysql_mutex_unlock(&buf_pool.flush_list_mutex);
} }
...@@ -1866,7 +1867,7 @@ ATTRIBUTE_COLD static void buf_flush_sync_for_checkpoint(lsn_t lsn) ...@@ -1866,7 +1867,7 @@ ATTRIBUTE_COLD static void buf_flush_sync_for_checkpoint(lsn_t lsn)
buf_flush_sync_lsn= 0; buf_flush_sync_lsn= 0;
/* wake up buf_flush_wait_flushed() */ /* wake up buf_flush_wait_flushed() */
mysql_cond_broadcast(&buf_pool.done_flush_list); pthread_cond_broadcast(&buf_pool.done_flush_list);
lsn= std::max(lsn, target); lsn= std::max(lsn, target);
...@@ -2095,10 +2096,11 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*) ...@@ -2095,10 +2096,11 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*)
break; break;
if (buf_pool.page_cleaner_idle()) if (buf_pool.page_cleaner_idle())
mysql_cond_wait(&buf_pool.do_flush_list, &buf_pool.flush_list_mutex); my_cond_wait(&buf_pool.do_flush_list,
&buf_pool.flush_list_mutex.m_mutex);
else else
mysql_cond_timedwait(&buf_pool.do_flush_list, &buf_pool.flush_list_mutex, my_cond_timedwait(&buf_pool.do_flush_list,
&abstime); &buf_pool.flush_list_mutex.m_mutex, &abstime);
set_timespec(abstime, 1); set_timespec(abstime, 1);
...@@ -2120,7 +2122,7 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*) ...@@ -2120,7 +2122,7 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*)
{ {
buf_flush_sync_lsn= 0; buf_flush_sync_lsn= 0;
/* wake up buf_flush_wait_flushed() */ /* wake up buf_flush_wait_flushed() */
mysql_cond_broadcast(&buf_pool.done_flush_list); pthread_cond_broadcast(&buf_pool.done_flush_list);
} }
unemployed: unemployed:
buf_pool.page_cleaner_set_idle(true); buf_pool.page_cleaner_set_idle(true);
...@@ -2156,7 +2158,7 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*) ...@@ -2156,7 +2158,7 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*)
{ {
n_flushed= buf_flush_lists(srv_max_io_capacity, lsn_limit); n_flushed= buf_flush_lists(srv_max_io_capacity, lsn_limit);
/* wake up buf_flush_wait_flushed() */ /* wake up buf_flush_wait_flushed() */
mysql_cond_broadcast(&buf_pool.done_flush_list); pthread_cond_broadcast(&buf_pool.done_flush_list);
goto try_checkpoint; goto try_checkpoint;
} }
else if (!srv_adaptive_flushing) else if (!srv_adaptive_flushing)
...@@ -2233,7 +2235,7 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*) ...@@ -2233,7 +2235,7 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*)
if (UNIV_UNLIKELY(lsn_limit != 0)) if (UNIV_UNLIKELY(lsn_limit != 0))
goto furious_flush; goto furious_flush;
buf_page_cleaner_is_active= false; buf_page_cleaner_is_active= false;
mysql_cond_broadcast(&buf_pool.done_flush_list); pthread_cond_broadcast(&buf_pool.done_flush_list);
mysql_mutex_unlock(&buf_pool.flush_list_mutex); mysql_mutex_unlock(&buf_pool.flush_list_mutex);
my_thread_end(); my_thread_end();
...@@ -2287,8 +2289,8 @@ ATTRIBUTE_COLD void buf_flush_buffer_pool() ...@@ -2287,8 +2289,8 @@ ATTRIBUTE_COLD void buf_flush_buffer_pool()
set_timespec(abstime, INNODB_EXTEND_TIMEOUT_INTERVAL / 2); set_timespec(abstime, INNODB_EXTEND_TIMEOUT_INTERVAL / 2);
mysql_mutex_lock(&buf_pool.mutex); mysql_mutex_lock(&buf_pool.mutex);
while (buf_pool.n_flush_list) while (buf_pool.n_flush_list)
mysql_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex, my_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex.m_mutex,
&abstime); &abstime);
mysql_mutex_unlock(&buf_pool.mutex); mysql_mutex_unlock(&buf_pool.mutex);
} }
} }
......
...@@ -17204,7 +17204,7 @@ innodb_max_dirty_pages_pct_update( ...@@ -17204,7 +17204,7 @@ innodb_max_dirty_pages_pct_update(
in_val); in_val);
srv_max_dirty_pages_pct_lwm = in_val; srv_max_dirty_pages_pct_lwm = in_val;
mysql_cond_signal(&buf_pool.do_flush_list); pthread_cond_signal(&buf_pool.do_flush_list);
} }
srv_max_buf_pool_modified_pct = in_val; srv_max_buf_pool_modified_pct = in_val;
...@@ -17238,7 +17238,7 @@ innodb_max_dirty_pages_pct_lwm_update( ...@@ -17238,7 +17238,7 @@ innodb_max_dirty_pages_pct_lwm_update(
} }
srv_max_dirty_pages_pct_lwm = in_val; srv_max_dirty_pages_pct_lwm = in_val;
mysql_cond_signal(&buf_pool.do_flush_list); pthread_cond_signal(&buf_pool.do_flush_list);
} }
/*************************************************************//** /*************************************************************//**
......
...@@ -1795,11 +1795,11 @@ class buf_pool_t ...@@ -1795,11 +1795,11 @@ class buf_pool_t
/** Number of pending LRU flush. */ /** Number of pending LRU flush. */
Atomic_counter<ulint> n_flush_LRU; Atomic_counter<ulint> n_flush_LRU;
/** broadcast when n_flush_LRU reaches 0; protected by mutex */ /** broadcast when n_flush_LRU reaches 0; protected by mutex */
mysql_cond_t done_flush_LRU; pthread_cond_t done_flush_LRU;
/** Number of pending flush_list flush. */ /** Number of pending flush_list flush. */
Atomic_counter<ulint> n_flush_list; Atomic_counter<ulint> n_flush_list;
/** broadcast when n_flush_list reaches 0; protected by mutex */ /** broadcast when n_flush_list reaches 0; protected by mutex */
mysql_cond_t done_flush_list; pthread_cond_t done_flush_list;
/** @name General fields */ /** @name General fields */
/* @{ */ /* @{ */
...@@ -1948,7 +1948,7 @@ class buf_pool_t ...@@ -1948,7 +1948,7 @@ class buf_pool_t
bool page_cleaner_is_idle; bool page_cleaner_is_idle;
public: public:
/** signalled to wake up the page_cleaner; protected by flush_list_mutex */ /** signalled to wake up the page_cleaner; protected by flush_list_mutex */
mysql_cond_t do_flush_list; pthread_cond_t do_flush_list;
/** @return whether the page cleaner must sleep due to being idle */ /** @return whether the page cleaner must sleep due to being idle */
bool page_cleaner_idle() const bool page_cleaner_idle() const
......
...@@ -61,7 +61,7 @@ class buf_dblwr_t ...@@ -61,7 +61,7 @@ class buf_dblwr_t
/** mutex protecting the data members below */ /** mutex protecting the data members below */
mysql_mutex_t mutex; mysql_mutex_t mutex;
/** condition variable for !batch_running */ /** condition variable for !batch_running */
mysql_cond_t cond; pthread_cond_t cond;
/** whether a batch is being written from the doublewrite buffer */ /** whether a batch is being written from the doublewrite buffer */
bool batch_running; bool batch_running;
/** number of expected flush_buffered_writes_completed() calls */ /** number of expected flush_buffered_writes_completed() calls */
...@@ -160,7 +160,7 @@ class buf_dblwr_t ...@@ -160,7 +160,7 @@ class buf_dblwr_t
{ {
mysql_mutex_lock(&mutex); mysql_mutex_lock(&mutex);
while (batch_running) while (batch_running)
mysql_cond_wait(&cond, &mutex); my_cond_wait(&cond, &mutex.m_mutex);
mysql_mutex_unlock(&mutex); mysql_mutex_unlock(&mutex);
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Google Inc. Copyright (c) 2009, Google Inc.
Copyright (c) 2014, 2020, MariaDB Corporation. Copyright (c) 2014, 2021, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described Google, Inc. Those modifications are gratefully acknowledged and are described
...@@ -1086,7 +1086,7 @@ ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown() ...@@ -1086,7 +1086,7 @@ ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown()
if (buf_page_cleaner_is_active) { if (buf_page_cleaner_is_active) {
thread_name = "page cleaner thread"; thread_name = "page cleaner thread";
mysql_cond_signal(&buf_pool.do_flush_list); pthread_cond_signal(&buf_pool.do_flush_list);
goto wait_suspend_loop; goto wait_suspend_loop;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2008, Google Inc. Copyright (c) 2008, Google Inc.
Copyright (c) 2009, Percona Inc. Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, 2020, MariaDB Corporation. Copyright (c) 2013, 2021, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described Google, Inc. Those modifications are gratefully acknowledged and are described
...@@ -2017,9 +2017,9 @@ void innodb_shutdown() ...@@ -2017,9 +2017,9 @@ void innodb_shutdown()
} }
mysql_mutex_lock(&buf_pool.flush_list_mutex); mysql_mutex_lock(&buf_pool.flush_list_mutex);
while (buf_page_cleaner_is_active) { while (buf_page_cleaner_is_active) {
mysql_cond_signal(&buf_pool.do_flush_list); pthread_cond_signal(&buf_pool.do_flush_list);
mysql_cond_wait(&buf_pool.done_flush_list, my_cond_wait(&buf_pool.done_flush_list,
&buf_pool.flush_list_mutex); &buf_pool.flush_list_mutex.m_mutex);
} }
mysql_mutex_unlock(&buf_pool.flush_list_mutex); mysql_mutex_unlock(&buf_pool.flush_list_mutex);
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment