18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * lib/debug_locks.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Generic place for common debugging facilities for various locks: 68c2ecf20Sopenharmony_ci * spinlocks, rwlocks, mutexes and rwsems. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Started by Ingo Molnar: 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci#include <linux/rwsem.h> 138c2ecf20Sopenharmony_ci#include <linux/mutex.h> 148c2ecf20Sopenharmony_ci#include <linux/export.h> 158c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 168c2ecf20Sopenharmony_ci#include <linux/debug_locks.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* 198c2ecf20Sopenharmony_ci * We want to turn all lock-debugging facilities on/off at once, 208c2ecf20Sopenharmony_ci * via a global flag. The reason is that once a single bug has been 218c2ecf20Sopenharmony_ci * detected and reported, there might be cascade of followup bugs 228c2ecf20Sopenharmony_ci * that would just muddy the log. So we report the first one and 238c2ecf20Sopenharmony_ci * shut up after that. 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_ciint debug_locks __read_mostly = 1; 268c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(debug_locks); 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* 298c2ecf20Sopenharmony_ci * The locking-testsuite uses <debug_locks_silent> to get a 308c2ecf20Sopenharmony_ci * 'silent failure': nothing is printed to the console when 318c2ecf20Sopenharmony_ci * a locking bug is detected. 328c2ecf20Sopenharmony_ci */ 338c2ecf20Sopenharmony_ciint debug_locks_silent __read_mostly; 348c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(debug_locks_silent); 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* 378c2ecf20Sopenharmony_ci * Generic 'turn off all lock debugging' function: 388c2ecf20Sopenharmony_ci */ 398c2ecf20Sopenharmony_ciint debug_locks_off(void) 408c2ecf20Sopenharmony_ci{ 418c2ecf20Sopenharmony_ci if (debug_locks && __debug_locks_off()) { 428c2ecf20Sopenharmony_ci if (!debug_locks_silent) { 438c2ecf20Sopenharmony_ci console_verbose(); 448c2ecf20Sopenharmony_ci return 1; 458c2ecf20Sopenharmony_ci } 468c2ecf20Sopenharmony_ci } 478c2ecf20Sopenharmony_ci return 0; 488c2ecf20Sopenharmony_ci} 498c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(debug_locks_off); 50