mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
lib/bug.c: use common WARN helper
The traceoff_on_warning option doesn't have any effect on s390, powerpc, arm64, parisc, and sh because there are two different types of WARN implementations: 1) The above mentioned architectures treat WARN() as a special case of a BUG() exception. They handle warnings in report_bug() in lib/bug.c. 2) All other architectures just call warn_slowpath_*() directly. Their warnings are handled in warn_slowpath_common() in kernel/panic.c. Support traceoff_on_warning on all architectures and prevent any future divergence by using a single common function to emit the warning. Also remove the '()' from '%pS()', because the parentheses look funky: [ 45.607629] WARNING: at /root/warn_mod/warn_mod.c:17 .init_dummy+0x20/0x40 [warn_mod]() Reported-by: Chunyu Hu <chuhu@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> Tested-by: Prarit Bhargava <prarit@redhat.com> Acked-by: Prarit Bhargava <prarit@redhat.com> Acked-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
4cc7ecb7f2
commit
2553b67a1f
3 changed files with 34 additions and 39 deletions
26
lib/bug.c
26
lib/bug.c
|
@ -167,30 +167,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
|
|||
|
||||
if (warning) {
|
||||
/* this is a WARN_ON rather than BUG/BUG_ON */
|
||||
pr_warn("------------[ cut here ]------------\n");
|
||||
|
||||
if (file)
|
||||
pr_warn("WARNING: at %s:%u\n", file, line);
|
||||
else
|
||||
pr_warn("WARNING: at %p [verbose debug info unavailable]\n",
|
||||
(void *)bugaddr);
|
||||
|
||||
if (panic_on_warn) {
|
||||
/*
|
||||
* This thread may hit another WARN() in the panic path.
|
||||
* Resetting this prevents additional WARN() from
|
||||
* panicking the system on this thread. Other threads
|
||||
* are blocked by the panic_mutex in panic().
|
||||
*/
|
||||
panic_on_warn = 0;
|
||||
panic("panic_on_warn set ...\n");
|
||||
}
|
||||
|
||||
print_modules();
|
||||
show_regs(regs);
|
||||
print_oops_end_marker();
|
||||
/* Just a warning, don't kill lockdep. */
|
||||
add_taint(BUG_GET_TAINT(bug), LOCKDEP_STILL_OK);
|
||||
__warn(file, line, (void *)bugaddr, BUG_GET_TAINT(bug), regs,
|
||||
NULL);
|
||||
return BUG_TRAP_TYPE_WARN;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue