linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@gmail.com>
To: Chunyu Hu <chuhu@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V3] tracing: Make latency tracers fully support the set_graph_notrace
Date: Tue, 28 Jun 2016 14:20:02 +0900	[thread overview]
Message-ID: <CADWwUUbeSrnOsiOkDuqYaiEkkfbmHqv_t0bsmreHeRKeZc3Q+Q@mail.gmail.com> (raw)
In-Reply-To: <1466765712-10544-1-git-send-email-chuhu@redhat.com>

Hello,

On Fri, Jun 24, 2016 at 7:55 PM, Chunyu Hu <chuhu@redhat.com> wrote:
> latency tracers(wakeup, wakeup_rt, wakeup_dl, irqsoff) can use the
> function_graph trace when display_graph trace option is set by user
> via tracefs. And currently the set_graph_notrace filter is not fully
> supported in latency tracers, only the graph_ret event can be filtered,
> the graph_ent events will always be submitted to the trace ring buffer
> without respecting to the filter.
>
> The issue is that the submitted graph_entry event that matches the
> filter can be assigned with a negative depth(minuts FTRACE_NOTRACE_DEPTH)
> which will be used as the array index of fgraph_cpu_data when printing
> trace entries, as a result, an oops can be hit when accessing the array.
>
> Fully supporting the set_graph_notrace filter in latency tracers can
> avoid this oops and provide a small enhancement for these tracers at
> the same time.
>
> To reproduce the oops:
> echo 1 > options/display_graph
> echo schedule > set_graph_notrace
> echo wakeup > current_tracer
> cat trace (several times)

I'm unabled to reproduce the oops even after running 'cat trace' multiple times.

Anyway, the patch looks good to me.

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


>
> Signed-off-by: Chunyu Hu <chuhu@redhat.com>
> ---
>  kernel/trace/trace_irqsoff.c      | 6 ++++++
>  kernel/trace/trace_sched_wakeup.c | 6 ++++++
>  2 files changed, 12 insertions(+)
>
> diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
> index 03cdff8..a4ed46a 100644
> --- a/kernel/trace/trace_irqsoff.c
> +++ b/kernel/trace/trace_irqsoff.c
> @@ -175,6 +175,12 @@ static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
>         int ret;
>         int pc;
>
> +       if (trace->depth < 0)
> +               return 0;
> +
> +       if (ftrace_graph_notrace_addr(trace->func))
> +               return 1;
> +
>         if (!func_prolog_dec(tr, &data, &flags))
>                 return 0;
>
> diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
> index 9d4399b..e54fff7 100644
> --- a/kernel/trace/trace_sched_wakeup.c
> +++ b/kernel/trace/trace_sched_wakeup.c
> @@ -239,6 +239,12 @@ static int wakeup_graph_entry(struct ftrace_graph_ent *trace)
>         unsigned long flags;
>         int pc, ret = 0;
>
> +       if (trace->depth < 0)
> +               return 0;
> +
> +       if (ftrace_graph_notrace_addr(trace->func))
> +               return 1;
> +
>         if (!func_prolog_preempt_disable(tr, &data, &pc))
>                 return 0;
>
> --
> 1.8.3.1
>

  reply	other threads:[~2016-06-28  5:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-24 10:55 [PATCH V3] tracing: Make latency tracers fully support the set_graph_notrace Chunyu Hu
2016-06-28  5:20 ` Namhyung Kim [this message]
2016-06-28  8:03   ` Chunyu Hu
2016-06-28 20:03     ` Steven Rostedt
2016-06-28 23:36       ` Chunyu Hu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADWwUUbeSrnOsiOkDuqYaiEkkfbmHqv_t0bsmreHeRKeZc3Q+Q@mail.gmail.com \
    --to=namhyung@gmail.com \
    --cc=chuhu@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).