Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1238594

[PATCH 06/10] perf list: Do event name substring search as last resort when no events found

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 06/10] perf list: Do event name substring search as last resort when no events found
Date 2015-10-02 22:30 +0200
Message-ID <qff7R-5Cf-35@gated-at.bofh.it> (permalink)
References <qff7P-5Cf-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Arnaldo Carvalho de Melo <acme@redhat.com>

Before:

  # perf list _alloc_ | head -10
  #

After:

  # perf list _alloc_ | head -10
    ext4:ext4_alloc_da_blocks                          [Tracepoint event]
    ext4:ext4_get_implied_cluster_alloc_exit           [Tracepoint event]
    kmem:kmem_cache_alloc_node                         [Tracepoint event]
    kmem:mm_page_alloc_extfrag                         [Tracepoint event]
    kmem:mm_page_alloc_zone_locked                     [Tracepoint event]
    xen:xen_mmu_alloc_ptpage                           [Tracepoint event]
  #

And it works for all types of events:

  # perf list br

  List of pre-defined events (to be used in -e):

    branch-instructions OR branches                    [Hardware event]
    branch-misses                                      [Hardware event]

    branch-load-misses                                 [Hardware cache event]
    branch-loads                                       [Hardware cache event]

    branch-instructions OR cpu/branch-instructions/    [Kernel PMU event]
    branch-misses OR cpu/branch-misses/                [Kernel PMU event]

    filelock:break_lease_block                         [Tracepoint event]
    filelock:break_lease_noblock                       [Tracepoint event]
    filelock:break_lease_unblock                       [Tracepoint event]
    syscalls:sys_enter_brk                             [Tracepoint event]
    syscalls:sys_exit_brk                              [Tracepoint event]

  #

Suggested-by: Ingo Molnar <mingo@kernel.org>
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-qieivl18jdemoaghgndj36e6@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-list.txt |  2 ++
 tools/perf/builtin-list.c              | 18 ++++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt
index bada8933fdd4..ad60c6ea1997 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -125,6 +125,8 @@ To limit the list use:
 . If none of the above is matched, it will apply the supplied glob to all
   events, printing the ones that match.
 
+. As a last resort, it will do a substring search in all event names.
+
 One or more types can be used at the same time, listing the events for the
 types specified.
 
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 602414040344..bf679e2c978b 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -45,6 +45,8 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 	}
 
 	for (i = 0; i < argc; ++i) {
+		char *sep, *s;
+
 		if (strcmp(argv[i], "tracepoint") == 0)
 			print_tracepoint_events(NULL, NULL, raw_dump);
 		else if (strcmp(argv[i], "hw") == 0 ||
@@ -60,8 +62,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 			print_hwcache_events(NULL, raw_dump);
 		else if (strcmp(argv[i], "pmu") == 0)
 			print_pmu_events(NULL, raw_dump);
-		else {
-			char *sep = strchr(argv[i], ':'), *s;
+		else if ((sep = strchr(argv[i], ':')) != NULL) {
 			int sep_idx;
 
 			if (sep == NULL) {
@@ -76,6 +77,19 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 			s[sep_idx] = '\0';
 			print_tracepoint_events(s, s + sep_idx + 1, raw_dump);
 			free(s);
+		} else {
+			if (asprintf(&s, "*%s*", argv[i]) < 0) {
+				printf("Critical: Not enough memory! Trying to continue...\n");
+				continue;
+			}
+			print_symbol_events(s, PERF_TYPE_HARDWARE,
+					    event_symbols_hw, PERF_COUNT_HW_MAX, raw_dump);
+			print_symbol_events(s, PERF_TYPE_SOFTWARE,
+					    event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump);
+			print_hwcache_events(s, raw_dump);
+			print_pmu_events(s, raw_dump);
+			print_tracepoint_events(NULL, s, raw_dump);
+			free(s);
 		}
 	}
 	return 0;
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 00/10] perf/cover improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-02 22:30 +0200
  [PATCH 09/10] perf record: Change 'record.samples' type to unsigned long long Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-02 22:30 +0200
  [PATCH 05/10] perf callchain: Allow for max_stack greater than PERF_MAX_STACK_DEPTH Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-02 22:30 +0200
  [PATCH 03/10] perf top: Register idle thread Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-02 22:30 +0200
  [PATCH 01/10] perf record: Allocate area for sample_id_hdr in a synthesized comm event Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-02 22:30 +0200
  [PATCH 02/10] perf top: Fix unresolved comm when -s comm is used Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-02 22:30 +0200
  [PATCH 06/10] perf list: Do event name substring search as last resort when no events found Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-02 22:30 +0200
  [PATCH 08/10] perf probe: Allow probing on kmodules without dwarf Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-02 22:30 +0200
  Re: [GIT PULL 00/10] perf/cover improvements and fixes Ingo Molnar <mingo@kernel.org> - 2015-10-03 08:40 +0200

csiph-web