aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-02-07 08:28:51 -0800
committerGravatar Craig Tiller <ctiller@google.com>2017-02-07 08:28:51 -0800
commitb038beb7245877b71e30e782ddd6c86d82d11d17 (patch)
treead1ff2c2e5ac711e868f59ecda4d443e152afa47 /src/core/lib
parentb4726ff0a6760f1b0a3e5a9a3914789b6ca9deeb (diff)
Add counters for mutex acquisitions, expose in bm_fullstack
Diffstat (limited to 'src/core/lib')
-rw-r--r--src/core/lib/support/sync_posix.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/core/lib/support/sync_posix.c b/src/core/lib/support/sync_posix.c
index dcb0969a4e..de0f0484b5 100644
--- a/src/core/lib/support/sync_posix.c
+++ b/src/core/lib/support/sync_posix.c
@@ -42,11 +42,18 @@
#include <time.h>
#include "src/core/lib/profiling/timers.h"
+#ifdef GPR_MU_COUNTERS
+gpr_atm grpc_mu_locks = 0;
+#endif
+
void gpr_mu_init(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_init(mu, NULL) == 0); }
void gpr_mu_destroy(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_destroy(mu) == 0); }
void gpr_mu_lock(gpr_mu* mu) {
+#ifdef GPR_MU_COUNTERS
+ gpr_atm_no_barrier_fetch_add(&grpc_mu_locks, 1);
+#endif
GPR_TIMER_BEGIN("gpr_mu_lock", 0);
GPR_ASSERT(pthread_mutex_lock(mu) == 0);
GPR_TIMER_END("gpr_mu_lock", 0);