summaryrefslogtreecommitdiff
path: root/innobase/sync/sync0sync.c
diff options
context:
space:
mode:
authormonty@mishka.local <>2004-04-26 15:53:31 +0300
committermonty@mishka.local <>2004-04-26 15:53:31 +0300
commit21fd1d270eb58fa95551bb6e37ecef5a30785929 (patch)
tree25e3315af05fa92d20d2ad1d812882957c400337 /innobase/sync/sync0sync.c
parent7d9a9fd93ac4622d596920169a6d6afbd787c377 (diff)
parent7d3e633edc5db31c0698660ed644d7a18faea41c (diff)
downloadmariadb-git-21fd1d270eb58fa95551bb6e37ecef5a30785929.tar.gz
Merge with 4.0
Diffstat (limited to 'innobase/sync/sync0sync.c')
-rw-r--r--innobase/sync/sync0sync.c102
1 files changed, 59 insertions, 43 deletions
diff --git a/innobase/sync/sync0sync.c b/innobase/sync/sync0sync.c
index 64f76f5ee77..5c42876a7bb 100644
--- a/innobase/sync/sync0sync.c
+++ b/innobase/sync/sync0sync.c
@@ -168,6 +168,30 @@ struct sync_level_struct{
};
/**********************************************************************
+A noninlined function that reserves a mutex. In ha_innodb.cc we have disabled
+inlining of InnoDB functions, and no inlined functions should be called from
+there. That is why we need to duplicate the inlined function here. */
+
+void
+mutex_enter_noninline(
+/*==================*/
+ mutex_t* mutex) /* in: mutex */
+{
+ mutex_enter(mutex);
+}
+
+/**********************************************************************
+Releases a mutex. */
+
+void
+mutex_exit_noninline(
+/*=================*/
+ mutex_t* mutex) /* in: mutex */
+{
+ mutex_exit(mutex);
+}
+
+/**********************************************************************
Creates, or rather, initializes a mutex object in a specified memory
location (which must be appropriately aligned). The mutex is initialized
in the reset state. Explicit freeing of the mutex with mutex_free is
@@ -288,6 +312,7 @@ mutex_enter_nowait(
return(1);
}
+#ifdef UNIV_DEBUG
/**********************************************************************
Checks that the mutex has been initialized. */
@@ -301,6 +326,7 @@ mutex_validate(
return(TRUE);
}
+#endif /* UNIV_DEBUG */
/**********************************************************************
Sets the waiters field in a mutex. */
@@ -365,9 +391,9 @@ spin_loop:
}
if (srv_print_latch_waits) {
- printf(
- "Thread %lu spin wait mutex at %lx cfile %s cline %lu rnds %lu\n",
- (ulong) os_thread_pf(os_thread_get_curr_id()), (ulong) mutex,
+ fprintf(stderr,
+ "Thread %lu spin wait mutex at %p cfile %s cline %lu rnds %lu\n",
+ (ulong) os_thread_pf(os_thread_get_curr_id()), mutex,
mutex->cfile_name, (ulong) mutex->cline, (ulong) i);
}
@@ -425,10 +451,11 @@ spin_loop:
#endif
if (srv_print_latch_waits) {
- printf(
- "Thread %lu spin wait succeeds at 2: mutex at %lx\n",
+ fprintf(stderr,
+ "Thread %lu spin wait succeeds at 2:"
+ " mutex at %p\n",
(ulong) os_thread_pf(os_thread_get_curr_id()),
- (ulong) mutex);
+ mutex);
}
return;
@@ -444,9 +471,9 @@ spin_loop:
Now there is no risk of infinite wait on the event. */
if (srv_print_latch_waits) {
- printf(
- "Thread %lu OS wait mutex at %lx cfile %s cline %lu rnds %lu\n",
- (ulong) os_thread_pf(os_thread_get_curr_id()), (ulong) mutex,
+ fprintf(stderr,
+ "Thread %lu OS wait mutex at %p cfile %s cline %lu rnds %lu\n",
+ (ulong) os_thread_pf(os_thread_get_curr_id()), mutex,
mutex->cfile_name, (ulong) mutex->cline, (ulong) i);
}
@@ -566,9 +593,9 @@ mutex_list_print_info(void)
os_thread_id_t thread_id;
ulint count = 0;
- printf("----------\n");
- printf("MUTEX INFO\n");
- printf("----------\n");
+ fputs("----------\n"
+ "MUTEX INFO\n"
+ "----------\n", stderr);
mutex_enter(&mutex_list_mutex);
@@ -580,16 +607,16 @@ mutex_list_print_info(void)
if (mutex_get_lock_word(mutex) != 0) {
mutex_get_debug_info(mutex, &file_name, &line,
&thread_id);
- printf(
- "Locked mutex: addr %lx thread %ld file %s line %ld\n",
- (ulint)mutex, os_thread_pf(thread_id),
+ fprintf(stderr,
+ "Locked mutex: addr %p thread %ld file %s line %ld\n",
+ mutex, os_thread_pf(thread_id),
file_name, line);
}
mutex = UT_LIST_GET_NEXT(list, mutex);
}
- printf("Total number of mutexes %ld\n", count);
+ fprintf(stderr, "Total number of mutexes %ld\n", count);
mutex_exit(&mutex_list_mutex);
}
@@ -747,12 +774,14 @@ sync_thread_levels_g(
lock = slot->latch;
mutex = slot->latch;
- printf(
+ fprintf(stderr,
"InnoDB error: sync levels should be > %lu but a level is %lu\n",
(ulong) limit, (ulong) slot->level);
if (mutex->magic_n == MUTEX_MAGIC_N) {
- printf("Mutex created at %s %lu\n", mutex->cfile_name,
+ fprintf(stderr,
+ "Mutex created at %s %lu\n",
+ mutex->cfile_name,
(ulong) mutex->cline);
if (mutex_get_lock_word(mutex) != 0) {
@@ -833,9 +862,6 @@ sync_thread_levels_empty_gen(
sync_level_t* arr;
sync_thread_t* thread_slot;
sync_level_t* slot;
- rw_lock_t* lock;
- mutex_t* mutex;
- char* buf;
ulint i;
if (!sync_order_checks_on) {
@@ -864,13 +890,7 @@ sync_thread_levels_empty_gen(
(slot->level != SYNC_DICT
&& slot->level != SYNC_DICT_OPERATION))) {
- lock = slot->latch;
- mutex = slot->latch;
mutex_exit(&sync_thread_mutex);
-
- buf = mem_alloc(20000);
-
- sync_print(buf, buf + 18000);
ut_error;
return(FALSE);
@@ -1054,8 +1074,12 @@ sync_thread_add_level(
} else if (level == SYNC_DICT_HEADER) {
ut_a(sync_thread_levels_g(array, SYNC_DICT_HEADER));
} else if (level == SYNC_DICT) {
- ut_a(buf_debug_prints
- || sync_thread_levels_g(array, SYNC_DICT));
+#ifdef UNIV_DEBUG
+ ut_a(buf_debug_prints ||
+ sync_thread_levels_g(array, SYNC_DICT));
+#else /* UNIV_DEBUG */
+ ut_a(sync_thread_levels_g(array, SYNC_DICT));
+#endif /* UNIV_DEBUG */
} else {
ut_error;
}
@@ -1225,19 +1249,14 @@ Prints wait info of the sync system. */
void
sync_print_wait_info(
/*=================*/
- char* buf, /* in/out: buffer where to print */
- char* buf_end) /* in: buffer end */
+ FILE* file) /* in: file where to print */
{
#ifdef UNIV_SYNC_DEBUG
- printf("Mutex exits %lu, rws exits %lu, rwx exits %lu\n",
+ fprintf(stderr, "Mutex exits %lu, rws exits %lu, rwx exits %lu\n",
mutex_exit_count, rw_s_exit_count, rw_x_exit_count);
#endif
- if (buf_end - buf < 500) {
- return;
- }
-
- sprintf(buf,
+ fprintf(file,
"Mutex spin waits %lu, rounds %lu, OS waits %lu\n"
"RW-shared spins %lu, OS waits %lu; RW-excl spins %lu, OS waits %lu\n",
(ulong) mutex_spin_wait_count,
@@ -1255,8 +1274,7 @@ Prints info of the sync system. */
void
sync_print(
/*=======*/
- char* buf, /* in/out: buffer where to print */
- char* buf_end) /* in: buffer end */
+ FILE* file) /* in: file where to print */
{
#ifdef UNIV_SYNC_DEBUG
mutex_list_print_info();
@@ -1264,9 +1282,7 @@ sync_print(
rw_lock_list_print_info();
#endif /* UNIV_SYNC_DEBUG */
- sync_array_print_info(buf, buf_end, sync_primary_wait_array);
-
- buf = buf + strlen(buf);
+ sync_array_print_info(file, sync_primary_wait_array);
- sync_print_wait_info(buf, buf_end);
+ sync_print_wait_info(file);
}