2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-17 17:53:56 +08:00

perf list: Remove blank lines, headers when piping output

So that one can, for instance, use it with wc -l:

  # perf list *:*write* | wc -l
  60

Or to look for the "bio" tracepoints, without 'perf list' headers:

  # perf list *:*bio* | head
    block:block_bio_backmerge                          [Tracepoint event]
    block:block_bio_bounce                             [Tracepoint event]
    block:block_bio_complete                           [Tracepoint event]
    block:block_bio_frontmerge                         [Tracepoint event]
    block:block_bio_queue                              [Tracepoint event]
    block:block_bio_remap                              [Tracepoint event]
  #

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-ts7sc0x8u4io4cifzkup4j44@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2015-09-30 17:13:26 -03:00
parent 6cca13bdf5
commit dfc431cbdc
3 changed files with 9 additions and 8 deletions

View File

@ -36,7 +36,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
setup_pager(); setup_pager();
if (!raw_dump) if (!raw_dump && pager_in_use())
printf("\nList of pre-defined events (to be used in -e):\n\n"); printf("\nList of pre-defined events (to be used in -e):\n\n");
if (argc == 0) { if (argc == 0) {

View File

@ -1534,7 +1534,7 @@ restart:
printf(" %-50s [%s]\n", evt_list[evt_i++], printf(" %-50s [%s]\n", evt_list[evt_i++],
event_type_descriptors[PERF_TYPE_TRACEPOINT]); event_type_descriptors[PERF_TYPE_TRACEPOINT]);
} }
if (evt_num) if (evt_num && pager_in_use())
printf("\n"); printf("\n");
out_free: out_free:
@ -1690,7 +1690,7 @@ restart:
printf(" %-50s [%s]\n", evt_list[evt_i++], printf(" %-50s [%s]\n", evt_list[evt_i++],
event_type_descriptors[PERF_TYPE_HW_CACHE]); event_type_descriptors[PERF_TYPE_HW_CACHE]);
} }
if (evt_num) if (evt_num && pager_in_use())
printf("\n"); printf("\n");
out_free: out_free:
@ -1763,7 +1763,7 @@ restart:
} }
printf(" %-50s [%s]\n", evt_list[evt_i++], event_type_descriptors[type]); printf(" %-50s [%s]\n", evt_list[evt_i++], event_type_descriptors[type]);
} }
if (evt_num) if (evt_num && pager_in_use())
printf("\n"); printf("\n");
out_free: out_free:
@ -1804,13 +1804,14 @@ void print_events(const char *event_glob, bool name_only)
printf(" %-50s [%s]\n", printf(" %-50s [%s]\n",
"cpu/t1=v1[,t2=v2,t3 ...]/modifier", "cpu/t1=v1[,t2=v2,t3 ...]/modifier",
event_type_descriptors[PERF_TYPE_RAW]); event_type_descriptors[PERF_TYPE_RAW]);
printf(" (see 'man perf-list' on how to encode it)\n"); if (pager_in_use())
printf("\n"); printf(" (see 'man perf-list' on how to encode it)\n\n");
printf(" %-50s [%s]\n", printf(" %-50s [%s]\n",
"mem:<addr>[/len][:access]", "mem:<addr>[/len][:access]",
event_type_descriptors[PERF_TYPE_BREAKPOINT]); event_type_descriptors[PERF_TYPE_BREAKPOINT]);
printf("\n"); if (pager_in_use())
printf("\n");
} }
print_tracepoint_events(NULL, NULL, name_only); print_tracepoint_events(NULL, NULL, name_only);

View File

@ -1026,7 +1026,7 @@ void print_pmu_events(const char *event_glob, bool name_only)
printf(" %-50s [Kernel PMU event]\n", aliases[j]); printf(" %-50s [Kernel PMU event]\n", aliases[j]);
printed++; printed++;
} }
if (printed) if (printed && pager_in_use())
printf("\n"); printf("\n");
out_free: out_free:
for (j = 0; j < len; j++) for (j = 0; j < len; j++)