Skip to content

Commit 892ba7f

Browse files
namhyungacmel
authored andcommitted
perf report: Fix --task and --stat with pipe input
Current 'perf report' fails to process a pipe input when --task or --stat options are used. This is because they reset all the tool callbacks and fails 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 occurs. 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 # Committer testing: Before: $ perf record -o- sleep 1 | perf report -i- --stat Can't parse sample, err = -14 [ perf record: Woken up 1 times to write data ] 0x1350 [0x30]: failed to process type: 9 Error: failed to process sample [ perf record: Captured and wrote 0.000 MB - ] $ After: $ perf record -o- sleep 1 | perf report -i- --stat [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.000 MB - ] Aggregated stats: TOTAL events: 41 COMM events: 2 ( 4.9%) EXIT events: 1 ( 2.4%) SAMPLE events: 9 (22.0%) MMAP2 events: 4 ( 9.8%) ATTR events: 1 ( 2.4%) FINISHED_ROUND events: 1 ( 2.4%) THREAD_MAP events: 1 ( 2.4%) CPU_MAP events: 1 ( 2.4%) EVENT_UPDATE events: 1 ( 2.4%) TIME_CONV events: 1 ( 2.4%) FEATURE events: 19 (46.3%) cycles:uhH stats: SAMPLE events: 9 $ Fixes: a4a4d0a ("perf report: Add --stats option to display quick data statistics") Signed-off-by: Namhyung Kim <[email protected]> Acked-by: Jiri Olsa <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a180bd1 commit 892ba7f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/perf/builtin-report.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,14 @@ static int count_sample_event(struct perf_tool *tool __maybe_unused,
729729
return 0;
730730
}
731731

732+
static int process_attr(struct perf_tool *tool __maybe_unused,
733+
union perf_event *event,
734+
struct evlist **pevlist);
735+
732736
static void stats_setup(struct report *rep)
733737
{
734738
memset(&rep->tool, 0, sizeof(rep->tool));
739+
rep->tool.attr = process_attr;
735740
rep->tool.sample = count_sample_event;
736741
rep->tool.no_warn = true;
737742
}
@@ -753,6 +758,7 @@ static void tasks_setup(struct report *rep)
753758
rep->tool.mmap = perf_event__process_mmap;
754759
rep->tool.mmap2 = perf_event__process_mmap2;
755760
}
761+
rep->tool.attr = process_attr;
756762
rep->tool.comm = perf_event__process_comm;
757763
rep->tool.exit = perf_event__process_exit;
758764
rep->tool.fork = perf_event__process_fork;

0 commit comments

Comments
 (0)