OSDN Git Service

lockdep: Teach lockdep about "USED" <- "IN-NMI" inversions
authorPeter Zijlstra <peterz@infradead.org>
Thu, 20 Feb 2020 08:45:02 +0000 (09:45 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 20 Mar 2020 12:06:25 +0000 (13:06 +0100)
commitf6f48e18040402136874a6a71611e081b4d0788a
tree494c4d17ab3f9744cc60647470b10ff45aefaf47
parent248efb2158f1e23750728e92ad9db3ab60c14485
lockdep: Teach lockdep about "USED" <- "IN-NMI" inversions

nmi_enter() does lockdep_off() and hence lockdep ignores everything.

And NMI context makes it impossible to do full IN-NMI tracking like we
do IN-HARDIRQ, that could result in graph_lock recursion.

However, since look_up_lock_class() is lockless, we can find the class
of a lock that has prior use and detect IN-NMI after USED, just not
USED after IN-NMI.

NOTE: By shifting the lockdep_off() recursion count to bit-16, we can
easily differentiate between actual recursion and off.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Link: https://lkml.kernel.org/r/20200221134215.090538203@infradead.org
kernel/locking/lockdep.c