From: Namhyung Kim <namhyung....@lge.com>

Most tracepoint events already have their system and event name in
->name field so that searching whole event tracing directory for each
evsel to match given id is suboptimal.

Factor out this routine into tracepoint_name_to_path().

Cc: Jiri Olsa <jo...@redhat.com>
Cc: Frederic Weisbecker <fweis...@gmail.com>
Signed-off-by: Namhyung Kim <namhy...@kernel.org>
---
 tools/perf/util/parse-events.c     | 23 +++++++++++++++++++++++
 tools/perf/util/parse-events.h     |  1 +
 tools/perf/util/trace-event-info.c | 11 +++++++++++
 3 files changed, 35 insertions(+)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 6c8bb0fb189b..1ae166c9da79 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -217,6 +217,29 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
        return NULL;
 }
 
+struct tracepoint_path *tracepoint_name_to_path(const char *name)
+{
+       struct tracepoint_path *path = zalloc(sizeof(*path));
+       char *str = strchr(name, ':');
+
+       if (path == NULL || str == NULL) {
+               free(path);
+               return NULL;
+       }
+
+       path->system = strndup(name, str - name);
+       path->name = strdup(str+1);
+
+       if (path->system == NULL || path->name == NULL) {
+               free(path->system);
+               free(path->name);
+               free(path);
+               path = NULL;
+       }
+
+       return path;
+}
+
 const char *event_type(int type)
 {
        switch (type) {
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 8a4859315fd9..080f7cf25d99 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -23,6 +23,7 @@ struct tracepoint_path {
 };
 
 extern struct tracepoint_path *tracepoint_id_to_path(u64 config);
+extern struct tracepoint_path *tracepoint_name_to_path(const char *name);
 extern bool have_tracepoints(struct list_head *evlist);
 
 const char *event_type(int type);
diff --git a/tools/perf/util/trace-event-info.c 
b/tools/perf/util/trace-event-info.c
index ab18bf12d54a..bfcaeac7ef9d 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -414,12 +414,23 @@ get_tracepoints_path(struct list_head *pattrs)
                if (pos->attr.type != PERF_TYPE_TRACEPOINT)
                        continue;
                ++nr_tracepoints;
+
+               if (pos->name) {
+                       ppath->next = tracepoint_name_to_path(pos->name);
+                       if (!ppath->next)
+                               goto error;
+
+                       goto next;
+               }
+
                ppath->next = tracepoint_id_to_path(pos->attr.config);
                if (!ppath->next) {
+error:
                        pr_debug("No memory to alloc tracepoints list\n");
                        put_tracepoints_path(&path);
                        return NULL;
                }
+next:
                ppath = ppath->next;
        }
 
-- 
1.7.11.7

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

Reply via email to