tracing: function graph cleanups for the next merge window
Subsystems (3)
Steven Rostedt
maintainercover tracing: function graph cleanups for the next merge window
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next
Head SHA1: 070ea1a24f403b68e76d9763cedd061917f6e1c1
Steven Rostedt (VMware) (5):
ftrace: Remove ASSIGN_OPS_HASH() macro from ftrace.c
ftrace: Do not process STUB functions in ftrace_ops_list_func()
function_graph: Have selftest also emulate tr->reset() as it did with tr->init()
function_graph: Use a ftrace_graph_ret_stub() for return
function_graph: Place ftrace_graph_entry_stub() prototype in include/linux/ftrace.h
----
arch/nds32/kernel/ftrace.c | 1 - arch/parisc/kernel/ftrace.c | 1 - include/linux/ftrace.h | 2 ++ kernel/trace/fgraph.c | 9 ++++++--- kernel/trace/ftrace.c | 7 +++---- kernel/trace/trace_selftest.c | 5 ++++- 6 files changed, 15 insertions(+), 10 deletions(-)
Steven Rostedt
maintainerPATCH 1/5 ftrace: Remove ASSIGN_OPS_HASH() macro from ftrace.c
From: "Steven Rostedt (VMware)" <[email protected]>
The ASSIGN_OPS_HASH() macro was moved to fgraph.c where it was used, but for some reason it wasn't removed from ftrace.c, as it is no longer referenced there.
--- kernel/trace/ftrace.c | 4 ---- 1 file changed, 4 deletions(-)
kernel/trace/ftrace.c +0 -4
@@ -69,12 +69,8 @@#define INIT_OPS_HASH (opsname) \ .func_hash = &opsname.local_hash, \ .local_hash.regex_lock = __MUTEX_INITIALIZER(opsname.local_hash.regex_lock), -#define ASSIGN_OPS_HASH (opsname, val) \ - .func_hash = val, \ - .local_hash.regex_lock = __MUTEX_INITIALIZER(opsname.local_hash.regex_lock),#else #define INIT_OPS_HASH (opsname) -#define ASSIGN_OPS_HASH (opsname, val)#endif enum {
Signature · 1 line
2.20.1
Steven Rostedt
maintainerPATCH 2/5 ftrace: Do not process STUB functions in ftrace_ops_list_func()
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
The function_graph tracer has a stub function and its ops flag has the FTRACE_OPS_FL_STUB set. As the function graph does not use the ftrace_ops->func pointer but instead is called by a separate part of the ftrace trampoline. The function_graph tracer still requires to pass in a ftrace_ops that may also hold the hash of the functions to call. But there's no reason to test that hash in the function tracing portion. Instead of testing to see if we should call the stub function, just test if the ops has FTRACE_OPS_FL_STUB set, and just skip it.
--- kernel/trace/ftrace.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/trace/ftrace.c +3 -0
@@ -6260,6 +6260,9 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,preempt_disable_notrace ();do_for_each_ftrace_op (op, ftrace_ops_list) { +/* Stub functions don't need to be called nor tested */ +if (op->flags &FTRACE_OPS_FL_STUB ) +continue ;/* * Check the following for each ops before calling their func: * if RCU flag is set, then rcu_is_watching() must be true
Signature · 1 line
2.20.1
Steven Rostedt
maintainerPATCH 3/5 function_graph: Have selftest also emulate tr->reset() as it did with tr->init()
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
The function_graph boot up self test emulates the tr->init() function in order to add a wrapper around the function graph tracer entry code to test for lock ups and such. But it does not emulate the tr->reset(), and just calls the function_graph tracer tr->reset() function which will use its own fgraph_ops to unregister function tracing with. As the fgraph_ops is becoming more meaningful with the register_ftrace_graph() and unregister_ftrace_graph() functions, the two need to be the same. The emulated tr->init() uses its own fgraph_ops descriptor, which means the unregister_ftrace_graph() must use the same ftrace_ops, which the selftest currently does not do. By emulating the tr->reset() as the selftest does with the tr->init() it will be able to pass the same fgraph_ops descriptor to the unregister_ftrace_graph() as it did with the register_ftrace_graph().
--- kernel/trace/trace_selftest.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/trace/trace_selftest.c +4 -1
@@ -792,7 +792,10 @@ trace_selftest_startup_function_graph(struct tracer *trace,/* check the trace buffer */ ret =trace_test_buffer (&tr->trace_buffer, &count); - trace->reset (tr); +/* Need to also simulate the tr->reset to remove this fgraph_ops */ +tracing_stop_cmdline_record (); +unregister_ftrace_graph (&fgraph_ops); +tracing_start ();if (!ret && !count) {
Signature · 1 line
2.20.1
Steven Rostedt
maintainerPATCH 4/5 function_graph: Use a ftrace_graph_ret_stub() for return
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
There's a unique ftrace_graph_entry_stub() for the entryfunc of a fgraph_ops, but the ftrace_stub is used for the retfunc(). To be consistent and also to use the same type of function as the type being called for retfunc(), create and use ftrace_graph_ret_stub().
--- kernel/trace/fgraph.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
kernel/trace/fgraph.c +6 -3
@@ -327,14 +327,17 @@ void ftrace_graph_sleep_time_control(bool enable) fgraph_sleep_time = enable; } +static void ftrace_graph_ret_stub (struct ftrace_graph_ret *trace) +{ +} +int ftrace_graph_entry_stub (struct ftrace_graph_ent *trace) {return 0 ; }/* The callbacks that hook a function */ -trace_func_graph_ret_t ftrace_graph_return = - (trace_func_graph_ret_t )ftrace_stub; +trace_func_graph_ret_t ftrace_graph_return = ftrace_graph_ret_stub;trace_func_graph_ent_t ftrace_graph_entry = ftrace_graph_entry_stub;static trace_func_graph_ent_t __ftrace_graph_entry = ftrace_graph_entry_stub;
@@ -614,7 +617,7 @@ void unregister_ftrace_graph(struct fgraph_ops *gops) goto out; ftrace_graph_active--; - ftrace_graph_return = (trace_func_graph_ret_t )ftrace_stub; + ftrace_graph_return = ftrace_graph_ret_stub; ftrace_graph_entry = ftrace_graph_entry_stub; __ftrace_graph_entry = ftrace_graph_entry_stub;ftrace_shutdown (&graph_ops,FTRACE_STOP_FUNC_RET );
Signature · 1 line
2.20.1
Steven Rostedt
maintainerPATCH 5/5 function_graph: Place ftrace_graph_entry_stub() prototype in include/linux/ftrace.h
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
ftrace_graph_entry_stub() is defined in generic code, its prototype should be in the generic header and not defined throughout architecture specific code in order to use it.
--- arch/nds32/kernel/ftrace.c | 1 - arch/parisc/kernel/ftrace.c | 1 - include/linux/ftrace.h | 2 ++ 3 files changed, 2 insertions(+), 2 deletions(-)
arch/nds32/kernel/ftrace.c +0 -1
@@ -7,7 +7,6 @@#ifndef CONFIG_DYNAMIC_FTRACE extern void (*ftrace_trace_function)(unsigned long ,unsigned long ,struct ftrace_ops *,struct pt_regs *); -extern int ftrace_graph_entry_stub (struct ftrace_graph_ent *trace);extern void ftrace_graph_caller (void ); noinline void __naked ftrace_stub(unsigned long ip, unsigned long parent_ip,
arch/parisc/kernel/ftrace.c +0 -1
@@ -51,7 +51,6 @@ void notrace __hot ftrace_function_trampoline(unsigned long parent, unsigned long org_sp_gr3) {extern ftrace_func_t ftrace_trace_function;/* depends on CONFIG_DYNAMIC_FTRACE */ -extern int ftrace_graph_entry_stub (struct ftrace_graph_ent *trace);if (ftrace_trace_function != ftrace_stub) {/* struct ftrace_ops *op, struct pt_regs *regs); */
include/linux/ftrace.h +2 -0
@@ -751,6 +751,8 @@ struct ftrace_graph_ret {typedef void (*trace_func_graph_ret_t )(struct ftrace_graph_ret *);/* return */ typedef int (*trace_func_graph_ent_t )(struct ftrace_graph_ent *);/* entry */ +extern int ftrace_graph_entry_stub (struct ftrace_graph_ent *trace); +#ifdef CONFIG_FUNCTION_GRAPH_TRACER struct fgraph_ops {
Signature · 1 line
2.20.1