locking/lockdep: Fix stack trace caching logic
authorDmitry Vyukov <dvyukov@google.com>
Thu, 4 Feb 2016 13:40:40 +0000 (14:40 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 9 Feb 2016 10:06:08 +0000 (11:06 +0100)
commit8a5fd56431fe1682e870bd6ab0c276e74befbeb9
treebc2047bcdb5f7a29656deeaee113b8223b5246db
parent765bdb406de4b6132e349c5d4e077866536a9cc0
locking/lockdep: Fix stack trace caching logic

check_prev_add() caches saved stack trace in static trace variable
to avoid duplicate save_trace() calls in dependencies involving trylocks.
But that caching logic contains a bug. We may not save trace on first
iteration due to early return from check_prev_add(). Then on the
second iteration when we actually need the trace we don't save it
because we think that we've already saved it.

Let check_prev_add() itself control when stack is saved.

There is another bug. Trace variable is protected by graph lock.
But we can temporary release graph lock during printing.

Fix this by invalidating cached stack trace when we release graph lock.

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: glider@google.com
Cc: kcc@google.com
Cc: peter@hurleysoftware.com
Cc: sasha.levin@oracle.com
Link: http://lkml.kernel.org/r/1454593240-121647-1-git-send-email-dvyukov@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/locking/lockdep.c