1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * lib/debug_locks.c 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Generic place for common debugging facilities for various locks: 6*4882a593Smuzhiyun * spinlocks, rwlocks, mutexes and rwsems. 7*4882a593Smuzhiyun * 8*4882a593Smuzhiyun * Started by Ingo Molnar: 9*4882a593Smuzhiyun * 10*4882a593Smuzhiyun * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> 11*4882a593Smuzhiyun */ 12*4882a593Smuzhiyun #include <linux/rwsem.h> 13*4882a593Smuzhiyun #include <linux/mutex.h> 14*4882a593Smuzhiyun #include <linux/export.h> 15*4882a593Smuzhiyun #include <linux/spinlock.h> 16*4882a593Smuzhiyun #include <linux/debug_locks.h> 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun /* 19*4882a593Smuzhiyun * We want to turn all lock-debugging facilities on/off at once, 20*4882a593Smuzhiyun * via a global flag. The reason is that once a single bug has been 21*4882a593Smuzhiyun * detected and reported, there might be cascade of followup bugs 22*4882a593Smuzhiyun * that would just muddy the log. So we report the first one and 23*4882a593Smuzhiyun * shut up after that. 24*4882a593Smuzhiyun */ 25*4882a593Smuzhiyun int debug_locks __read_mostly = 1; 26*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(debug_locks); 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun /* 29*4882a593Smuzhiyun * The locking-testsuite uses <debug_locks_silent> to get a 30*4882a593Smuzhiyun * 'silent failure': nothing is printed to the console when 31*4882a593Smuzhiyun * a locking bug is detected. 32*4882a593Smuzhiyun */ 33*4882a593Smuzhiyun int debug_locks_silent __read_mostly; 34*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(debug_locks_silent); 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun /* 37*4882a593Smuzhiyun * Generic 'turn off all lock debugging' function: 38*4882a593Smuzhiyun */ debug_locks_off(void)39*4882a593Smuzhiyunint debug_locks_off(void) 40*4882a593Smuzhiyun { 41*4882a593Smuzhiyun if (debug_locks && __debug_locks_off() && !debug_locks_silent) 42*4882a593Smuzhiyun return 1; 43*4882a593Smuzhiyun return 0; 44*4882a593Smuzhiyun } 45*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(debug_locks_off); 46