Skip to content

Commit

Permalink
ftrace-graph: Remove dependency of ftrace_stop() from ftrace_graph_st…
Browse files Browse the repository at this point in the history
…op()

ftrace_stop() is going away as it disables parts of function tracing
that affects users that should not be affected. But ftrace_graph_stop()
is built on ftrace_stop(). Here's another example of killing all of
function tracing because something went wrong with function graph
tracing.

Instead of disabling all users of function tracing on function graph
error, disable only function graph tracing.

A new function is created called ftrace_graph_is_dead(). This is called
in strategic paths to prevent function graph from doing more harm and
allowing at least a warning to be printed before the system crashes.

NOTE: ftrace_stop() is still used until all the archs are converted over
to use ftrace_graph_is_dead(). After that, ftrace_stop() will be removed.

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt (Red Hat) committed Jul 17, 2014
1 parent 2b01466 commit 1b2f121
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/linux/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ extern char __irqentry_text_end[];
extern int register_ftrace_graph(trace_func_graph_ret_t retfunc,
trace_func_graph_ent_t entryfunc);

extern bool ftrace_graph_is_dead(void);
extern void ftrace_graph_stop(void);

/* The current handlers in use */
Expand Down
5 changes: 0 additions & 5 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -5473,9 +5473,4 @@ void ftrace_graph_exit_task(struct task_struct *t)

kfree(ret_stack);
}

void ftrace_graph_stop(void)
{
ftrace_stop();
}
#endif
35 changes: 35 additions & 0 deletions kernel/trace/trace_functions_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,38 @@
#include "trace.h"
#include "trace_output.h"

static bool kill_ftrace_graph;

/**
* ftrace_graph_is_dead - returns true if ftrace_graph_stop() was called
*
* ftrace_graph_stop() is called when a severe error is detected in
* the function graph tracing. This function is called by the critical
* paths of function graph to keep those paths from doing any more harm.
*/
bool ftrace_graph_is_dead(void)
{
return kill_ftrace_graph;
}

/**
* ftrace_graph_stop - set to permanently disable function graph tracincg
*
* In case of an error int function graph tracing, this is called
* to try to keep function graph tracing from causing any more harm.
* Usually this is pretty severe and this is called to try to at least
* get a warning out to the user.
*/
void ftrace_graph_stop(void)
{
kill_ftrace_graph = true;
/*
* ftrace_stop() will be removed when all archs are updated to
* use ftrace_graph_is_dead()
*/
ftrace_stop();
}

/* When set, irq functions will be ignored */
static int ftrace_graph_skip_irqs;

Expand Down Expand Up @@ -92,6 +124,9 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
unsigned long long calltime;
int index;

if (unlikely(ftrace_graph_is_dead()))
return -EBUSY;

if (!current->ret_stack)
return -EBUSY;

Expand Down

0 comments on commit 1b2f121

Please sign in to comment.