1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-05 09:14:03 +00:00

LinuxKPI: Add sysctl(8) knob to control verbosity of WARN_ON's.

The purpose of this change is to reduce the amount of dmesg(8) noise when
VT switching after a panic.

Submitted by:	Greg V <greg@unrelenting.technology>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30174
Sponsored by:	NVIDIA Networking
This commit is contained in:
Hans Petter Selasky 2021-11-02 16:52:46 +01:00
parent a670e1c13a
commit 2390a1441e
2 changed files with 19 additions and 11 deletions

View File

@ -121,28 +121,31 @@ extern const volatile int lkpi_build_bug_on_zero;
} \
} while (0)
extern int linuxkpi_warn_dump_stack;
#define WARN_ON(cond) ({ \
bool __ret = (cond); \
if (__ret) { \
bool __ret = (cond); \
if (__ret) { \
printf("WARNING %s failed at %s:%d\n", \
__stringify(cond), __FILE__, __LINE__); \
linux_dump_stack(); \
} \
unlikely(__ret); \
if (linuxkpi_warn_dump_stack) \
linux_dump_stack(); \
} \
unlikely(__ret); \
})
#define WARN_ON_SMP(cond) WARN_ON(cond)
#define WARN_ON_ONCE(cond) ({ \
static bool __warn_on_once; \
bool __ret = (cond); \
if (__ret && !__warn_on_once) { \
static bool __warn_on_once; \
bool __ret = (cond); \
if (__ret && !__warn_on_once) { \
__warn_on_once = 1; \
printf("WARNING %s failed at %s:%d\n", \
__stringify(cond), __FILE__, __LINE__); \
linux_dump_stack(); \
} \
unlikely(__ret); \
if (linuxkpi_warn_dump_stack) \
linux_dump_stack(); \
} \
unlikely(__ret); \
})
#define oops_in_progress SCHEDULER_STOPPED()

View File

@ -103,6 +103,11 @@ int linuxkpi_debug;
SYSCTL_INT(_compat_linuxkpi, OID_AUTO, debug, CTLFLAG_RWTUN,
&linuxkpi_debug, 0, "Set to enable pr_debug() prints. Clear to disable.");
int linuxkpi_warn_dump_stack = 0;
SYSCTL_INT(_compat_linuxkpi, OID_AUTO, warn_dump_stack, CTLFLAG_RWTUN,
&linuxkpi_warn_dump_stack, 0,
"Set to enable stack traces from WARN_ON(). Clear to disable.");
static struct timeval lkpi_net_lastlog;
static int lkpi_net_curpps;
static int lkpi_net_maxpps = 99;