ftrace: Remove global function list and call function directly
Instead of having a list of global functions that are called, as only one global function is allow to be enabled at a time, there's no reason to have a list. Instead, simply have all the users of the global ops, use the global ops directly, instead of registering their own ftrace_ops. Just switch what function is used before enabling the function tracer. This removes a lot of code as well as the complexity involved with it. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:

committed by
Steven Rostedt

parent
a798c10faf
commit
4104d326b6
@@ -26,8 +26,6 @@ function_trace_call(unsigned long ip, unsigned long parent_ip,
|
||||
static void
|
||||
function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
|
||||
struct ftrace_ops *op, struct pt_regs *pt_regs);
|
||||
static struct ftrace_ops trace_ops;
|
||||
static struct ftrace_ops trace_stack_ops;
|
||||
static struct tracer_flags func_flags;
|
||||
|
||||
/* Our option */
|
||||
@@ -83,28 +81,24 @@ void ftrace_destroy_function_files(struct trace_array *tr)
|
||||
|
||||
static int function_trace_init(struct trace_array *tr)
|
||||
{
|
||||
struct ftrace_ops *ops;
|
||||
ftrace_func_t func;
|
||||
|
||||
if (tr->flags & TRACE_ARRAY_FL_GLOBAL) {
|
||||
/* There's only one global tr */
|
||||
if (!trace_ops.private) {
|
||||
trace_ops.private = tr;
|
||||
trace_stack_ops.private = tr;
|
||||
}
|
||||
|
||||
if (func_flags.val & TRACE_FUNC_OPT_STACK)
|
||||
ops = &trace_stack_ops;
|
||||
else
|
||||
ops = &trace_ops;
|
||||
tr->ops = ops;
|
||||
} else if (!tr->ops) {
|
||||
/*
|
||||
* Instance trace_arrays get their ops allocated
|
||||
* at instance creation. Unless it failed
|
||||
* the allocation.
|
||||
*/
|
||||
/*
|
||||
* Instance trace_arrays get their ops allocated
|
||||
* at instance creation. Unless it failed
|
||||
* the allocation.
|
||||
*/
|
||||
if (!tr->ops)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Currently only the global instance can do stack tracing */
|
||||
if (tr->flags & TRACE_ARRAY_FL_GLOBAL &&
|
||||
func_flags.val & TRACE_FUNC_OPT_STACK)
|
||||
func = function_stack_trace_call;
|
||||
else
|
||||
func = function_trace_call;
|
||||
|
||||
ftrace_init_array_ops(tr, func);
|
||||
|
||||
tr->trace_buffer.cpu = get_cpu();
|
||||
put_cpu();
|
||||
@@ -118,6 +112,7 @@ static void function_trace_reset(struct trace_array *tr)
|
||||
{
|
||||
tracing_stop_function_trace(tr);
|
||||
tracing_stop_cmdline_record();
|
||||
ftrace_reset_array_ops(tr);
|
||||
}
|
||||
|
||||
static void function_trace_start(struct trace_array *tr)
|
||||
@@ -199,18 +194,6 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
static struct ftrace_ops trace_ops __read_mostly =
|
||||
{
|
||||
.func = function_trace_call,
|
||||
.flags = FTRACE_OPS_FL_GLOBAL | FTRACE_OPS_FL_RECURSION_SAFE,
|
||||
};
|
||||
|
||||
static struct ftrace_ops trace_stack_ops __read_mostly =
|
||||
{
|
||||
.func = function_stack_trace_call,
|
||||
.flags = FTRACE_OPS_FL_GLOBAL | FTRACE_OPS_FL_RECURSION_SAFE,
|
||||
};
|
||||
|
||||
static struct tracer_opt func_opts[] = {
|
||||
#ifdef CONFIG_STACKTRACE
|
||||
{ TRACER_OPT(func_stack_trace, TRACE_FUNC_OPT_STACK) },
|
||||
@@ -248,10 +231,10 @@ func_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
|
||||
unregister_ftrace_function(tr->ops);
|
||||
|
||||
if (set) {
|
||||
tr->ops = &trace_stack_ops;
|
||||
tr->ops->func = function_stack_trace_call;
|
||||
register_ftrace_function(tr->ops);
|
||||
} else {
|
||||
tr->ops = &trace_ops;
|
||||
tr->ops->func = function_trace_call;
|
||||
register_ftrace_function(tr->ops);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user