Messages in this thread | | | Date | Wed, 22 May 2019 23:19:55 +0900 | From | Masami Hiramatsu <> | Subject | Re: [RFC][PATCH 00/14 v2] function_graph: Rewrite to allow multiple users |
| |
On Mon, 20 May 2019 10:20:01 -0400 Steven Rostedt <rostedt@goodmis.org> wrote:
> > The background for this is explained in the V1 version found here: > > http://lkml.kernel.org/r/20181122012708.491151844@goodmis.org > > The TL;DR; is this: > > The function graph tracer required a rewrite, mainly because it > can only allow one callback registered at a time. The main motivation > for this change is to allow kretprobes to use the code of function > graph tracer, which should allow all archs that have function graph > tracing to also have kretprobes with no extra work. > > Masami told me that one requirement was to allow the function entry > callback to store data on the shadow stack that can be retrieved by > the the function return callback. I added this, as well as a per-task > variable (used by one of the function graph users). > > The two functions to allow the storing of data on the stack and > retrieval of it are: > > void *fgraph_reserve_data(int size_in_bytes) > > Allows the entry function to reserve up to 4 words of data on > the shadow stack. On success, a pointer to the contents is returned. > This may be only called once per entry function. > > void *fgraph_retrieve_data(void) > > Allows the return function to retrieve the reserved data that was > allocated by the entry function.
Nice! this seems good for kretprobe too. I'll review and try to port kretprobe on this framework.
Thank you!
> > Note, this code has passed my full test suite. > > Changes since v1: > > - Well, the first part of that series was already merged. > But that was just the preparation for this part. > > - Allocate a page for the shadow stack split it up that way. > When the stack is full, we stop allowing more to be added (stop tracing). > > - Added the reserve and retrieve of private data on the shadow stack > for individual entry/return callbacks to pass data to each other. > > - Added a "per task" data that can be used by a fgraph_ops for all > function callbacks for a specific task. > > Steven Rostedt (VMware) (14): > function_graph: Convert ret_stack to a series of longs > function_graph: Add an array structure that will allow multiple callbacks > function_graph: Allow multiple users to attach to function graph > function_graph: Remove logic around ftrace_graph_entry and return > ftrace/function_graph: Pass fgraph_ops to function graph callbacks > ftrace: Allow function_graph tracer to be enabled in instances > ftrace: Allow ftrace startup flags exist without dynamic ftrace > function_graph: Have the instances use their own ftrace_ops for filtering > function_graph: Add "task variables" per task for fgraph_ops > function_graph: Move set_graph_function tests to shadow stack global var > function_graph: Move graph depth stored data to shadow stack global var > function_graph: Move graph notrace bit to shadow stack global var > function_graph: Implement fgraph_reserve_data() and fgraph_retrieve_data() > function_graph: Add selftest for passing local variables > > ---- > include/linux/ftrace.h | 37 +- > include/linux/sched.h | 2 +- > kernel/trace/fgraph.c | 862 ++++++++++++++++++++++++++++------- > kernel/trace/ftrace.c | 13 +- > kernel/trace/ftrace_internal.h | 2 - > kernel/trace/trace.h | 132 +++--- > kernel/trace/trace_functions.c | 7 + > kernel/trace/trace_functions_graph.c | 96 ++-- > kernel/trace/trace_irqsoff.c | 10 +- > kernel/trace/trace_sched_wakeup.c | 10 +- > kernel/trace/trace_selftest.c | 168 ++++++- > 11 files changed, 1048 insertions(+), 291 deletions(-)
-- Masami Hiramatsu <mhiramat@kernel.org>
| |