From e010d936ed57bd8b54d5649272e79003ab70c236 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Piotr=20Da=C5=82ek?= Date: Fri, 22 Apr 2016 20:03:17 +0200 Subject: [PATCH] lockdep: Reduce matrices usage range to minimum MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Introduce current_maxid variable which holds highest lock ID. Using that, don't attempt to check/reset parts of "follows" and "follows_bt" matrices that are not used yet. This improves performance by reducing CPU usage (particularly by lockdep_unregister() function), this also reduces RSS memory usage by quite a bit, as many allocated pages are not actually touched anymore. Improve CPU usage a bit more, by using memset() to reset "follows" members instead of iterating byte-by-byte. Finally, use push_front instead of push_back when unregistering, so unregistered IDs will be recycled. Signed-off-by: Piotr Dałek --- src/common/lockdep.cc | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/common/lockdep.cc b/src/common/lockdep.cc index 660c7b76ba978..b542b3b840437 100644 --- a/src/common/lockdep.cc +++ b/src/common/lockdep.cc @@ -56,6 +56,7 @@ static list free_ids; static ceph::unordered_map > held; static bool follows[MAX_LOCKS][MAX_LOCKS]; // follows[a][b] means b taken after a static BackTrace *follows_bt[MAX_LOCKS][MAX_LOCKS]; +unsigned current_maxid; static bool lockdep_force_backtrace() { @@ -75,6 +76,7 @@ void lockdep_register_ceph_context(CephContext *cct) g_lockdep = true; g_lockdep_ceph_ctx = cct; lockdep_dout(0) << "lockdep start" << dendl; + current_maxid = 0; for (int i=0; isecond); lock_names.erase(id); lock_refs.erase(id); - free_ids.push_back(id); + free_ids.push_front(id); } else { lockdep_dout(20) << "have " << refs << " of '" << p->second << "' " << "from " << id << dendl; @@ -216,7 +223,7 @@ static bool does_follow(int a, int b) return true; } - for (int i=0; i