From 9e9fe76ff130f8fd7aac46ab4819da4b477f7c73 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 8 Mar 2021 15:34:47 +0800 Subject: [PATCH] common/lockdep: introduce MAX_FOLLOWERS before this change we use a matrix for tracking the locks and those which are locked after acquiring the formers. where follows[a][b] sigifies that b is acquired after a is acquired, and a and b are both lock ids allocated in the lock_ids registry. but since we might need to have a much large set of locks which are acquired at the same time. but the numbers of their follower of each of them are always much smaller. because we are not likely to hold, for instance, 4096 locks when we still holding a lock. actually, this might be a bug, if we actually do this. so we can use smaller vectors for tracking the followers. and the size of those vectors can be one or more orders of magnitude smaller than the number of locks. in this change, MAX_FOLLOWERS in introduced for the max number of followers. Signed-off-by: Kefu Chai --- src/common/lockdep.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/common/lockdep.cc b/src/common/lockdep.cc index 687d99d4953..644245d4144 100644 --- a/src/common/lockdep.cc +++ b/src/common/lockdep.cc @@ -19,7 +19,6 @@ /******* Constants **********/ #define lockdep_dout(v) lsubdout(g_lockdep_ceph_ctx, lockdep, v) -#define MAX_LOCKS 4096 // increase me as needed #define BACKTRACE_SKIP 2 /******* Globals **********/ @@ -38,10 +37,12 @@ static lockdep_stopper_t lockdep_stopper; static ceph::unordered_map lock_ids; static std::map lock_names; static std::map lock_refs; +static constexpr size_t MAX_LOCKS = 4096; // increase me as needed static std::bitset free_ids; // bit set = free static ceph::unordered_map > held; -static std::vector> follows(MAX_LOCKS); // follows[a][b] means b taken after a -static std::vector> follows_bt(MAX_LOCKS); +static constexpr size_t MAX_FOLLOWERS = 4096; +static std::vector> follows(MAX_LOCKS); // follows[a][b] means b taken after a +static std::vector> follows_bt(MAX_LOCKS); unsigned current_maxid; int last_freed_id = -1; static bool free_ids_inited; -- 2.39.5