Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 305504
b: refs/heads/master
c: 6b5fc39
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed May 22, 2012
1 parent 844480a commit a635130
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 08d2f762ac4af861b962e543fceab341f05c8886
refs/heads/master: 6b5fc39bdd781711d7da8b95ae0243df3b35c5bf
25 changes: 25 additions & 0 deletions trunk/tools/perf/util/parse-events-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,27 @@ static int test__checkevent_list(struct perf_evlist *evlist)
return 0;
}

static int test__checkevent_pmu_name(struct perf_evlist *evlist)
{
struct perf_evsel *evsel;

/* cpu/config=1,name=krava1/u */
evsel = list_entry(evlist->entries.next, struct perf_evsel, node);
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
TEST_ASSERT_VAL("wrong name", !strcmp(evsel->name, "krava"));

/* cpu/config=2/" */
evsel = list_entry(evsel->node.next, struct perf_evsel, node);
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config);
TEST_ASSERT_VAL("wrong name", !strcmp(evsel->name, "raw 0x2"));

return 0;
}

struct test__event_st {
const char *name;
__u32 type;
Expand Down Expand Up @@ -529,6 +550,10 @@ static struct test__event_st test__events_pmu[] = {
.name = "cpu/config=10,config1,config2=3,period=1000/u",
.check = test__checkevent_pmu,
},
[1] = {
.name = "cpu/config=1,name=krava/u,cpu/config=2/u",
.check = test__checkevent_pmu_name,
},
};

#define TEST__EVENTS_PMU_CNT (sizeof(test__events_pmu) / \
Expand Down
23 changes: 22 additions & 1 deletion trunk/tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,9 @@ do { \
* attr->branch_sample_type = term->val.num;
*/
break;
case PARSE_EVENTS__TERM_TYPE_NAME:
CHECK_TYPE_VAL(STR);
break;
default:
return -EINVAL;
}
Expand Down Expand Up @@ -672,6 +675,23 @@ int parse_events_add_numeric(struct list_head **list, int *idx,
(char *) __event_name(type, config));
}

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)
{
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);
}

int parse_events_add_pmu(struct list_head **list, int *idx,
char *name, struct list_head *head_config)
{
Expand All @@ -693,7 +713,8 @@ int parse_events_add_pmu(struct list_head **list, int *idx,
if (perf_pmu__config(pmu, &attr, head_config))
return -EINVAL;

return add_event(list, idx, &attr, (char *) "pmu");
return add_event(list, idx, &attr,
pmu_event_name(&attr, head_config));
}

void parse_events_update_lists(struct list_head *list_event,
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/parse-events.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ enum {
PARSE_EVENTS__TERM_TYPE_CONFIG,
PARSE_EVENTS__TERM_TYPE_CONFIG1,
PARSE_EVENTS__TERM_TYPE_CONFIG2,
PARSE_EVENTS__TERM_TYPE_NAME,
PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD,
PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE,
};
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/parse-events.l
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ misses|miss { return str(PE_NAME_CACHE_OP_RESULT); }
config { return term(PARSE_EVENTS__TERM_TYPE_CONFIG); }
config1 { return term(PARSE_EVENTS__TERM_TYPE_CONFIG1); }
config2 { return term(PARSE_EVENTS__TERM_TYPE_CONFIG2); }
name { return term(PARSE_EVENTS__TERM_TYPE_NAME); }
period { return term(PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
branch_type { return term(PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }

Expand Down
8 changes: 8 additions & 0 deletions trunk/tools/perf/util/parse-events.y
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ PE_NAME
$$ = term;
}
|
PE_TERM '=' PE_NAME
{
struct parse_events__term *term;

ABORT_ON(parse_events__term_str(&term, $1, NULL, $3));
$$ = term;
}
|
PE_TERM '=' PE_VALUE
{
struct parse_events__term *term;
Expand Down
4 changes: 2 additions & 2 deletions trunk/tools/perf/util/pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ static int pmu_config_term(struct list_head *formats,
static int pmu_config(struct list_head *formats, struct perf_event_attr *attr,
struct list_head *head_terms)
{
struct parse_events__term *term, *h;
struct parse_events__term *term;

list_for_each_entry_safe(term, h, head_terms, list)
list_for_each_entry(term, head_terms, list)
if (pmu_config_term(formats, attr, term))
return -EINVAL;

Expand Down

0 comments on commit a635130

Please sign in to comment.