Skip to content

Commit

Permalink
perf tools: Remove __event_name
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo committed Jun 19, 2012
1 parent 22c8b84 commit 9db1763
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 56 deletions.
61 changes: 6 additions & 55 deletions tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,6 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
return NULL;
}

#define TP_PATH_LEN (MAX_EVENT_LENGTH * 2 + 1)
static const char *tracepoint_id_to_name(u64 config)
{
static char buf[TP_PATH_LEN];
struct tracepoint_path *path;

path = tracepoint_id_to_path(config);
if (path) {
snprintf(buf, TP_PATH_LEN, "%s:%s", path->system, path->name);
free(path->name);
free(path->system);
free(path);
} else
snprintf(buf, TP_PATH_LEN, "%s:%s", "unknown", "unknown");

return buf;
}

const char *event_type(int type)
{
switch (type) {
Expand All @@ -201,36 +183,6 @@ const char *event_type(int type)
return "unknown";
}

const char *__event_name(int type, u64 config)
{
static char buf[32];

if (type == PERF_TYPE_RAW) {
sprintf(buf, "raw 0x%" PRIx64, config);
return buf;
}

switch (type) {
case PERF_TYPE_HARDWARE:
return __perf_evsel__hw_name(config);

case PERF_TYPE_HW_CACHE:
__perf_evsel__hw_cache_name(config, buf, sizeof(buf));
return buf;

case PERF_TYPE_SOFTWARE:
return __perf_evsel__sw_name(config);

case PERF_TYPE_TRACEPOINT:
return tracepoint_id_to_name(config);

default:
break;
}

return "unknown";
}

static int add_event(struct list_head **_list, int *idx,
struct perf_event_attr *attr, char *name)
{
Expand All @@ -252,7 +204,8 @@ static int add_event(struct list_head **_list, int *idx,
return -ENOMEM;
}

evsel->name = strdup(name);
if (name)
evsel->name = strdup(name);
list_add_tail(&evsel->node, list);
*_list = list;
return 0;
Expand Down Expand Up @@ -545,25 +498,23 @@ int parse_events_add_numeric(struct list_head **list, int *idx,
config_attr(&attr, head_config, 1))
return -EINVAL;

return add_event(list, idx, &attr,
(char *) __event_name(type, config));
return add_event(list, idx, &attr, NULL);
}

static int parse_events__is_name_term(struct parse_events__term *term)
{
return term->type_term == PARSE_EVENTS__TERM_TYPE_NAME;
}

static char *pmu_event_name(struct perf_event_attr *attr,
struct list_head *head_terms)
static char *pmu_event_name(struct list_head *head_terms)
{
struct parse_events__term *term;

list_for_each_entry(term, head_terms, list)
if (parse_events__is_name_term(term))
return term->val.str;

return (char *) __event_name(PERF_TYPE_RAW, attr->config);
return NULL;
}

int parse_events_add_pmu(struct list_head **list, int *idx,
Expand All @@ -588,7 +539,7 @@ int parse_events_add_pmu(struct list_head **list, int *idx,
return -EINVAL;

return add_event(list, idx, &attr,
pmu_event_name(&attr, head_config));
pmu_event_name(head_config));
}

void parse_events_update_lists(struct list_head *list_event,
Expand Down
1 change: 0 additions & 1 deletion tools/perf/util/parse-events.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ extern struct tracepoint_path *tracepoint_id_to_path(u64 config);
extern bool have_tracepoints(struct list_head *evlist);

const char *event_type(int type);
extern const char *__event_name(int type, u64 config);

extern int parse_events_option(const struct option *opt, const char *str,
int unset);
Expand Down

0 comments on commit 9db1763

Please sign in to comment.