summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2017-05-12 23:26:59 (GMT)
committerQi Wang <interwq@gmail.com>2017-05-23 19:26:20 (GMT)
commit5f5ed2198e47f3e904cbf1aff7c124e196855272 (patch)
treeaabc4168f63175667d18ad58b4b5082f947f3961
parent2bee0c6251856f48ed6882df2f02a060c0a14829 (diff)
downloadjemalloc-5f5ed2198e47f3e904cbf1aff7c124e196855272.zip
jemalloc-5f5ed2198e47f3e904cbf1aff7c124e196855272.tar.gz
jemalloc-5f5ed2198e47f3e904cbf1aff7c124e196855272.tar.bz2
Add profiling for the background thread mutex.
-rw-r--r--include/jemalloc/internal/mutex_externs.h12
-rw-r--r--include/jemalloc/internal/mutex_prof.h1
-rw-r--r--src/ctl.c12
-rw-r--r--src/mutex.c2
4 files changed, 21 insertions, 6 deletions
diff --git a/include/jemalloc/internal/mutex_externs.h b/include/jemalloc/internal/mutex_externs.h
index c9a817f..d0139f2 100644
--- a/include/jemalloc/internal/mutex_externs.h
+++ b/include/jemalloc/internal/mutex_externs.h
@@ -10,12 +10,12 @@ extern bool isthreaded;
# define isthreaded true
#endif
-bool malloc_mutex_init(malloc_mutex_t *mutex, const char *name,
+bool malloc_mutex_init(malloc_mutex_t *mutex, const char *name,
witness_rank_t rank, malloc_mutex_lock_order_t lock_order);
-void malloc_mutex_prefork(tsdn_t *tsdn, malloc_mutex_t *mutex);
-void malloc_mutex_postfork_parent(tsdn_t *tsdn, malloc_mutex_t *mutex);
-void malloc_mutex_postfork_child(tsdn_t *tsdn, malloc_mutex_t *mutex);
-bool malloc_mutex_boot(void);
-void malloc_mutex_prof_data_reset(tsdn_t *tsdn, malloc_mutex_t *mutex);
+void malloc_mutex_prefork(tsdn_t *tsdn, malloc_mutex_t *mutex);
+void malloc_mutex_postfork_parent(tsdn_t *tsdn, malloc_mutex_t *mutex);
+void malloc_mutex_postfork_child(tsdn_t *tsdn, malloc_mutex_t *mutex);
+bool malloc_mutex_boot(void);
+void malloc_mutex_prof_data_reset(tsdn_t *tsdn, malloc_mutex_t *mutex);
#endif /* JEMALLOC_INTERNAL_MUTEX_EXTERNS_H */
diff --git a/include/jemalloc/internal/mutex_prof.h b/include/jemalloc/internal/mutex_prof.h
index 1cc198d..3358bcf 100644
--- a/include/jemalloc/internal/mutex_prof.h
+++ b/include/jemalloc/internal/mutex_prof.h
@@ -6,6 +6,7 @@
#include "jemalloc/internal/tsd_types.h"
#define MUTEX_PROF_GLOBAL_MUTEXES \
+ OP(background_thread) \
OP(ctl) \
OP(prof)
diff --git a/src/ctl.c b/src/ctl.c
index caa9f3e..da5e171 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -947,6 +947,15 @@ ctl_refresh(tsdn_t *tsdn) {
READ_GLOBAL_MUTEX_PROF_DATA(global_prof_mutex_prof,
bt2gctx_mtx);
}
+ if (have_background_thread) {
+ READ_GLOBAL_MUTEX_PROF_DATA(
+ global_prof_mutex_background_thread,
+ background_thread_lock);
+ } else {
+ memset(&ctl_stats->mutex_prof_data[
+ global_prof_mutex_background_thread], 0,
+ sizeof(mutex_prof_data_t));
+ }
/* We own ctl mutex already. */
malloc_mutex_prof_read(tsdn,
&ctl_stats->mutex_prof_data[global_prof_mutex_ctl],
@@ -2557,6 +2566,9 @@ stats_mutexes_reset_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
/* Global mutexes: ctl and prof. */
MUTEX_PROF_RESET(ctl_mtx);
+ if (have_background_thread) {
+ MUTEX_PROF_RESET(background_thread_lock);
+ }
if (config_prof && opt_prof) {
MUTEX_PROF_RESET(bt2gctx_mtx);
}
diff --git a/src/mutex.c b/src/mutex.c
index c92ddd7..48e2940 100644
--- a/src/mutex.c
+++ b/src/mutex.c
@@ -112,6 +112,8 @@ label_spin_done:
static void
mutex_prof_data_init(mutex_prof_data_t *data) {
memset(data, 0, sizeof(mutex_prof_data_t));
+ nstime_init(&data->max_wait_time, 0);
+ nstime_init(&data->tot_wait_time, 0);
data->prev_owner = NULL;
}