UPSTREAM: locking/lockdep: Make it easy to detect whether or not inside a selftest
The patch that frees unused lock classes will modify the behavior of lockdep_free_key_range() and lockdep_reset_lock() depending on whether or not these functions are called from the context of the lockdep selftests. Hence make it easy to detect whether or not lockdep code is called from the context of a lockdep selftest. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Johannes Berg <johannes@sipsolutions.net> 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: Waiman Long <longman@redhat.com> Cc: Will Deacon <will.deacon@arm.com> Cc: johannes.berg@intel.com Cc: tj@kernel.org Link: https://lkml.kernel.org/r/20190214230058.196511-10-bvanassche@acm.org Signed-off-by: Ingo Molnar <mingo@kernel.org> Change-Id: I4628f4ed4dcb7470109b6eb89e054f48917a3ad5 Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
This commit is contained in:
parent
ccff3d32d1
commit
8b7d6602c6
@ -267,6 +267,7 @@ extern void lockdep_reset(void);
|
||||
extern void lockdep_reset_lock(struct lockdep_map *lock);
|
||||
extern void lockdep_free_key_range(void *start, unsigned long size);
|
||||
extern asmlinkage void lockdep_sys_exit(void);
|
||||
extern void lockdep_set_selftest_task(struct task_struct *task);
|
||||
|
||||
extern void lockdep_off(void);
|
||||
extern void lockdep_on(void);
|
||||
@ -397,6 +398,10 @@ static inline void lockdep_on(void)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void lockdep_set_selftest_task(struct task_struct *task)
|
||||
{
|
||||
}
|
||||
|
||||
# define lock_acquire(l, s, t, r, c, n, i) do { } while (0)
|
||||
# define lock_release(l, n, i) do { } while (0)
|
||||
# define lock_downgrade(l, i) do { } while (0)
|
||||
|
@ -106,6 +106,7 @@ static int lockdep_logging_off(void)
|
||||
* code to recurse back into the lockdep code...
|
||||
*/
|
||||
static arch_spinlock_t lockdep_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
|
||||
static struct task_struct *lockdep_selftest_task_struct;
|
||||
|
||||
static int graph_lock(void)
|
||||
{
|
||||
@ -364,6 +365,11 @@ void lockdep_on(void)
|
||||
}
|
||||
EXPORT_SYMBOL(lockdep_on);
|
||||
|
||||
void lockdep_set_selftest_task(struct task_struct *task)
|
||||
{
|
||||
lockdep_selftest_task_struct = task;
|
||||
}
|
||||
|
||||
/*
|
||||
* Debugging switches:
|
||||
*/
|
||||
|
@ -1989,6 +1989,7 @@ void locking_selftest(void)
|
||||
|
||||
init_shared_classes();
|
||||
debug_locks_silent = !debug_locks_verbose;
|
||||
lockdep_set_selftest_task(current);
|
||||
|
||||
DO_TESTCASE_6R("A-A deadlock", AA);
|
||||
DO_TESTCASE_6R("A-B-B-A deadlock", ABBA);
|
||||
@ -2097,5 +2098,6 @@ void locking_selftest(void)
|
||||
printk("---------------------------------\n");
|
||||
debug_locks = 1;
|
||||
}
|
||||
lockdep_set_selftest_task(NULL);
|
||||
debug_locks_silent = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user