Skip to content

Commit

Permalink
MDEV-23399 fixup: Use plain pthread_cond
Browse files Browse the repository at this point in the history
The condition variables that were introduced in
commit 7cffb5f (MDEV-23399)
are never instrumented with PERFORMANCE_SCHEMA.
Let us avoid the storage overhead and dead code.
  • Loading branch information
dr-m committed Feb 7, 2021
1 parent 7ce6437 commit 4f4a4cf
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 47 deletions.
20 changes: 10 additions & 10 deletions storage/innobase/buf/buf0buf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -3694,8 +3694,8 @@ buf_page_create(fil_space_t *space, uint32_t offset,
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);
}
Expand All @@ -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. */
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;
}

Expand Down
10 changes: 5 additions & 5 deletions storage/innobase/buf/buf0dblwr.cc
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
40 changes: 21 additions & 19 deletions storage/innobase/buf/buf0flu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -2095,10 +2096,11 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*)
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);

Expand All @@ -2120,7 +2122,7 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*)
{
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);
Expand Down Expand Up @@ -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);
/* 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)
Expand Down Expand Up @@ -2233,7 +2235,7 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*)
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();
Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/*************************************************************//**
Expand Down
6 changes: 3 additions & 3 deletions storage/innobase/include/buf0buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1795,11 +1795,11 @@ class buf_pool_t
/** 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 */
/* @{ */
Expand Down Expand Up @@ -1948,7 +1948,7 @@ class buf_pool_t
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
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/include/buf0dblwr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -160,7 +160,7 @@ class buf_dblwr_t
{
mysql_mutex_lock(&mutex);
while (batch_running)
mysql_cond_wait(&cond, &mutex);
my_cond_wait(&cond, &mutex.m_mutex);
mysql_mutex_unlock(&mutex);
}
}
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1086,7 +1086,7 @@ ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown()

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;
}

Expand Down
8 changes: 4 additions & 4 deletions storage/innobase/srv/srv0start.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4f4a4cf

Please sign in to comment.