Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * lib/debug_locks.c
0004  *
0005  * Generic place for common debugging facilities for various locks:
0006  * spinlocks, rwlocks, mutexes and rwsems.
0007  *
0008  * Started by Ingo Molnar:
0009  *
0010  *  Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
0011  */
0012 #include <linux/rwsem.h>
0013 #include <linux/mutex.h>
0014 #include <linux/export.h>
0015 #include <linux/spinlock.h>
0016 #include <linux/debug_locks.h>
0017 
0018 /*
0019  * We want to turn all lock-debugging facilities on/off at once,
0020  * via a global flag. The reason is that once a single bug has been
0021  * detected and reported, there might be cascade of followup bugs
0022  * that would just muddy the log. So we report the first one and
0023  * shut up after that.
0024  */
0025 int debug_locks __read_mostly = 1;
0026 EXPORT_SYMBOL_GPL(debug_locks);
0027 
0028 /*
0029  * The locking-testsuite uses <debug_locks_silent> to get a
0030  * 'silent failure': nothing is printed to the console when
0031  * a locking bug is detected.
0032  */
0033 int debug_locks_silent __read_mostly;
0034 EXPORT_SYMBOL_GPL(debug_locks_silent);
0035 
0036 /*
0037  * Generic 'turn off all lock debugging' function:
0038  */
0039 int debug_locks_off(void)
0040 {
0041     if (debug_locks && __debug_locks_off()) {
0042         if (!debug_locks_silent) {
0043             console_verbose();
0044             return 1;
0045         }
0046     }
0047     return 0;
0048 }
0049 EXPORT_SYMBOL_GPL(debug_locks_off);