aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-06-12 12:45:00 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-06-19 12:06:21 -0400
commit9db1763c72b1548626ae9d634015de4f07ef624f (patch)
tree04756aba42137f90d17d3842e884d22f942802a6 /tools
parent22c8b84320ecf9ecbb6587d46a259b828e9ece5e (diff)
perf tools: Remove __event_name
Not needed anymore, the parsing code can just leave evsel->name as NULL and the first call to perf_evsel__name() will do exactly what was being pre-cached using __event_name(). Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-cn2eiijcinnc97buod8cs34m@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/parse-events.c61
-rw-r--r--tools/perf/util/parse-events.h1
2 files changed, 6 insertions, 56 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 517e6473982c..eacf932a36a0 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -161,24 +161,6 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
161 return NULL; 161 return NULL;
162} 162}
163 163
164#define TP_PATH_LEN (MAX_EVENT_LENGTH * 2 + 1)
165static const char *tracepoint_id_to_name(u64 config)
166{
167 static char buf[TP_PATH_LEN];
168 struct tracepoint_path *path;
169
170 path = tracepoint_id_to_path(config);
171 if (path) {
172 snprintf(buf, TP_PATH_LEN, "%s:%s", path->system, path->name);
173 free(path->name);
174 free(path->system);
175 free(path);
176 } else
177 snprintf(buf, TP_PATH_LEN, "%s:%s", "unknown", "unknown");
178
179 return buf;
180}
181
182const char *event_type(int type) 164const char *event_type(int type)
183{ 165{
184 switch (type) { 166 switch (type) {
@@ -201,36 +183,6 @@ const char *event_type(int type)
201 return "unknown"; 183 return "unknown";
202} 184}
203 185
204const char *__event_name(int type, u64 config)
205{
206 static char buf[32];
207
208 if (type == PERF_TYPE_RAW) {
209 sprintf(buf, "raw 0x%" PRIx64, config);
210 return buf;
211 }
212
213 switch (type) {
214 case PERF_TYPE_HARDWARE:
215 return __perf_evsel__hw_name(config);
216
217 case PERF_TYPE_HW_CACHE:
218 __perf_evsel__hw_cache_name(config, buf, sizeof(buf));
219 return buf;
220
221 case PERF_TYPE_SOFTWARE:
222 return __perf_evsel__sw_name(config);
223
224 case PERF_TYPE_TRACEPOINT:
225 return tracepoint_id_to_name(config);
226
227 default:
228 break;
229 }
230
231 return "unknown";
232}
233
234static int add_event(struct list_head **_list, int *idx, 186static int add_event(struct list_head **_list, int *idx,
235 struct perf_event_attr *attr, char *name) 187 struct perf_event_attr *attr, char *name)
236{ 188{
@@ -252,7 +204,8 @@ static int add_event(struct list_head **_list, int *idx,
252 return -ENOMEM; 204 return -ENOMEM;
253 } 205 }
254 206
255 evsel->name = strdup(name); 207 if (name)
208 evsel->name = strdup(name);
256 list_add_tail(&evsel->node, list); 209 list_add_tail(&evsel->node, list);
257 *_list = list; 210 *_list = list;
258 return 0; 211 return 0;
@@ -545,8 +498,7 @@ int parse_events_add_numeric(struct list_head **list, int *idx,
545 config_attr(&attr, head_config, 1)) 498 config_attr(&attr, head_config, 1))
546 return -EINVAL; 499 return -EINVAL;
547 500
548 return add_event(list, idx, &attr, 501 return add_event(list, idx, &attr, NULL);
549 (char *) __event_name(type, config));
550} 502}
551 503
552static int parse_events__is_name_term(struct parse_events__term *term) 504static int parse_events__is_name_term(struct parse_events__term *term)
@@ -554,8 +506,7 @@ static int parse_events__is_name_term(struct parse_events__term *term)
554 return term->type_term == PARSE_EVENTS__TERM_TYPE_NAME; 506 return term->type_term == PARSE_EVENTS__TERM_TYPE_NAME;
555} 507}
556 508
557static char *pmu_event_name(struct perf_event_attr *attr, 509static char *pmu_event_name(struct list_head *head_terms)
558 struct list_head *head_terms)
559{ 510{
560 struct parse_events__term *term; 511 struct parse_events__term *term;
561 512
@@ -563,7 +514,7 @@ static char *pmu_event_name(struct perf_event_attr *attr,
563 if (parse_events__is_name_term(term)) 514 if (parse_events__is_name_term(term))
564 return term->val.str; 515 return term->val.str;
565 516
566 return (char *) __event_name(PERF_TYPE_RAW, attr->config); 517 return NULL;
567} 518}
568 519
569int parse_events_add_pmu(struct list_head **list, int *idx, 520int parse_events_add_pmu(struct list_head **list, int *idx,
@@ -588,7 +539,7 @@ int parse_events_add_pmu(struct list_head **list, int *idx,
588 return -EINVAL; 539 return -EINVAL;
589 540
590 return add_event(list, idx, &attr, 541 return add_event(list, idx, &attr,
591 pmu_event_name(&attr, head_config)); 542 pmu_event_name(head_config));
592} 543}
593 544
594void parse_events_update_lists(struct list_head *list_event, 545void parse_events_update_lists(struct list_head *list_event,
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index d7eb070937c4..1784f06e3a6a 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -26,7 +26,6 @@ extern struct tracepoint_path *tracepoint_id_to_path(u64 config);
26extern bool have_tracepoints(struct list_head *evlist); 26extern bool have_tracepoints(struct list_head *evlist);
27 27
28const char *event_type(int type); 28const char *event_type(int type);
29extern const char *__event_name(int type, u64 config);
30 29
31extern int parse_events_option(const struct option *opt, const char *str, 30extern int parse_events_option(const struct option *opt, const char *str,
32 int unset); 31 int unset);