Re: [for-next][PATCH 7/8] fgraph: Handle a case where a tracer ignores set_graph_notrace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 12, 2016 at 11:49:20AM -0500, Steven Rostedt wrote:
> On Tue, 13 Dec 2016 01:30:01 +0900
> Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> 
> 
> > Sorry to miss updating those tracers.  I guess it's no more necessary once
> > the patch 8 is applied so that functions in the notrace filter will not be
> > recorded.
> > 
> > Or maybe we need to change the prepare_ftrace_return() so that the
> > graph_entry callback should be called after ftrace_push_return_trace() as
> > some archs do.
> 
> I plan on updating fgraph in general so this should all be handled then.

ok

> 
> > 
> > >
> > > Have the print functions handle cases where a tracer still records functions
> > > even when they are in set_graph_notrace.  
> > 
> > I think it'd be better (or consistent, at least) not printing negative index
> > records rather than showing entry only.
> 
> I thought about this too, but I'm more concerned about it not crashing
> the kernel than to show a proper trace. The fix will just make sure it
> doesn't crash.

ok

> 
> > 
> > >
> > > Also add warnings if the depth is below zero before accessing the array.
> > >
> > > Note, the function graph logic will still prevent the return of these
> > > functions from being recorded, which means that they will be left hanging
> > > without a return. For example:
> > >
> > >    # echo '*spin*' > set_graph_notrace
> > >    # echo 1 > options/display-graph
> > >    # echo wakeup > current_tracer
> > >    # cat trace
> > >    [...]
> > >       _raw_spin_lock() {
> > >         preempt_count_add() {
> > >         do_raw_spin_lock() {
> > >       update_rq_clock();
> > >
> > > Where it should look like:
> > >
> > >       _raw_spin_lock() {
> > >         preempt_count_add();
> > >         do_raw_spin_lock();
> > >       }
> > >       update_rq_clock();  
> > 
> > If set_graph_notrace works correctly, it should be just:
> > 
> >          update_rq_clock();
> 
> Which is what it should look like after patch 8. But I didn't mark 8 as
> stable as that's more of a feature. As wakeup and irqsoff doesn't use
> notrace yet. Yeah, notrace may break it a bit, but since this is the
> first someone noticed it, I don't think it's used much.
> 
> I wanted the simplest fix for stable.

I think a simpler fix is just to return when it sees a negative record..


diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 52fb1e21b86b..2fb73c2e35b5 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -844,7 +844,7 @@ print_graph_entry_leaf(struct trace_iterator *iter,
 
                /* If a graph tracer ignored set_graph_notrace */
                if (call->depth < -1)
-                       call->depth += FTRACE_NOTRACE_DEPTH;
+                       return TRACE_TYPE_HANDLED;
 
                /*
                 * Comments display at + 1 to depth. Since
@@ -887,7 +887,7 @@ print_graph_entry_nested(struct trace_iterator *iter,
 
                /* If a graph tracer ignored set_graph_notrace */
                if (call->depth < -1)
-                       call->depth += FTRACE_NOTRACE_DEPTH;
+                       return TRACE_TYPE_HANDLED;
 
                cpu_data = per_cpu_ptr(data->cpu_data, cpu);
                cpu_data->depth = call->depth;


Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]