* [PATCH] perf report: Fix --task and --stat with pipe input
@ 2021-06-30 4:30 Namhyung Kim
2021-07-02 10:38 ` Jiri Olsa
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2021-06-30 4:30 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Jiri Olsa
Cc: Ingo Molnar, Peter Zijlstra, LKML, Andi Kleen, Ian Rogers
Current perf report fails to process a pipe input when --task
or --stat option is used. This is because they reset all the
tool callbacks and failed to find a matching event for a sample.
When pipe input is used, the event info is passed via ATTR records
so it needs to handle that operation. Otherwise the following error
occurred. Note, -14 (= -EFAULT) comes from evlist__parse_sample():
# perf record -a -o- sleep 1 | perf report -i- --stat
Can't parse sample, err = -14
0x271044 [0x38]: failed to process type: 9
Error:
failed to process sample
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-report.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index bc5c393021dc..8639bbe0969d 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -729,9 +729,14 @@ static int count_sample_event(struct perf_tool *tool __maybe_unused,
return 0;
}
+static int process_attr(struct perf_tool *tool __maybe_unused,
+ union perf_event *event,
+ struct evlist **pevlist);
+
static void stats_setup(struct report *rep)
{
memset(&rep->tool, 0, sizeof(rep->tool));
+ rep->tool.attr = process_attr;
rep->tool.sample = count_sample_event;
rep->tool.no_warn = true;
}
@@ -753,6 +758,7 @@ static void tasks_setup(struct report *rep)
rep->tool.mmap = perf_event__process_mmap;
rep->tool.mmap2 = perf_event__process_mmap2;
}
+ rep->tool.attr = process_attr;
rep->tool.comm = perf_event__process_comm;
rep->tool.exit = perf_event__process_exit;
rep->tool.fork = perf_event__process_fork;
--
2.32.0.93.g670b81a890-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] perf report: Fix --task and --stat with pipe input
2021-06-30 4:30 [PATCH] perf report: Fix --task and --stat with pipe input Namhyung Kim
@ 2021-07-02 10:38 ` Jiri Olsa
2021-07-02 12:46 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Olsa @ 2021-07-02 10:38 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, LKML,
Andi Kleen, Ian Rogers
On Tue, Jun 29, 2021 at 09:30:58PM -0700, Namhyung Kim wrote:
> Current perf report fails to process a pipe input when --task
> or --stat option is used. This is because they reset all the
> tool callbacks and failed to find a matching event for a sample.
>
> When pipe input is used, the event info is passed via ATTR records
> so it needs to handle that operation. Otherwise the following error
> occurred. Note, -14 (= -EFAULT) comes from evlist__parse_sample():
>
> # perf record -a -o- sleep 1 | perf report -i- --stat
> Can't parse sample, err = -14
> 0x271044 [0x38]: failed to process type: 9
> Error:
> failed to process sample
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
thanks,
jirka
> ---
> tools/perf/builtin-report.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index bc5c393021dc..8639bbe0969d 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -729,9 +729,14 @@ static int count_sample_event(struct perf_tool *tool __maybe_unused,
> return 0;
> }
>
> +static int process_attr(struct perf_tool *tool __maybe_unused,
> + union perf_event *event,
> + struct evlist **pevlist);
> +
> static void stats_setup(struct report *rep)
> {
> memset(&rep->tool, 0, sizeof(rep->tool));
> + rep->tool.attr = process_attr;
> rep->tool.sample = count_sample_event;
> rep->tool.no_warn = true;
> }
> @@ -753,6 +758,7 @@ static void tasks_setup(struct report *rep)
> rep->tool.mmap = perf_event__process_mmap;
> rep->tool.mmap2 = perf_event__process_mmap2;
> }
> + rep->tool.attr = process_attr;
> rep->tool.comm = perf_event__process_comm;
> rep->tool.exit = perf_event__process_exit;
> rep->tool.fork = perf_event__process_fork;
> --
> 2.32.0.93.g670b81a890-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] perf report: Fix --task and --stat with pipe input
2021-07-02 10:38 ` Jiri Olsa
@ 2021-07-02 12:46 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-07-02 12:46 UTC (permalink / raw)
To: Jiri Olsa
Cc: Namhyung Kim, Ingo Molnar, Peter Zijlstra, LKML, Andi Kleen,
Ian Rogers, stable
Em Fri, Jul 02, 2021 at 12:38:09PM +0200, Jiri Olsa escreveu:
> On Tue, Jun 29, 2021 at 09:30:58PM -0700, Namhyung Kim wrote:
> > Current perf report fails to process a pipe input when --task
> > or --stat option is used. This is because they reset all the
> > tool callbacks and failed to find a matching event for a sample.
> >
> > When pipe input is used, the event info is passed via ATTR records
> > so it needs to handle that operation. Otherwise the following error
> > occurred. Note, -14 (= -EFAULT) comes from evlist__parse_sample():
> >
> > # perf record -a -o- sleep 1 | perf report -i- --stat
> > Can't parse sample, err = -14
> > 0x271044 [0x38]: failed to process type: 9
> > Error:
> > failed to process sample
> >
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>
> Acked-by: Jiri Olsa <jolsa@redhat.com>
Added this for the the benefit of stable@kernel.org:
Fixes: a4a4d0a7a2b20f78 ("perf report: Add --stats option to display quick data statistics")
> thanks,
> jirka
>
> > ---
> > tools/perf/builtin-report.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> > index bc5c393021dc..8639bbe0969d 100644
> > --- a/tools/perf/builtin-report.c
> > +++ b/tools/perf/builtin-report.c
> > @@ -729,9 +729,14 @@ static int count_sample_event(struct perf_tool *tool __maybe_unused,
> > return 0;
> > }
> >
> > +static int process_attr(struct perf_tool *tool __maybe_unused,
> > + union perf_event *event,
> > + struct evlist **pevlist);
> > +
> > static void stats_setup(struct report *rep)
> > {
> > memset(&rep->tool, 0, sizeof(rep->tool));
> > + rep->tool.attr = process_attr;
> > rep->tool.sample = count_sample_event;
> > rep->tool.no_warn = true;
> > }
> > @@ -753,6 +758,7 @@ static void tasks_setup(struct report *rep)
> > rep->tool.mmap = perf_event__process_mmap;
> > rep->tool.mmap2 = perf_event__process_mmap2;
> > }
> > + rep->tool.attr = process_attr;
> > rep->tool.comm = perf_event__process_comm;
> > rep->tool.exit = perf_event__process_exit;
> > rep->tool.fork = perf_event__process_fork;
> > --
> > 2.32.0.93.g670b81a890-goog
> >
>
--
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-02 12:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-30 4:30 [PATCH] perf report: Fix --task and --stat with pipe input Namhyung Kim
2021-07-02 10:38 ` Jiri Olsa
2021-07-02 12:46 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.