From d0f8c71280518f1f1dc46a4716c173f1d7da98f1 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 8 Mar 2021 16:09:34 +0800 Subject: [PATCH] common/lockdep: increase MAX_LOCKS to 128k initialize follows and follows_bt with 4k, and resize them when the size of locks exceeds the initial number, but with the upper bound of MAX_LOCKS which is fixed at compile time. this change allows us to use 128k locks in the same time. Signed-off-by: Kefu Chai --- src/common/lockdep.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/common/lockdep.cc b/src/common/lockdep.cc index 644245d41443..59d42780a895 100644 --- a/src/common/lockdep.cc +++ b/src/common/lockdep.cc @@ -37,12 +37,14 @@ 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 constexpr size_t MAX_LOCKS = 128 * 1024; // increase me as needed static std::bitset free_ids; // bit set = free static ceph::unordered_map > held; +static constexpr size_t NR_LOCKS = 4096; // the initial number of 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); +static std::vector> follows(NR_LOCKS); // follows[a][b] means b taken after a +static std::vector> follows_bt(NR_LOCKS); +// upper bound of lock id unsigned current_maxid; int last_freed_id = -1; static bool free_ids_inited; @@ -169,7 +171,11 @@ static int _lockdep_register(const char *name) ceph_abort(); } if (current_maxid <= (unsigned)id) { - current_maxid = (unsigned)id + 1; + current_maxid = (unsigned)id + 1; + if (current_maxid == follows.size()) { + follows.resize(current_maxid); + follows_bt.resize(current_maxid); + } } lock_ids[name] = id; lock_names[id] = name; -- 2.47.3