Skip to content

Commit c143b77

Browse files
Cheng Jianrostedt
authored andcommitted
ftrace: show debugging information when panic_on_warn set
When an anomaly is detected in the function call modification code, ftrace_bug() is called to disable function tracing as well as give some warn and information that may help debug the problem. But currently, we call FTRACE_WARN_ON_ONCE() first in ftrace_bug(), so when panic_on_warn is set, we can't see the debugging information here. Call FTRACE_WARN_ON_ONCE() at the end of ftrace_bug() to ensure that the debugging information is displayed first. after this patch, the dmesg looks like: ------------[ ftrace bug ]------------ ftrace failed to modify [<ffff800010081004>] bcm2835_handle_irq+0x4/0x58 actual: 1f:20:03:d5 Setting ftrace call site to call ftrace function ftrace record flags: 80000001 (1) expected tramp: ffff80001009d6f0 ------------[ cut here ]------------ WARNING: CPU: 2 PID: 1635 at kernel/trace/ftrace.c:2078 ftrace_bug+0x204/0x238 Kernel panic - not syncing: panic_on_warn set ... CPU: 2 PID: 1635 Comm: sh Not tainted 5.7.0-rc5-00033-gb922183867f5 #14 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace+0x0/0x1b0 show_stack+0x20/0x30 dump_stack+0xc0/0x10c panic+0x16c/0x368 __warn+0x120/0x160 report_bug+0xc8/0x160 bug_handler+0x28/0x98 brk_handler+0x70/0xd0 do_debug_exception+0xcc/0x1ac el1_sync_handler+0xe4/0x120 el1_sync+0x7c/0x100 ftrace_bug+0x204/0x238 Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Cheng Jian <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent b9bbe6e commit c143b77

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernel/trace/ftrace.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,14 +2027,14 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)
20272027
{
20282028
unsigned long ip = rec ? rec->ip : 0;
20292029

2030+
pr_info("------------[ ftrace bug ]------------\n");
2031+
20302032
switch (failed) {
20312033
case -EFAULT:
2032-
FTRACE_WARN_ON_ONCE(1);
20332034
pr_info("ftrace faulted on modifying ");
20342035
print_ip_sym(ip);
20352036
break;
20362037
case -EINVAL:
2037-
FTRACE_WARN_ON_ONCE(1);
20382038
pr_info("ftrace failed to modify ");
20392039
print_ip_sym(ip);
20402040
print_ip_ins(" actual: ", (unsigned char *)ip);
@@ -2045,12 +2045,10 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)
20452045
}
20462046
break;
20472047
case -EPERM:
2048-
FTRACE_WARN_ON_ONCE(1);
20492048
pr_info("ftrace faulted on writing ");
20502049
print_ip_sym(ip);
20512050
break;
20522051
default:
2053-
FTRACE_WARN_ON_ONCE(1);
20542052
pr_info("ftrace faulted on unknown error ");
20552053
print_ip_sym(ip);
20562054
}
@@ -2077,6 +2075,8 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)
20772075
ip = ftrace_get_addr_curr(rec);
20782076
pr_cont("\n expected tramp: %lx\n", ip);
20792077
}
2078+
2079+
FTRACE_WARN_ON_ONCE(1);
20802080
}
20812081

20822082
static int ftrace_check_record(struct dyn_ftrace *rec, bool enable, bool update)

0 commit comments

Comments
 (0)