diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-02-07 12:19:24 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-02-07 12:19:24 +0200 |
commit | 4f4a4cf9eb10fe29fb79a8321a5661d679659dec (patch) | |
tree | a0939ab32bfa6ae1c3f7fb2e471daf1461dbfa97 | |
parent | 7ce643782ba32dda0c9e5cc98efa55d0ab48cb03 (diff) | |
download | mariadb-git-4f4a4cf9eb10fe29fb79a8321a5661d679659dec.tar.gz |
MDEV-23399 fixup: Use plain pthread_cond
The condition variables that were introduced in
commit 7cffb5f6e8a231a041152447be8980ce35d2c9b8 (MDEV-23399)
are never instrumented with PERFORMANCE_SCHEMA.
Let us avoid the storage overhead and dead code.
-rw-r--r-- | storage/innobase/buf/buf0buf.cc | 20 | ||||
-rw-r--r-- | storage/innobase/buf/buf0dblwr.cc | 10 | ||||
-rw-r--r-- | storage/innobase/buf/buf0flu.cc | 40 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 4 | ||||
-rw-r--r-- | storage/innobase/include/buf0buf.h | 6 | ||||
-rw-r--r-- | storage/innobase/include/buf0dblwr.h | 4 | ||||
-rw-r--r-- | storage/innobase/log/log0log.cc | 4 | ||||
-rw-r--r-- | storage/innobase/srv/srv0start.cc | 8 |
8 files changed, 49 insertions, 47 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index e740db82d38..d531be43a8b 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1462,9 +1462,9 @@ bool buf_pool_t::create() mysql_mutex_init(flush_list_mutex_key, &flush_list_mutex, MY_MUTEX_INIT_FAST); - mysql_cond_init(0, &done_flush_LRU, nullptr); - mysql_cond_init(0, &done_flush_list, nullptr); - mysql_cond_init(0, &do_flush_list, nullptr); + pthread_cond_init(&done_flush_LRU, nullptr); + pthread_cond_init(&done_flush_list, nullptr); + pthread_cond_init(&do_flush_list, nullptr); try_LRU_scan= true; @@ -1525,9 +1525,9 @@ void buf_pool_t::close() allocator.deallocate_large_dodump(chunk->mem, &chunk->mem_pfx); } - mysql_cond_destroy(&done_flush_LRU); - mysql_cond_destroy(&done_flush_list); - mysql_cond_destroy(&do_flush_list); + pthread_cond_destroy(&done_flush_LRU); + pthread_cond_destroy(&done_flush_list); + pthread_cond_destroy(&do_flush_list); ut_free(chunks); chunks= nullptr; @@ -3694,8 +3694,8 @@ loop: We must not hold buf_pool.mutex while waiting. */ timespec abstime; set_timespec_nsec(abstime, 1000000); - mysql_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex, - &abstime); + my_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex.m_mutex, + &abstime); } mtr_memo_push(mtr, block, MTR_MEMO_PAGE_X_FIX); } @@ -3719,8 +3719,8 @@ loop: /* Wait for buf_page_write_complete() to release the I/O fix. */ timespec abstime; set_timespec_nsec(abstime, 1000000); - mysql_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex, - &abstime); + my_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex.m_mutex, + &abstime); goto loop; } diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 6a4a6ced074..afaa02e7ab1 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -1,7 +1,7 @@ /***************************************************************************** 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 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) ut_ad(!batch_running); 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)); block2= page_id_t(0, mach_read_from_4(header + TRX_SYS_DOUBLEWRITE_BLOCK2)); @@ -452,7 +452,7 @@ void buf_dblwr_t::close() ut_ad(!active_slot->first_free); ut_ad(!batch_running); - mysql_cond_destroy(&cond); + pthread_cond_destroy(&cond); for (int i= 0; i < 2; i++) { aligned_free(slots[i].write_buf); @@ -489,7 +489,7 @@ void buf_dblwr_t::write_completed() /* We can now reuse the doublewrite memory buffer: */ flush_slot->first_free= 0; batch_running= false; - mysql_cond_broadcast(&cond); + pthread_cond_broadcast(&cond); } mysql_mutex_unlock(&mutex); @@ -566,7 +566,7 @@ bool buf_dblwr_t::flush_buffered_writes(const ulint size) return false; if (!batch_running) break; - mysql_cond_wait(&cond, &mutex); + my_cond_wait(&cond, &mutex.m_mutex); } ut_ad(active_slot->reserved == active_slot->first_free); diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 934feadb437..21a01dbd2fe 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -138,7 +138,7 @@ inline void buf_pool_t::page_cleaner_wakeup() srv_max_buf_pool_modified_pct <= dirty_pct) { 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) { buf_LRU_free_page(bpage, true); if (!--buf_pool.n_flush_LRU) - mysql_cond_broadcast(&buf_pool.done_flush_LRU); + pthread_cond_broadcast(&buf_pool.done_flush_LRU); } else { 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); @@ -1512,11 +1512,11 @@ void buf_flush_wait_batch_end(bool lru) tpool::tpool_wait_begin(); thd_wait_begin(nullptr, THD_WAIT_DISKIO); do - mysql_cond_wait(cond, &buf_pool.mutex); + my_cond_wait(cond, &buf_pool.mutex.m_mutex); while (n_flush); tpool::tpool_wait_end(); 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) if (running || (lsn && !UT_LIST_GET_LEN(buf_pool.flush_list))) { if (!running) - mysql_cond_broadcast(cond); + pthread_cond_broadcast(cond); mysql_mutex_unlock(&buf_pool.mutex); return 0; } @@ -1588,7 +1588,7 @@ ulint buf_flush_lists(ulint max_n, lsn_t lsn) mysql_mutex_unlock(&buf_pool.mutex); if (!n_flushing) - mysql_cond_broadcast(cond); + pthread_cond_broadcast(cond); buf_dblwr.flush_buffered_writes(); @@ -1749,14 +1749,15 @@ ATTRIBUTE_COLD void buf_flush_wait_flushed(lsn_t sync_lsn) if (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 { tpool::tpool_wait_begin(); 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); tpool::tpool_wait_end(); @@ -1788,7 +1789,7 @@ void buf_flush_ahead(lsn_t lsn) if (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); } @@ -1866,7 +1867,7 @@ ATTRIBUTE_COLD static void buf_flush_sync_for_checkpoint(lsn_t lsn) buf_flush_sync_lsn= 0; /* 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); @@ -2095,10 +2096,11 @@ furious_flush: break; 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 - mysql_cond_timedwait(&buf_pool.do_flush_list, &buf_pool.flush_list_mutex, - &abstime); + my_cond_timedwait(&buf_pool.do_flush_list, + &buf_pool.flush_list_mutex.m_mutex, &abstime); set_timespec(abstime, 1); @@ -2120,7 +2122,7 @@ furious_flush: { buf_flush_sync_lsn= 0; /* wake up buf_flush_wait_flushed() */ - mysql_cond_broadcast(&buf_pool.done_flush_list); + pthread_cond_broadcast(&buf_pool.done_flush_list); } unemployed: buf_pool.page_cleaner_set_idle(true); @@ -2156,7 +2158,7 @@ unemployed: { n_flushed= buf_flush_lists(srv_max_io_capacity, lsn_limit); /* 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; } else if (!srv_adaptive_flushing) @@ -2233,7 +2235,7 @@ next: if (UNIV_UNLIKELY(lsn_limit != 0)) goto furious_flush; 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); my_thread_end(); @@ -2287,8 +2289,8 @@ ATTRIBUTE_COLD void buf_flush_buffer_pool() set_timespec(abstime, INNODB_EXTEND_TIMEOUT_INTERVAL / 2); mysql_mutex_lock(&buf_pool.mutex); while (buf_pool.n_flush_list) - mysql_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex, - &abstime); + my_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex.m_mutex, + &abstime); mysql_mutex_unlock(&buf_pool.mutex); } } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 0aad1347435..e72b307854d 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -17204,7 +17204,7 @@ innodb_max_dirty_pages_pct_update( 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; @@ -17238,7 +17238,7 @@ innodb_max_dirty_pages_pct_lwm_update( } srv_max_dirty_pages_pct_lwm = in_val; - mysql_cond_signal(&buf_pool.do_flush_list); + pthread_cond_signal(&buf_pool.do_flush_list); } /*************************************************************//** diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index c4254f911dc..12fb139f1bf 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1795,11 +1795,11 @@ public: /** Number of pending LRU flush. */ Atomic_counter<ulint> n_flush_LRU; /** 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. */ Atomic_counter<ulint> n_flush_list; /** 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 */ /* @{ */ @@ -1948,7 +1948,7 @@ private: bool page_cleaner_is_idle; public: /** 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 */ bool page_cleaner_idle() const diff --git a/storage/innobase/include/buf0dblwr.h b/storage/innobase/include/buf0dblwr.h index e95f2844fdc..fb9df55504c 100644 --- a/storage/innobase/include/buf0dblwr.h +++ b/storage/innobase/include/buf0dblwr.h @@ -61,7 +61,7 @@ class buf_dblwr_t /** mutex protecting the data members below */ mysql_mutex_t mutex; /** condition variable for !batch_running */ - mysql_cond_t cond; + pthread_cond_t cond; /** whether a batch is being written from the doublewrite buffer */ bool batch_running; /** number of expected flush_buffered_writes_completed() calls */ @@ -160,7 +160,7 @@ public: { mysql_mutex_lock(&mutex); while (batch_running) - mysql_cond_wait(&cond, &mutex); + my_cond_wait(&cond, &mutex.m_mutex); mysql_mutex_unlock(&mutex); } } diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index be1a341d9e5..6dfeec0f925 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. 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 Google, Inc. Those modifications are gratefully acknowledged and are described @@ -1086,7 +1086,7 @@ wait_suspend_loop: if (buf_page_cleaner_is_active) { 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; } diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index b0bc3d3ede9..a3678e20955 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -3,7 +3,7 @@ Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2008, Google 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 Google, Inc. Those modifications are gratefully acknowledged and are described @@ -2017,9 +2017,9 @@ void innodb_shutdown() } mysql_mutex_lock(&buf_pool.flush_list_mutex); while (buf_page_cleaner_is_active) { - mysql_cond_signal(&buf_pool.do_flush_list); - mysql_cond_wait(&buf_pool.done_flush_list, - &buf_pool.flush_list_mutex); + pthread_cond_signal(&buf_pool.do_flush_list); + my_cond_wait(&buf_pool.done_flush_list, + &buf_pool.flush_list_mutex.m_mutex); } mysql_mutex_unlock(&buf_pool.flush_list_mutex); break; |