]> git.proxmox.com Git - ceph.git/blob - ceph/src/common/mutex_debug.cc
import ceph quincy 17.2.6
[ceph.git] / ceph / src / common / mutex_debug.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15 #include "common/mutex_debug.h"
16 #include "common/perf_counters.h"
17 #include "common/ceph_context.h"
18 #include "common/config.h"
19
20 namespace ceph {
21 namespace mutex_debug_detail {
22 enum {
23 l_mutex_first = 999082,
24 l_mutex_wait,
25 l_mutex_last
26 };
27
28 mutex_debugging_base::mutex_debugging_base(std::string group, bool ld, bool bt)
29 : group(std::move(group)),
30 lockdep(ld),
31 backtrace(bt)
32 {
33 if (_enable_lockdep()) {
34 _register();
35 }
36 }
37
38 mutex_debugging_base::~mutex_debugging_base() {
39 ceph_assert(nlock == 0);
40 if (_enable_lockdep()) {
41 lockdep_unregister(id);
42 }
43 }
44
45 void mutex_debugging_base::_register() {
46 id = lockdep_register(group.c_str());
47 }
48 void mutex_debugging_base::_will_lock(bool recursive) { // about to lock
49 id = lockdep_will_lock(group.c_str(), id, backtrace, recursive);
50 }
51 void mutex_debugging_base::_locked() { // just locked
52 id = lockdep_locked(group.c_str(), id, backtrace);
53 }
54 void mutex_debugging_base::_will_unlock() { // about to unlock
55 id = lockdep_will_unlock(group.c_str(), id);
56 }
57
58 } // namespace mutex_debug_detail
59 } // namespace ceph