From 6b5fc39bdd781711d7da8b95ae0243df3b35c5bf Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Mon, 21 May 2012 09:12:53 +0200 Subject: perf tools: Add hardcoded name term for pmu events Adding a new hardcoded term 'name' allowing to specify a name for the pmu event. The term is defined along with standard pmu terms. If no 'name' term is given, the event name follows following template: "raw 0x" running: perf stat -e cpu/config=1,name=krava1/u ls will produce following output: ... Performance counter stats for 'ls': 0 krava1 ... running: perf stat -e cpu/config=1/u ls will produce following output: ... Performance counter stats for 'ls': 0 raw 0x1 ... Signed-off-by: Jiri Olsa Cc: Corey Ashford Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1337584373-2741-6-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/parse-events-test.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tools/perf/util/parse-events-test.c') diff --git a/tools/perf/util/parse-events-test.c b/tools/perf/util/parse-events-test.c index 2e8f435384a6..76b98e2a587d 100644 --- a/tools/perf/util/parse-events-test.c +++ b/tools/perf/util/parse-events-test.c @@ -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; @@ -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) / \ -- cgit v1.2.3-59-g8ed1b