140 UNIV_INTERN rw_lock_list_t rw_lock_list;
143 #ifdef UNIV_PFS_MUTEX
144 UNIV_INTERN mysql_pfs_key_t rw_lock_list_mutex_key;
145 UNIV_INTERN mysql_pfs_key_t rw_lock_mutex_key;
148 #ifdef UNIV_SYNC_DEBUG
155 # ifdef UNIV_PFS_MUTEX
156 UNIV_INTERN mysql_pfs_key_t rw_lock_debug_mutex_key;
163 UNIV_INTERN ibool rw_lock_debug_waiters;
169 rw_lock_debug_create(
void);
177 rw_lock_debug_t* info);
184 rw_lock_debug_create(
void)
187 return((rw_lock_debug_t*) mem_alloc(
sizeof(rw_lock_debug_t)));
196 rw_lock_debug_t* info)
213 # ifdef UNIV_SYNC_DEBUG
216 const char* cmutex_name,
218 const char* cfile_name,
224 #ifndef INNODB_RW_LOCKS_USE_ATOMICS
225 mutex_create(rw_lock_mutex_key, rw_lock_get_mutex(lock),
226 SYNC_NO_ORDER_CHECK);
231 ut_d(lock->
mutex.cmutex_name = cmutex_name);
250 #ifdef UNIV_SYNC_DEBUG
256 ut_d(lock->magic_n = RW_LOCK_MAGIC_N);
259 lock->
cline = (
unsigned int) cline;
269 mutex_enter(&rw_lock_list_mutex);
276 mutex_exit(&rw_lock_list_mutex);
289 #ifndef INNODB_RW_LOCKS_USE_ATOMICS
293 ut_ad(rw_lock_validate(lock));
296 mutex_enter(&rw_lock_list_mutex);
298 #ifndef INNODB_RW_LOCKS_USE_ATOMICS
299 mutex = rw_lock_get_mutex(lock);
313 mutex_exit(&rw_lock_list_mutex);
315 ut_d(lock->magic_n = 0);
317 #ifndef INNODB_RW_LOCKS_USE_ATOMICS
343 ut_ad(lock->magic_n == RW_LOCK_MAGIC_N);
344 ut_ad(waiters == 0 || waiters == 1);
345 ut_ad(lock_word > -(2 * X_LOCK_DECR));
346 ut_ad(lock_word <= X_LOCK_DECR);
364 const char* file_name,
370 size_t counter_index;
377 ut_ad(rw_lock_validate(lock));
383 while (i < SYNC_SPIN_ROUNDS && lock->lock_word <= 0) {
384 if (srv_spin_wait_delay) {
411 sync_arr, lock, RW_LOCK_SHARED,
412 file_name, line, &index);
416 rw_lock_set_waiter_flag(lock);
462 #ifdef UNIV_SYNC_DEBUG
466 const char* file_name,
472 size_t counter_index;
482 if (srv_spin_wait_delay) {
496 sync_arr, lock, RW_LOCK_WAIT_EX,
497 file_name, line, &index);
511 #ifdef UNIV_SYNC_DEBUG
512 rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
517 #ifdef UNIV_SYNC_DEBUG
518 rw_lock_remove_debug_info(
519 lock, pass, RW_LOCK_WAIT_EX);
540 const char* file_name,
553 lock, pass ? FALSE : TRUE);
556 #ifdef UNIV_SYNC_DEBUG
579 #ifdef UNIV_SYNC_DEBUG
580 rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name, line);
604 const char* file_name,
610 ibool spinning = FALSE;
611 size_t counter_index;
618 ut_ad(rw_lock_validate(lock));
619 #ifdef UNIV_SYNC_DEBUG
620 ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED));
644 if (srv_spin_wait_delay) {
646 srv_spin_wait_delay));
663 sync_arr, lock, RW_LOCK_EX, file_name, line, &index);
667 rw_lock_set_waiter_flag(lock);
684 #ifdef UNIV_SYNC_DEBUG
693 rw_lock_debug_mutex_enter(
void)
697 if (0 == mutex_enter_nowait(&rw_lock_debug_mutex)) {
703 rw_lock_debug_waiters = TRUE;
705 if (0 == mutex_enter_nowait(&rw_lock_debug_mutex)) {
709 os_event_wait(rw_lock_debug_event);
718 rw_lock_debug_mutex_exit(
void)
721 mutex_exit(&rw_lock_debug_mutex);
723 if (rw_lock_debug_waiters) {
724 rw_lock_debug_waiters = FALSE;
733 rw_lock_add_debug_info(
738 const char* file_name,
741 rw_lock_debug_t* info;
746 info = rw_lock_debug_create();
748 rw_lock_debug_mutex_enter();
750 info->file_name = file_name;
752 info->lock_type = lock_type;
758 rw_lock_debug_mutex_exit();
760 if ((pass == 0) && (lock_type != RW_LOCK_WAIT_EX)) {
761 sync_thread_add_level(lock, lock->level,
762 lock_type == RW_LOCK_EX
771 rw_lock_remove_debug_info(
777 rw_lock_debug_t* info;
781 if ((pass == 0) && (lock_type != RW_LOCK_WAIT_EX)) {
782 sync_thread_reset_level(lock);
785 rw_lock_debug_mutex_enter();
789 while (info != NULL) {
790 if ((pass == info->pass)
794 && (info->lock_type == lock_type)) {
798 rw_lock_debug_mutex_exit();
800 rw_lock_debug_free(info);
812 #ifdef UNIV_SYNC_DEBUG
825 rw_lock_debug_t* info;
828 ut_ad(rw_lock_validate(lock));
830 rw_lock_debug_mutex_enter();
834 while (info != NULL) {
838 && (info->lock_type == lock_type)) {
840 rw_lock_debug_mutex_exit();
848 rw_lock_debug_mutex_exit();
868 ut_ad(rw_lock_validate(lock));
870 if (lock_type == RW_LOCK_SHARED) {
874 }
else if (lock_type == RW_LOCK_EX) {
885 #ifdef UNIV_SYNC_DEBUG
890 rw_lock_list_print_info(
896 rw_lock_debug_t* info;
898 mutex_enter(&rw_lock_list_mutex);
900 fputs(
"-------------\n"
902 "-------------\n", file);
906 while (lock != NULL) {
910 #ifndef INNODB_RW_LOCKS_USE_ATOMICS
911 mutex_enter(&(lock->
mutex));
915 fprintf(file,
"RW-LOCK: %p ", (
void*) lock);
918 fputs(
" Waiters for the lock exist\n", file);
923 rw_lock_debug_mutex_enter();
925 while (info != NULL) {
926 rw_lock_debug_print(file, info);
929 rw_lock_debug_mutex_exit();
931 #ifndef INNODB_RW_LOCKS_USE_ATOMICS
932 mutex_exit(&(lock->
mutex));
938 fprintf(file,
"Total number of rw-locks %ld\n", count);
939 mutex_exit(&rw_lock_list_mutex);
950 rw_lock_debug_t* info;
955 "RW-LATCH: %p ", (
void*) lock);
957 #ifndef INNODB_RW_LOCKS_USE_ATOMICS
968 fputs(
" Waiters for the lock exist\n", stderr);
973 rw_lock_debug_mutex_enter();
975 while (info != NULL) {
976 rw_lock_debug_print(stderr, info);
979 rw_lock_debug_mutex_exit();
990 rw_lock_debug_t* info)
994 rwt = info->lock_type;
996 fprintf(f,
"Locked: thread %lu file %s line %lu ",
999 if (rwt == RW_LOCK_SHARED) {
1001 }
else if (rwt == RW_LOCK_EX) {
1003 }
else if (rwt == RW_LOCK_WAIT_EX) {
1004 fputs(
"WAIT X-LOCK", f);
1008 if (info->pass != 0) {
1009 fprintf(f,
" pass value %lu", (ulong) info->pass);
1020 rw_lock_n_locked(
void)
1026 mutex_enter(&rw_lock_list_mutex);
1030 while (lock != NULL) {
1039 mutex_exit(&rw_lock_list_mutex);