提交 e0a413f6 编写于 作者: S Steven Rostedt 提交者: Steven Rostedt

tracing: Warn on output if the function tracer was found corrupted

As the function tracer is very intrusive, lots of self checks are
performed on the tracer and if something is found to be strange
it will shut itself down keeping it from corrupting the rest of the
kernel. This shutdown may still allow functions to be traced, as the
tracing only stops new modifications from happening. Trying to stop
the function tracer itself can cause more harm as it requires code
modification.

Although a WARN_ON() is executed, a user may not notice it. To help
the user see that something isn't right with the tracing of the system
a big warning is added to the output of the tracer that lets the user
know that their data may be incomplete.
Reported-by: NThomas Gleixner <tglx@linutronix.de>
Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
上级 e36de1de
...@@ -3862,6 +3862,14 @@ void ftrace_kill(void) ...@@ -3862,6 +3862,14 @@ void ftrace_kill(void)
clear_ftrace_function(); clear_ftrace_function();
} }
/**
* Test if ftrace is dead or not.
*/
int ftrace_is_dead(void)
{
return ftrace_disabled;
}
/** /**
* register_ftrace_function - register a function for profiling * register_ftrace_function - register a function for profiling
* @ops - ops structure that holds the function for profiling. * @ops - ops structure that holds the function for profiling.
......
...@@ -2160,6 +2160,14 @@ void trace_default_header(struct seq_file *m) ...@@ -2160,6 +2160,14 @@ void trace_default_header(struct seq_file *m)
} }
} }
static void test_ftrace_alive(struct seq_file *m)
{
if (!ftrace_is_dead())
return;
seq_printf(m, "# WARNING: FUNCTION TRACING IS CORRUPTED\n");
seq_printf(m, "# MAY BE MISSING FUNCTION EVENTS\n");
}
static int s_show(struct seq_file *m, void *v) static int s_show(struct seq_file *m, void *v)
{ {
struct trace_iterator *iter = v; struct trace_iterator *iter = v;
...@@ -2169,6 +2177,7 @@ static int s_show(struct seq_file *m, void *v) ...@@ -2169,6 +2177,7 @@ static int s_show(struct seq_file *m, void *v)
if (iter->tr) { if (iter->tr) {
seq_printf(m, "# tracer: %s\n", iter->trace->name); seq_printf(m, "# tracer: %s\n", iter->trace->name);
seq_puts(m, "#\n"); seq_puts(m, "#\n");
test_ftrace_alive(m);
} }
if (iter->trace && iter->trace->print_header) if (iter->trace && iter->trace->print_header)
iter->trace->print_header(m); iter->trace->print_header(m);
...@@ -4613,6 +4622,12 @@ __ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode) ...@@ -4613,6 +4622,12 @@ __ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode)
tracing_off(); tracing_off();
/* Did function tracer already get disabled? */
if (ftrace_is_dead()) {
printk("# WARNING: FUNCTION TRACING IS CORRUPTED\n");
printk("# MAY BE MISSING FUNCTION EVENTS\n");
}
if (disable_tracing) if (disable_tracing)
ftrace_kill(); ftrace_kill();
......
...@@ -579,11 +579,13 @@ static inline int ftrace_trace_task(struct task_struct *task) ...@@ -579,11 +579,13 @@ static inline int ftrace_trace_task(struct task_struct *task)
return test_tsk_trace_trace(task); return test_tsk_trace_trace(task);
} }
extern int ftrace_is_dead(void);
#else #else
static inline int ftrace_trace_task(struct task_struct *task) static inline int ftrace_trace_task(struct task_struct *task)
{ {
return 1; return 1;
} }
static inline int ftrace_is_dead(void) { return 0; }
#endif #endif
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册