[4/4] perf report: Do not show dummy events with --skip-empty
Commit Message
In system-wide mode, a dummy event was added during the perf record to
save various side-band events like FORK, MMAP and so on. But this dummy
event doesn't have samples for itself so it just wastes the output with
all zero values.
When --skip-empty option is on (by default), it can skip those (dummy)
events without any samples by removing them from the evlist. Users can
disable it using --no-skip-empty command line option or setting the
report.skip-empty config option to false.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/Documentation/perf-report.txt | 3 ++-
tools/perf/builtin-report.c | 14 +++++++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
@@ -609,7 +609,8 @@ include::itrace.txt[]
'Avg Cycles' - block average sampled cycles
--skip-empty::
- Do not print 0 results in the --stat output.
+ Do not print 0 results in the output. This means skipping dummy events
+ in the event list and the --stat output.
include::callchain-overhead-calculation.txt[]
@@ -752,10 +752,22 @@ static int hists__resort_cb(struct hist_entry *he, void *arg)
static void report__output_resort(struct report *rep)
{
struct ui_progress prog;
- struct evsel *pos;
+ struct evsel *pos, *tmp;
ui_progress__init(&prog, rep->nr_entries, "Sorting events for output...");
+ if (rep->skip_empty) {
+ evlist__for_each_entry_safe(rep->session->evlist, tmp, pos) {
+ struct hists *hists = evsel__hists(pos);
+
+ if (hists->nr_entries != 0)
+ continue;
+
+ evlist__remove(rep->session->evlist, pos);
+ evsel__delete(pos);
+ }
+ }
+
evlist__for_each_entry(rep->session->evlist, pos) {
evsel__output_resort_cb(pos, &prog, hists__resort_cb, rep);
}