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(
{
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;
uint hton_name_len = (uint) strlen(innobase_hton_name);
......@@ -16396,36 +16396,34 @@ innodb_show_rwlock_status(
mutex_enter(&rw_lock_list_mutex);
for (rw_lock_t* rw_lock = UT_LIST_GET_FIRST(rw_lock_list);
rw_lock != NULL;
rw_lock = UT_LIST_GET_NEXT(list, rw_lock)) {
for (const rw_lock_t& rw_lock : rw_lock_list) {
if (rw_lock->count_os_wait == 0) {
if (rw_lock.count_os_wait == 0) {
continue;
}
int buf1len;
char buf1[IO_SIZE];
if (rw_lock->is_block_lock) {
if (rw_lock.is_block_lock) {
block_rwlock = rw_lock;
block_rwlock_oswait_count += rw_lock->count_os_wait;
block_rwlock = &rw_lock;
block_rwlock_oswait_count += rw_lock.count_os_wait;
continue;
}
buf1len = snprintf(
buf1, sizeof buf1, "rwlock: %s:%u",
innobase_basename(rw_lock->cfile_name),
rw_lock->cline);
innobase_basename(rw_lock.cfile_name),
rw_lock.cline);
int buf2len;
char buf2[IO_SIZE];
buf2len = snprintf(
buf2, sizeof buf2, "waits=%u",
rw_lock->count_os_wait);
rw_lock.count_os_wait);
if (stat_print(thd, innobase_hton_name,
hton_name_len,
......
......@@ -7165,9 +7165,8 @@ i_s_innodb_mutexes_fill_table(
TABLE_LIST* tables, /*!< in/out: tables to fill */
Item* ) /*!< in: condition (not used) */
{
rw_lock_t* lock;
ulint block_lock_oswait_count = 0;
rw_lock_t* block_lock = NULL;
const rw_lock_t* block_lock= nullptr;
Field** fields = tables->table->field;
DBUG_ENTER("i_s_innodb_mutexes_fill_table");
......@@ -7210,32 +7209,31 @@ i_s_innodb_mutexes_fill_table(
char lock_name[sizeof "buf0dump.cc:12345"];
for (lock = UT_LIST_GET_FIRST(rw_lock_list); lock != NULL;
lock = UT_LIST_GET_NEXT(list, lock)) {
if (lock->count_os_wait == 0) {
for (const rw_lock_t& lock : rw_lock_list) {
if (lock.count_os_wait == 0) {
continue;
}
if (buf_pool.is_block_lock(lock)) {
block_lock = lock;
block_lock_oswait_count += lock->count_os_wait;
if (buf_pool.is_block_lock(&lock)) {
block_lock = &lock;
block_lock_oswait_count += lock.count_os_wait;
continue;
}
const char* basename = innobase_basename(
lock->cfile_name);
lock.cfile_name);
snprintf(lock_name, sizeof lock_name, "%s:%u",
basename, lock->cline);
basename, lock.cline);
OK(field_store_string(fields[MUTEXES_NAME],
lock_name));
OK(field_store_string(fields[MUTEXES_CREATE_FILE],
basename));
OK(fields[MUTEXES_CREATE_LINE]->store(lock->cline,
OK(fields[MUTEXES_CREATE_LINE]->store(lock.cline,
true));
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));
fields[MUTEXES_OS_WAITS]->set_notnull();
OK(schema_table_store_record(thd, tables->table));
......
......@@ -36,6 +36,7 @@ Created 9/11/1995 Heikki Tuuri
#include "os0event.h"
#include "ut0mutex.h"
#include "ilist.h"
/** Counters for RW locks. */
struct rw_lock_stats_t {
......@@ -105,9 +106,7 @@ struct rw_lock_t;
struct rw_lock_debug_t;
#endif /* UNIV_DEBUG */
typedef UT_LIST_BASE_NODE_T(rw_lock_t) rw_lock_list_t;
extern rw_lock_list_t rw_lock_list;
extern ilist<rw_lock_t> rw_lock_list;
extern ib_mutex_t rw_lock_list_mutex;
/** Counters for RW locks. */
......@@ -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
exit. */
struct rw_lock_t
struct rw_lock_t :
#ifdef UNIV_DEBUG
: public latch_t
public latch_t,
#endif /* UNIV_DEBUG */
public ilist_node<>
{
/** Holds the state of the lock. */
Atomic_relaxed<int32_t> lock_word;
......@@ -615,9 +615,6 @@ struct rw_lock_t
/** Count of os_waits. May not be accurate */
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
/** The instrumentation hook */
struct PSI_rwlock* pfs_psi;
......
......@@ -1682,9 +1682,7 @@ sync_check_init()
sync_latch_meta_init();
/* Init the rw-lock & mutex list and create the mutex to protect it. */
UT_LIST_INIT(rw_lock_list, &rw_lock_t::list);
/* create the mutex to protect rw_lock list. */
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
rw_lock_stats_t rw_lock_stats;
/* 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;
#ifdef UNIV_DEBUG
......@@ -235,7 +235,7 @@ rw_lock_create_func(
lock->is_block_lock = 0;
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);
}
......@@ -257,7 +257,7 @@ rw_lock_free_func(
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);
}
......@@ -1095,17 +1095,15 @@ rw_lock_list_print_info(
"RW-LATCH INFO\n"
"-------------\n", file);
for (const rw_lock_t* lock = UT_LIST_GET_FIRST(rw_lock_list);
lock != NULL;
lock = UT_LIST_GET_NEXT(list, lock)) {
for (const rw_lock_t& lock : rw_lock_list) {
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);
} else {
putc('\n', file);
......@@ -1115,7 +1113,7 @@ rw_lock_list_print_info(
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 = UT_LIST_GET_NEXT(list, info)) {
......
......@@ -257,11 +257,8 @@ MutexMonitor::reset()
mutex_enter(&rw_lock_list_mutex);
for (rw_lock_t* rw_lock = UT_LIST_GET_FIRST(rw_lock_list);
rw_lock != NULL;
rw_lock = UT_LIST_GET_NEXT(list, rw_lock)) {
rw_lock->count_os_wait = 0;
for (rw_lock_t& rw_lock : rw_lock_list) {
rw_lock.count_os_wait = 0;
}
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