Commit 1ae008d2 authored by Eugene Kosov's avatar Eugene Kosov

replace UT_LIST with ilist in rw_lock_list_t

parent ee584137
...@@ -16388,7 +16388,7 @@ innodb_show_rwlock_status( ...@@ -16388,7 +16388,7 @@ innodb_show_rwlock_status(
{ {
DBUG_ENTER("innodb_show_rwlock_status"); DBUG_ENTER("innodb_show_rwlock_status");
rw_lock_t* block_rwlock = NULL; const rw_lock_t* block_rwlock= nullptr;
ulint block_rwlock_oswait_count = 0; ulint block_rwlock_oswait_count = 0;
uint hton_name_len = (uint) strlen(innobase_hton_name); uint hton_name_len = (uint) strlen(innobase_hton_name);
...@@ -16396,36 +16396,34 @@ innodb_show_rwlock_status( ...@@ -16396,36 +16396,34 @@ innodb_show_rwlock_status(
mutex_enter(&rw_lock_list_mutex); mutex_enter(&rw_lock_list_mutex);
for (rw_lock_t* rw_lock = UT_LIST_GET_FIRST(rw_lock_list); for (const rw_lock_t& rw_lock : rw_lock_list) {
rw_lock != NULL;
rw_lock = UT_LIST_GET_NEXT(list, rw_lock)) {
if (rw_lock->count_os_wait == 0) { if (rw_lock.count_os_wait == 0) {
continue; continue;
} }
int buf1len; int buf1len;
char buf1[IO_SIZE]; char buf1[IO_SIZE];
if (rw_lock->is_block_lock) { if (rw_lock.is_block_lock) {
block_rwlock = rw_lock; block_rwlock = &rw_lock;
block_rwlock_oswait_count += rw_lock->count_os_wait; block_rwlock_oswait_count += rw_lock.count_os_wait;
continue; continue;
} }
buf1len = snprintf( buf1len = snprintf(
buf1, sizeof buf1, "rwlock: %s:%u", buf1, sizeof buf1, "rwlock: %s:%u",
innobase_basename(rw_lock->cfile_name), innobase_basename(rw_lock.cfile_name),
rw_lock->cline); rw_lock.cline);
int buf2len; int buf2len;
char buf2[IO_SIZE]; char buf2[IO_SIZE];
buf2len = snprintf( buf2len = snprintf(
buf2, sizeof buf2, "waits=%u", buf2, sizeof buf2, "waits=%u",
rw_lock->count_os_wait); rw_lock.count_os_wait);
if (stat_print(thd, innobase_hton_name, if (stat_print(thd, innobase_hton_name,
hton_name_len, hton_name_len,
......
...@@ -7165,9 +7165,8 @@ i_s_innodb_mutexes_fill_table( ...@@ -7165,9 +7165,8 @@ i_s_innodb_mutexes_fill_table(
TABLE_LIST* tables, /*!< in/out: tables to fill */ TABLE_LIST* tables, /*!< in/out: tables to fill */
Item* ) /*!< in: condition (not used) */ Item* ) /*!< in: condition (not used) */
{ {
rw_lock_t* lock;
ulint block_lock_oswait_count = 0; ulint block_lock_oswait_count = 0;
rw_lock_t* block_lock = NULL; const rw_lock_t* block_lock= nullptr;
Field** fields = tables->table->field; Field** fields = tables->table->field;
DBUG_ENTER("i_s_innodb_mutexes_fill_table"); DBUG_ENTER("i_s_innodb_mutexes_fill_table");
...@@ -7210,32 +7209,31 @@ i_s_innodb_mutexes_fill_table( ...@@ -7210,32 +7209,31 @@ i_s_innodb_mutexes_fill_table(
char lock_name[sizeof "buf0dump.cc:12345"]; char lock_name[sizeof "buf0dump.cc:12345"];
for (lock = UT_LIST_GET_FIRST(rw_lock_list); lock != NULL; for (const rw_lock_t& lock : rw_lock_list) {
lock = UT_LIST_GET_NEXT(list, lock)) { if (lock.count_os_wait == 0) {
if (lock->count_os_wait == 0) {
continue; continue;
} }
if (buf_pool.is_block_lock(lock)) { if (buf_pool.is_block_lock(&lock)) {
block_lock = lock; block_lock = &lock;
block_lock_oswait_count += lock->count_os_wait; block_lock_oswait_count += lock.count_os_wait;
continue; continue;
} }
const char* basename = innobase_basename( const char* basename = innobase_basename(
lock->cfile_name); lock.cfile_name);
snprintf(lock_name, sizeof lock_name, "%s:%u", snprintf(lock_name, sizeof lock_name, "%s:%u",
basename, lock->cline); basename, lock.cline);
OK(field_store_string(fields[MUTEXES_NAME], OK(field_store_string(fields[MUTEXES_NAME],
lock_name)); lock_name));
OK(field_store_string(fields[MUTEXES_CREATE_FILE], OK(field_store_string(fields[MUTEXES_CREATE_FILE],
basename)); basename));
OK(fields[MUTEXES_CREATE_LINE]->store(lock->cline, OK(fields[MUTEXES_CREATE_LINE]->store(lock.cline,
true)); true));
fields[MUTEXES_CREATE_LINE]->set_notnull(); fields[MUTEXES_CREATE_LINE]->set_notnull();
OK(fields[MUTEXES_OS_WAITS]->store(lock->count_os_wait, OK(fields[MUTEXES_OS_WAITS]->store(lock.count_os_wait,
true)); true));
fields[MUTEXES_OS_WAITS]->set_notnull(); fields[MUTEXES_OS_WAITS]->set_notnull();
OK(schema_table_store_record(thd, tables->table)); OK(schema_table_store_record(thd, tables->table));
......
...@@ -36,6 +36,7 @@ Created 9/11/1995 Heikki Tuuri ...@@ -36,6 +36,7 @@ Created 9/11/1995 Heikki Tuuri
#include "os0event.h" #include "os0event.h"
#include "ut0mutex.h" #include "ut0mutex.h"
#include "ilist.h"
/** Counters for RW locks. */ /** Counters for RW locks. */
struct rw_lock_stats_t { struct rw_lock_stats_t {
...@@ -105,9 +106,7 @@ struct rw_lock_t; ...@@ -105,9 +106,7 @@ struct rw_lock_t;
struct rw_lock_debug_t; struct rw_lock_debug_t;
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
typedef UT_LIST_BASE_NODE_T(rw_lock_t) rw_lock_list_t; extern ilist<rw_lock_t> rw_lock_list;
extern rw_lock_list_t rw_lock_list;
extern ib_mutex_t rw_lock_list_mutex; extern ib_mutex_t rw_lock_list_mutex;
/** Counters for RW locks. */ /** Counters for RW locks. */
...@@ -562,10 +561,11 @@ readers, a writer may queue for x-lock by decrementing lock_word: no ...@@ -562,10 +561,11 @@ readers, a writer may queue for x-lock by decrementing lock_word: no
new readers will be let in while the thread waits for readers to new readers will be let in while the thread waits for readers to
exit. */ exit. */
struct rw_lock_t struct rw_lock_t :
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
: public latch_t public latch_t,
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
public ilist_node<>
{ {
/** Holds the state of the lock. */ /** Holds the state of the lock. */
Atomic_relaxed<int32_t> lock_word; Atomic_relaxed<int32_t> lock_word;
...@@ -615,9 +615,6 @@ struct rw_lock_t ...@@ -615,9 +615,6 @@ struct rw_lock_t
/** Count of os_waits. May not be accurate */ /** Count of os_waits. May not be accurate */
uint32_t count_os_wait; uint32_t count_os_wait;
/** All allocated rw locks are put into a list */
UT_LIST_NODE_T(rw_lock_t) list;
#ifdef UNIV_PFS_RWLOCK #ifdef UNIV_PFS_RWLOCK
/** The instrumentation hook */ /** The instrumentation hook */
struct PSI_rwlock* pfs_psi; struct PSI_rwlock* pfs_psi;
......
...@@ -1682,9 +1682,7 @@ sync_check_init() ...@@ -1682,9 +1682,7 @@ sync_check_init()
sync_latch_meta_init(); sync_latch_meta_init();
/* Init the rw-lock & mutex list and create the mutex to protect it. */ /* create the mutex to protect rw_lock list. */
UT_LIST_INIT(rw_lock_list, &rw_lock_t::list);
mutex_create(LATCH_ID_RW_LOCK_LIST, &rw_lock_list_mutex); mutex_create(LATCH_ID_RW_LOCK_LIST, &rw_lock_list_mutex);
......
...@@ -141,7 +141,7 @@ wait_ex_event: A thread may only wait on the wait_ex_event after it has ...@@ -141,7 +141,7 @@ wait_ex_event: A thread may only wait on the wait_ex_event after it has
rw_lock_stats_t rw_lock_stats; rw_lock_stats_t rw_lock_stats;
/* The global list of rw-locks */ /* The global list of rw-locks */
rw_lock_list_t rw_lock_list; ilist<rw_lock_t> rw_lock_list;
ib_mutex_t rw_lock_list_mutex; ib_mutex_t rw_lock_list_mutex;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
...@@ -235,7 +235,7 @@ rw_lock_create_func( ...@@ -235,7 +235,7 @@ rw_lock_create_func(
lock->is_block_lock = 0; lock->is_block_lock = 0;
mutex_enter(&rw_lock_list_mutex); mutex_enter(&rw_lock_list_mutex);
UT_LIST_ADD_FIRST(rw_lock_list, lock); rw_lock_list.push_front(*lock);
mutex_exit(&rw_lock_list_mutex); mutex_exit(&rw_lock_list_mutex);
} }
...@@ -257,7 +257,7 @@ rw_lock_free_func( ...@@ -257,7 +257,7 @@ rw_lock_free_func(
os_event_destroy(lock->wait_ex_event); os_event_destroy(lock->wait_ex_event);
UT_LIST_REMOVE(rw_lock_list, lock); rw_lock_list.remove(*lock);
mutex_exit(&rw_lock_list_mutex); mutex_exit(&rw_lock_list_mutex);
} }
...@@ -1095,17 +1095,15 @@ rw_lock_list_print_info( ...@@ -1095,17 +1095,15 @@ rw_lock_list_print_info(
"RW-LATCH INFO\n" "RW-LATCH INFO\n"
"-------------\n", file); "-------------\n", file);
for (const rw_lock_t* lock = UT_LIST_GET_FIRST(rw_lock_list); for (const rw_lock_t& lock : rw_lock_list) {
lock != NULL;
lock = UT_LIST_GET_NEXT(list, lock)) {
count++; count++;
if (lock->lock_word != X_LOCK_DECR) { if (lock.lock_word != X_LOCK_DECR) {
fprintf(file, "RW-LOCK: %p ", (void*) lock); fprintf(file, "RW-LOCK: %p ", (void*) &lock);
if (int32_t waiters= lock->waiters) { if (int32_t waiters= lock.waiters) {
fprintf(file, " (%d waiters)\n", waiters); fprintf(file, " (%d waiters)\n", waiters);
} else { } else {
putc('\n', file); putc('\n', file);
...@@ -1115,7 +1113,7 @@ rw_lock_list_print_info( ...@@ -1115,7 +1113,7 @@ rw_lock_list_print_info(
rw_lock_debug_mutex_enter(); rw_lock_debug_mutex_enter();
for (info = UT_LIST_GET_FIRST(lock->debug_list); for (info = UT_LIST_GET_FIRST(lock.debug_list);
info != NULL; info != NULL;
info = UT_LIST_GET_NEXT(list, info)) { info = UT_LIST_GET_NEXT(list, info)) {
......
...@@ -257,11 +257,8 @@ MutexMonitor::reset() ...@@ -257,11 +257,8 @@ MutexMonitor::reset()
mutex_enter(&rw_lock_list_mutex); mutex_enter(&rw_lock_list_mutex);
for (rw_lock_t* rw_lock = UT_LIST_GET_FIRST(rw_lock_list); for (rw_lock_t& rw_lock : rw_lock_list) {
rw_lock != NULL; rw_lock.count_os_wait = 0;
rw_lock = UT_LIST_GET_NEXT(list, rw_lock)) {
rw_lock->count_os_wait = 0;
} }
mutex_exit(&rw_lock_list_mutex); mutex_exit(&rw_lock_list_mutex);
......
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