Re: [PATCH 3/3] tracing: Rewrite filter logic to be simpler and faster

From: Jiri Olsa
Date: Tue Mar 13 2018 - 06:14:12 EST


On Mon, Mar 12, 2018 at 07:52:45PM -0400, Steven Rostedt wrote:
> On Mon, 12 Mar 2018 19:54:14 +0100
> Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> > On Mon, Mar 12, 2018 at 02:40:01PM -0400, Steven Rostedt wrote:
> > > On Mon, 12 Mar 2018 16:10:17 +0100
> > > Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> > >
> > > > got it crashed when clearing the filter via 'echo > filter'
> > >
> > > Awesome. I'll go and test this out. Thanks!
> > >
> > > Hmm, could you pull my tree and test my branch: ftrace/core. I may have
> > > already fixed this but haven't posted the latest (which I'll do before
> > > pushing to next).
> >
> > I couldn't apply your patches from mailbox so I used your ftrace/core already
> >
>
> Jiri, If you apply the below, does it fix it for you?

yes, the crash is gone and I can set filter ftrace/function,
but I'm still having some issues put that filter through perf

# perf record -e ftrace:function --filter "ip == 0xffffffffa41e8490" ls

but I might be just missing something.. it's been a while ;-) I'm looking to that

jirka


>
> -- Steve
>
> diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
> index a5a131ec3c9c..4099e141188c 100644
> --- a/kernel/trace/trace_events_filter.c
> +++ b/kernel/trace/trace_events_filter.c
> @@ -1498,11 +1498,14 @@ static int process_preds(struct trace_event_call *call,
> return ret;
> }
>
> - prog = predicate_parse(filter_string, nr_parens, nr_preds,
> + if (!nr_preds) {
> + prog = NULL;
> + } else {
> + prog = predicate_parse(filter_string, nr_parens, nr_preds,
> parse_pred, call, pe);
> - if (IS_ERR(prog))
> - return PTR_ERR(prog);
> -
> + if (IS_ERR(prog))
> + return PTR_ERR(prog);
> + }
> rcu_assign_pointer(filter->prog, prog);
> return 0;
> }