Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1338153

[PATCH 12/55] perf tools: Enable config raw and numeric events

From Wang Nan <wangnan0@huawei.com>
Newsgroups linux.kernel
Subject [PATCH 12/55] perf tools: Enable config raw and numeric events
Date 2016-02-19 13:20 +0100
Message-ID <r3Scq-4Z3-11@gated-at.bofh.it> (permalink)
References <r3RJo-4w0-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


This patch allows setting config terms for raw and numeric events.
For example:

 # perf stat -e cycles/name=cyc/ ls
 ...
 1821108      cyc
 ...

 # perf stat -e r6530160/name=event/ ls
 ...
 1103195      event
 ...

 # perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
 ...
 # perf report --stdio
 ...
 # Samples: 124  of event 'cycles'
 46.61%     0.00%  swapper        [kernel.vmlinux]            [k] cpu_startup_entry
 41.26%     0.00%  swapper        [kernel.vmlinux]            [k] start_secondary
 ...
 # Samples: 91  of event 'evtx'
 ...
 93.76%     0.00%  swapper      [kernel.vmlinux]            [k] cpu_startup_entry
         |
         ---cpu_startup_entry
            |
            |--66.63%--call_cpuidle
            |          cpuidle_enter
            |          |
 ...

3 test cases are introduced to test config terms for symbol, raw and
numeric events.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
 tools/perf/tests/parse-events.c | 40 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/parse-events.c  |  3 ++-
 tools/perf/util/parse-events.y  | 10 ++++++----
 3 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 6648274..15e2d05 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1271,6 +1271,31 @@ static int test__checkevent_precise_max_modifier(struct perf_evlist *evlist)
 	return 0;
 }
 
+static int test__checkevent_config_symbol(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel = perf_evlist__first(evlist);
+
+	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "insn") == 0);
+	return 0;
+}
+
+static int test__checkevent_config_raw(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel = perf_evlist__first(evlist);
+
+	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "rawpmu") == 0);
+	return 0;
+}
+
+static int test__checkevent_config_num(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel = perf_evlist__first(evlist);
+
+	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "numpmu") == 0);
+	return 0;
+}
+
+
 static int count_tracepoints(void)
 {
 	struct dirent *events_ent;
@@ -1579,6 +1604,21 @@ static struct evlist_test test__events[] = {
 		.check = test__checkevent_precise_max_modifier,
 		.id    = 47,
 	},
+	{
+		.name  = "instructions/name=insn/",
+		.check = test__checkevent_config_symbol,
+		.id    = 48,
+	},
+	{
+		.name  = "r1234/name=rawpmu/",
+		.check = test__checkevent_config_raw,
+		.id    = 49,
+	},
+	{
+		.name  = "4:0x6530160/name=numpmu/",
+		.check = test__checkevent_config_num,
+		.id    = 50,
+	},
 };
 
 static struct evlist_test test__events_pmu[] = {
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 87911ae..68a3871 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1094,7 +1094,8 @@ int parse_events_add_numeric(struct parse_events_evlist *data,
 			return -ENOMEM;
 	}
 
-	return add_event(list, &data->idx, &attr, NULL, &config_terms);
+	return add_event(list, &data->idx, &attr,
+			 get_config_name(head_config), &config_terms);
 }
 
 int parse_events_add_pmu(struct parse_events_evlist *data,
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 448c1ec..7ce8633 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -434,24 +434,26 @@ PE_NAME ':' PE_NAME
 }
 
 event_legacy_numeric:
-PE_VALUE ':' PE_VALUE
+PE_VALUE ':' PE_VALUE opt_event_config
 {
 	struct parse_events_evlist *data = _data;
 	struct list_head *list;
 
 	ALLOC_LIST(list);
-	ABORT_ON(parse_events_add_numeric(data, list, (u32)$1, $3, NULL));
+	ABORT_ON(parse_events_add_numeric(data, list, (u32)$1, $3, $4));
+	parse_events_terms__delete($4);
 	$$ = list;
 }
 
 event_legacy_raw:
-PE_RAW
+PE_RAW opt_event_config
 {
 	struct parse_events_evlist *data = _data;
 	struct list_head *list;
 
 	ALLOC_LIST(list);
-	ABORT_ON(parse_events_add_numeric(data, list, PERF_TYPE_RAW, $1, NULL));
+	ABORT_ON(parse_events_add_numeric(data, list, PERF_TYPE_RAW, $1, $2));
+	parse_events_terms__delete($2);
 	$$ = list;
 }
 
-- 
1.8.3.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/55] perf tools: Bugfix, BPF improvements and overwrite ring buffer support Wang Nan <wangnan0@huawei.com> - 2016-02-19 13:10 +0100
  [PATCH 45/55] perf record: Don't poll on overwrite channel Wang Nan <wangnan0@huawei.com> - 2016-02-19 13:10 +0100
  [PATCH 22/55] perf core: Prepare writing into ring buffer from end Wang Nan <wangnan0@huawei.com> - 2016-02-19 13:10 +0100
  [PATCH 12/55] perf tools: Enable config raw and numeric events Wang Nan <wangnan0@huawei.com> - 2016-02-19 13:20 +0100
    Re: [PATCH 12/55] perf tools: Enable config raw and numeric events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-19 16:10 +0100
      Re: [PATCH 12/55] perf tools: Enable config raw and numeric events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-19 16:20 +0100
        Re: [PATCH 12/55] perf tools: Enable config raw and numeric events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-19 23:00 +0100
    [tip:perf/core] perf tools: Enable config raw and numeric events tip-bot for Wang Nan <tipbot@zytor.com> - 2016-02-20 12:40 +0100

csiph-web