]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/common/Mutex.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / common / Mutex.cc
index 1bb588902d00c5c1a8cfee9ee5b2f95374fef74a..e029adc752788b79aa1bad59b0ced076ae1ef0b0 100644 (file)
  */
 
 #include "common/Mutex.h"
-#include "common/perf_counters.h"
 #include "common/config.h"
 #include "common/Clock.h"
 #include "common/valgrind.h"
 
 Mutex::Mutex(const std::string &n, bool r, bool ld,
-            bool bt,
-            CephContext *cct) :
+            bool bt) :
   name(n), id(-1), recursive(r), lockdep(ld), backtrace(bt), nlock(0),
-  locked_by(0), cct(cct), logger(0)
+  locked_by(0)
 {
   ANNOTATE_BENIGN_RACE_SIZED(&id, sizeof(id), "Mutex lockdep id");
   ANNOTATE_BENIGN_RACE_SIZED(&nlock, sizeof(nlock), "Mutex nlock");
   ANNOTATE_BENIGN_RACE_SIZED(&locked_by, sizeof(locked_by), "Mutex locked_by");
-  if (cct) {
-    PerfCountersBuilder b(cct, string("mutex-") + name,
-                         l_mutex_first, l_mutex_last);
-    b.add_time_avg(l_mutex_wait, "wait", "Average time of mutex in locked state");
-    logger = b.create_perf_counters();
-    cct->get_perfcounters_collection()->add(logger);
-    logger->set(l_mutex_wait, 0);
-  }
   if (recursive) {
     // Mutexes of type PTHREAD_MUTEX_RECURSIVE do all the same checks as
     // mutexes of type PTHREAD_MUTEX_ERRORCHECK.
@@ -71,53 +61,30 @@ Mutex::Mutex(const std::string &n, bool r, bool ld,
 }
 
 Mutex::~Mutex() {
-  assert(nlock == 0);
+  ceph_assert(nlock == 0);
 
   // helgrind gets confused by condition wakeups leading to mutex destruction
   ANNOTATE_BENIGN_RACE_SIZED(&_m, sizeof(_m), "Mutex primitive");
   pthread_mutex_destroy(&_m);
 
-  if (cct && logger) {
-    cct->get_perfcounters_collection()->remove(logger);
-    delete logger;
-  }
   if (lockdep && g_lockdep) {
     lockdep_unregister(id);
   }
 }
 
-void Mutex::Lock(bool no_lockdep) {
-  int r;
-
+void Mutex::lock(bool no_lockdep)
+{
   if (lockdep && g_lockdep && !no_lockdep && !recursive) _will_lock();
-
-  if (logger && cct && cct->_conf->mutex_perf_counter) {
-    utime_t start;
-    // instrumented mutex enabled
-    start = ceph_clock_now();
-    if (TryLock()) {
-      goto out;
-    }
-
-    r = pthread_mutex_lock(&_m);
-
-    logger->tinc(l_mutex_wait,
-                ceph_clock_now() - start);
-  } else {
-    r = pthread_mutex_lock(&_m);
-  }
-
-  assert(r == 0);
+  int r = pthread_mutex_lock(&_m);
+  ceph_assert(r == 0);
   if (lockdep && g_lockdep) _locked();
   _post_lock();
-
-out:
-  ;
 }
 
-void Mutex::Unlock() {
+void Mutex::unlock()
+{
   _pre_unlock();
   if (lockdep && g_lockdep) _will_unlock();
   int r = pthread_mutex_unlock(&_m);
-  assert(r == 0);
+  ceph_assert(r == 0);
 }