aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorLin Ming <ming.m.lin@intel.com>2011-01-06 22:11:09 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-01-06 22:44:36 -0500
commit23a2f3ab46596d9fd0b0e592d2101bea90970594 (patch)
tree6b3d9e3755a3e71bb0e6b47e62b269e50b6cf37d /tools/perf
parent6b01f2c4f6188da50d8fe094e369a9c0390424ab (diff)
perf tools: Pass whole attr to event selectors
Since commit 69aad6f1(perf tools: Introduce event selectors), only perf_event_attr::type and ::config are passed to event selector, which makes perf tool not work correctly. For example, PEBS does not work because perf_event_attr::precise_ip is not passed to the syscall. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <peterz@infradead.org> LKML-Reference: <1294369869.20563.19.camel@minggr.sh.intel.com> Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-stat.c3
-rw-r--r--tools/perf/builtin-test.c6
-rw-r--r--tools/perf/util/evsel.c5
-rw-r--r--tools/perf/util/evsel.h2
-rw-r--r--tools/perf/util/parse-events.c13
5 files changed, 19 insertions, 10 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 02b2d8013a61..2dfcb613e66b 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -683,8 +683,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
683 nr_counters = ARRAY_SIZE(default_attrs); 683 nr_counters = ARRAY_SIZE(default_attrs);
684 684
685 for (c = 0; c < ARRAY_SIZE(default_attrs); ++c) { 685 for (c = 0; c < ARRAY_SIZE(default_attrs); ++c) {
686 pos = perf_evsel__new(default_attrs[c].type, 686 pos = perf_evsel__new(&default_attrs[c],
687 default_attrs[c].config,
688 nr_counters); 687 nr_counters);
689 if (pos == NULL) 688 if (pos == NULL)
690 goto out; 689 goto out;
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 1c984342a579..e12753f976a1 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -264,6 +264,7 @@ static int test__open_syscall_event(void)
264 int err = -1, fd; 264 int err = -1, fd;
265 struct thread_map *threads; 265 struct thread_map *threads;
266 struct perf_evsel *evsel; 266 struct perf_evsel *evsel;
267 struct perf_event_attr attr;
267 unsigned int nr_open_calls = 111, i; 268 unsigned int nr_open_calls = 111, i;
268 int id = trace_event__id("sys_enter_open"); 269 int id = trace_event__id("sys_enter_open");
269 270
@@ -278,7 +279,10 @@ static int test__open_syscall_event(void)
278 return -1; 279 return -1;
279 } 280 }
280 281
281 evsel = perf_evsel__new(PERF_TYPE_TRACEPOINT, id, 0); 282 memset(&attr, 0, sizeof(attr));
283 attr.type = PERF_TYPE_TRACEPOINT;
284 attr.config = id;
285 evsel = perf_evsel__new(&attr, 0);
282 if (evsel == NULL) { 286 if (evsel == NULL) {
283 pr_debug("perf_evsel__new\n"); 287 pr_debug("perf_evsel__new\n");
284 goto out_thread_map_delete; 288 goto out_thread_map_delete;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index c95267e63c5b..1a5591d7a245 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -6,14 +6,13 @@
6 6
7#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) 7#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
8 8
9struct perf_evsel *perf_evsel__new(u32 type, u64 config, int idx) 9struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx)
10{ 10{
11 struct perf_evsel *evsel = zalloc(sizeof(*evsel)); 11 struct perf_evsel *evsel = zalloc(sizeof(*evsel));
12 12
13 if (evsel != NULL) { 13 if (evsel != NULL) {
14 evsel->idx = idx; 14 evsel->idx = idx;
15 evsel->attr.type = type; 15 evsel->attr = *attr;
16 evsel->attr.config = config;
17 INIT_LIST_HEAD(&evsel->node); 16 INIT_LIST_HEAD(&evsel->node);
18 } 17 }
19 18
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index a0ccd69c3fc2..b2d755fe88a5 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -37,7 +37,7 @@ struct perf_evsel {
37struct cpu_map; 37struct cpu_map;
38struct thread_map; 38struct thread_map;
39 39
40struct perf_evsel *perf_evsel__new(u32 type, u64 config, int idx); 40struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx);
41void perf_evsel__delete(struct perf_evsel *evsel); 41void perf_evsel__delete(struct perf_evsel *evsel);
42 42
43int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); 43int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 917a0ca521c1..5cb6f4bde905 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -823,7 +823,7 @@ int parse_events(const struct option *opt __used, const char *str, int unset __u
823 823
824 if (ret != EVT_HANDLED_ALL) { 824 if (ret != EVT_HANDLED_ALL) {
825 struct perf_evsel *evsel; 825 struct perf_evsel *evsel;
826 evsel = perf_evsel__new(attr.type, attr.config, 826 evsel = perf_evsel__new(&attr,
827 nr_counters); 827 nr_counters);
828 if (evsel == NULL) 828 if (evsel == NULL)
829 return -1; 829 return -1;
@@ -1013,8 +1013,15 @@ void print_events(void)
1013 1013
1014int perf_evsel_list__create_default(void) 1014int perf_evsel_list__create_default(void)
1015{ 1015{
1016 struct perf_evsel *evsel = perf_evsel__new(PERF_TYPE_HARDWARE, 1016 struct perf_evsel *evsel;
1017 PERF_COUNT_HW_CPU_CYCLES, 0); 1017 struct perf_event_attr attr;
1018
1019 memset(&attr, 0, sizeof(attr));
1020 attr.type = PERF_TYPE_HARDWARE;
1021 attr.config = PERF_COUNT_HW_CPU_CYCLES;
1022
1023 evsel = perf_evsel__new(&attr, 0);
1024
1018 if (evsel == NULL) 1025 if (evsel == NULL)
1019 return -ENOMEM; 1026 return -ENOMEM;
1020 1027