mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
perf sort: Use default sort if evlist is empty
Fixes bug noted by Jiri in https://lkml.org/lkml/2017/6/13/755 and caused by commitd49dadea78("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 <[email protected]> Report-Link: https://lkml.kernel.org/r/20170613185422.GA6092@krava Signed-off-by: David Carrillo-Cisneros <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Paul Turner <[email protected]> Cc: Simon Que <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Wang Nan <[email protected]> Fixes:d49dadea78("perf tools: Make 'trace' or 'trace_fields' sort key default for tracepoint events") Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
parent
c6c13be76c
commit
64831a21db
2 changed files with 6 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue