Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1699067
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 05/15] perf sort: Use default sort if evlist is empty |
| Date | 2017-07-28 22:10 +0200 |
| Message-ID | <u8jKc-8pF-33@gated-at.bofh.it> (permalink) |
| References | <u8jK9-8pF-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: David Carrillo-Cisneros <davidcc@google.com>
Fixes bug noted by Jiri in https://lkml.org/lkml/2017/6/13/755 and
caused by commit d49dadea7862 ("perf tools: Make 'trace' or
'trace_fields' sort key default for tracepoint events") not taking into
account that evlist is empty in pipe-mode.
Before this commit, pipe mode will only show bogus "100.00% N/A"
instead of correct output as follows:
$ perf record -o - sleep 1 | perf report -i -
# To display the perf.data header info, please use --header/--header-only options.
#
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]
#
# Total Lost Samples: 0
#
# Samples: 8 of event 'cycles:ppH'
# Event count (approx.): 145658
#
# Overhead Trace output
# ........ ............
#
100.00% N/A
Correct output, after patch:
$ perf record -o - sleep 1 | perf report -i -
# To display the perf.data header info, please use --header/--header-only options.
#
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]
#
# Total Lost Samples: 0
#
# Samples: 8 of event 'cycles:ppH'
# Event count (approx.): 191331
#
# Overhead Command Shared Object Symbol
# ........ ....... ................. .................................
#
81.63% sleep libc-2.19.so [.] _exit
13.58% sleep ld-2.19.so [.] do_lookup_x
2.34% sleep [kernel.kallsyms] [k] context_switch
2.34% sleep libc-2.19.so [.] __GI___libc_nanosleep
0.11% perf [kernel.kallsyms] [k] __intel_pmu_enable_a
Reported-by: Jiri Olsa <jolsa@kernel.org>
Report-Link: https://lkml.kernel.org/r/20170613185422.GA6092@krava
Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Turner <pjt@google.com>
Cc: Simon Que <sque@chromium.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: d49dadea7862 ("perf tools: Make 'trace' or 'trace_fields' sort key default for tracepoint events")
Link: https://lkml.kernel.org/r/20170721051157.47331-1-davidcc@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/evlist.h | 5 +++++
tools/perf/util/sort.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 0843746bc389..bf2c4936e35f 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -265,6 +265,11 @@ bool perf_evlist__valid_read_format(struct perf_evlist *evlist);
void perf_evlist__splice_list_tail(struct perf_evlist *evlist,
struct list_head *list);
+static inline bool perf_evlist__empty(struct perf_evlist *evlist)
+{
+ return list_empty(&evlist->entries);
+}
+
static inline struct perf_evsel *perf_evlist__first(struct perf_evlist *evlist)
{
return list_entry(evlist->entries.next, struct perf_evsel, node);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 8b327c955a4f..12359bd986db 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2563,7 +2563,7 @@ static const char *get_default_sort_order(struct perf_evlist *evlist)
BUG_ON(sort__mode >= ARRAY_SIZE(default_sort_orders));
- if (evlist == NULL)
+ if (evlist == NULL || perf_evlist__empty(evlist))
goto out_no_evlist;
evlist__for_each_entry(evlist, evsel) {
--
2.9.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-28 22:10 +0200 [PATCH 03/15] perf stat: Use group read for event groups Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-28 22:10 +0200 [PATCH 05/15] perf sort: Use default sort if evlist is empty Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-28 22:10 +0200 [PATCH 14/15] perf data: Add mmap[2] events to CTF conversion Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-28 22:10 +0200 [PATCH 09/15] perf annotate TUI: Fix --show-total-period Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-28 22:10 +0200 Re: [GIT PULL 00/15] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2017-07-30 11:40 +0200 [PATCH] perf build: Clarify header version warning message Ingo Molnar <mingo@kernel.org> - 2017-07-30 11:40 +0200 perf build: Clarify open-coded header version warning message Ingo Molnar <mingo@kernel.org> - 2017-07-30 12:00 +0200 tools/include: Sync kernel ABI headers with tooling headers Ingo Molnar <mingo@kernel.org> - 2017-07-30 12:00 +0200
csiph-web