From: Piotr Dałek Date: Fri, 22 Apr 2016 18:03:17 +0000 (+0200) Subject: lockdep: Reduce matrices usage range to minimum X-Git-Tag: v11.0.0~304^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e010d936ed57bd8b54d5649272e79003ab70c236;p=ceph.git lockdep: Reduce matrices usage range to minimum 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 --- diff --git a/src/common/lockdep.cc b/src/common/lockdep.cc index 660c7b76ba9..b542b3b8404 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