From 94f9daba014fbf69d730993f1407a426b614071b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 24 Oct 2018 14:56:59 -0500 Subject: [PATCH] common/Throttle: ceph::mutex -> std::mutex These are inner locks; no need for lockdep here, and throttles are in hot paths. Signed-off-by: Sage Weil --- src/common/Throttle.cc | 6 ++---- src/common/Throttle.h | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc index a4d4cd4172baa..73c10789f0145 100644 --- a/src/common/Throttle.cc +++ b/src/common/Throttle.cc @@ -39,7 +39,6 @@ enum { Throttle::Throttle(CephContext *cct, const std::string& n, int64_t m, bool _use_perf) : cct(cct), name(n), max(m), - lock(ceph::make_mutex(name)), use_perf(_use_perf) { ceph_assert(m >= 0); @@ -86,7 +85,7 @@ void Throttle::_reset_max(int64_t m) max = m; } -bool Throttle::_wait(int64_t c, std::unique_lock& l) +bool Throttle::_wait(int64_t c, std::unique_lock& l) { mono_time start; bool waited = false; @@ -262,7 +261,6 @@ enum { BackoffThrottle::BackoffThrottle(CephContext *cct, const std::string& n, unsigned expected_concurrency, bool _use_perf) : cct(cct), name(n), - lock(ceph::make_mutex(name)), conds(expected_concurrency),///< [in] determines size of conds use_perf(_use_perf) { @@ -633,7 +631,7 @@ int OrderedThrottle::wait_for_ret() { return m_ret_val; } -void OrderedThrottle::complete_pending_ops(std::unique_lock& l) { +void OrderedThrottle::complete_pending_ops(std::unique_lock& l) { while (true) { auto it = m_tid_result.begin(); if (it == m_tid_result.end() || it->first != m_complete_tid || diff --git a/src/common/Throttle.h b/src/common/Throttle.h index 3ccfdb1698a1b..5b31366d9faa6 100644 --- a/src/common/Throttle.h +++ b/src/common/Throttle.h @@ -30,8 +30,8 @@ class Throttle final : public ThrottleInterface { const std::string name; PerfCountersRef logger; std::atomic count = { 0 }, max = { 0 }; - ceph::mutex lock; - std::list conds; + std::mutex lock; + std::list conds; const bool use_perf; public: @@ -49,7 +49,7 @@ private: (c >= m && cur > m)); // except for large c } - bool _wait(int64_t c, std::unique_lock& l); + bool _wait(int64_t c, std::unique_lock& l); public: /** @@ -157,20 +157,20 @@ class BackoffThrottle { const std::string name; PerfCountersRef logger; - ceph::mutex lock; - using locker = std::unique_lock; + std::mutex lock; + using locker = std::unique_lock; unsigned next_cond = 0; /// allocated once to avoid constantly allocating new ones - vector conds; + vector conds; const bool use_perf; /// pointers into conds - list waiters; + list waiters; - std::list::iterator _push_waiter() { + std::list::iterator _push_waiter() { unsigned next = next_cond++; if (next_cond == conds.size()) next_cond = 0; @@ -253,8 +253,8 @@ public: bool pending_error() const; int wait_for_ret(); private: - mutable ceph::mutex m_lock = ceph::make_mutex("SimpleThrottle::m_lock"); - ceph::condition_variable m_cond; + mutable std::mutex m_lock; + std::condition_variable m_cond; uint64_t m_max; uint64_t m_current = 0; int m_ret = 0; @@ -315,8 +315,8 @@ private: typedef std::map TidResult; - mutable ceph::mutex m_lock = ceph::make_mutex("OrderedThrottle::m_lock"); - ceph::condition_variable m_cond; + mutable std::mutex m_lock; + std::condition_variable m_cond; uint64_t m_max; uint64_t m_current = 0; int m_ret_val = 0; @@ -327,7 +327,7 @@ private: TidResult m_tid_result; - void complete_pending_ops(std::unique_lock& l); + void complete_pending_ops(std::unique_lock& l); uint32_t waiters = 0; }; -- 2.39.5