From: Piotr Dałek Date: Fri, 22 Apr 2016 18:34:05 +0000 (+0200) Subject: lockdep: Reduce "follows" matrix size by 8 X-Git-Tag: v11.0.0~304^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6ddc87a8becaf0887ab9b5a04acfa023c2b55e0e;p=ceph.git lockdep: Reduce "follows" matrix size by 8 Convert "follows" matrix to 2-dimensional array of bits, reducing its storage size from 16 MB (assuming MAX_LOCKS = 4096) to 2MB. Signed-off-by: Piotr Dałek --- diff --git a/src/common/lockdep.cc b/src/common/lockdep.cc index b542b3b84043..0b2046b6bc92 100644 --- a/src/common/lockdep.cc +++ b/src/common/lockdep.cc @@ -54,7 +54,7 @@ static map lock_names; static map lock_refs; 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 char follows[MAX_LOCKS][MAX_LOCKS/8]; // follows[a][b] means b taken after a static BackTrace *follows_bt[MAX_LOCKS][MAX_LOCKS]; unsigned current_maxid; @@ -106,7 +106,7 @@ void lockdep_unregister_ceph_context(CephContext *cct) lock_ids.clear(); lock_refs.clear(); free_ids.clear(); - memset((void*)&follows[0][0], 0, sizeof(bool) * current_maxid * MAX_LOCKS); + memset((void*)&follows[0][0], 0, current_maxid * MAX_LOCKS/8); memset((void*)&follows_bt[0][0], 0, sizeof(BackTrace*) * current_maxid * MAX_LOCKS); current_maxid = 0; } @@ -135,7 +135,6 @@ int lockdep_dump_locks() return 0; } - int lockdep_register(const char *name) { int id; @@ -184,14 +183,14 @@ void lockdep_unregister(int id) int &refs = lock_refs[id]; if (--refs == 0) { // reset dependency ordering - memset((void*)&follows[id][0], 0, current_maxid); + memset((void*)&follows[id][0], 0, MAX_LOCKS/8); for (unsigned i=0; isecond << "' from " << id @@ -211,7 +210,7 @@ void lockdep_unregister(int id) // does b follow a? static bool does_follow(int a, int b) { - if (follows[a][b]) { + if (follows[a][b/8] & (1 << (b % 8))) { lockdep_dout(0) << "\n"; *_dout << "------------------------------------" << "\n"; *_dout << "existing dependency " << lock_names[a] << " (" << a << ") -> " @@ -224,7 +223,7 @@ static bool does_follow(int a, int b) } for (unsigned i=0; i " << lock_names[i] << " (" << i << ") at:\n"; @@ -265,7 +264,7 @@ int lockdep_will_lock(const char *name, int id, bool force_backtrace) *_dout << dendl; assert(0); } - else if (!follows[p->first][id]) { + else if (!(follows[p->first][id/8] & (1 << (id % 8)))) { // new dependency // did we just create a cycle? @@ -300,7 +299,7 @@ int lockdep_will_lock(const char *name, int id, bool force_backtrace) if (force_backtrace || lockdep_force_backtrace()) { bt = new BackTrace(BACKTRACE_SKIP); } - follows[p->first][id] = true; + follows[p->first][id/8] |= 1 << (id % 8); follows_bt[p->first][id] = bt; lockdep_dout(10) << lock_names[p->first] << " -> " << name << " at" << dendl; //bt->print(*_dout);