summaryrefslogtreecommitdiff
path: root/tools/perf/util/evlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/evlist.c')
-rw-r--r--tools/perf/util/evlist.c22
1 files changed, 2 insertions, 20 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 2a40b8e1def7..097b3ed77fdd 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -239,31 +239,13 @@ void perf_event_attr__set_max_precise_ip(struct perf_event_attr *attr)
int perf_evlist__add_default(struct perf_evlist *evlist)
{
- struct perf_event_attr attr = {
- .type = PERF_TYPE_HARDWARE,
- .config = PERF_COUNT_HW_CPU_CYCLES,
- };
- struct perf_evsel *evsel;
-
- event_attr_init(&attr);
+ struct perf_evsel *evsel = perf_evsel__new_cycles();
- perf_event_attr__set_max_precise_ip(&attr);
-
- evsel = perf_evsel__new(&attr);
if (evsel == NULL)
- goto error;
-
- /* use asprintf() because free(evsel) assumes name is allocated */
- if (asprintf(&evsel->name, "cycles%.*s",
- attr.precise_ip ? attr.precise_ip + 1 : 0, ":ppp") < 0)
- goto error_free;
+ return -ENOMEM;
perf_evlist__add(evlist, evsel);
return 0;
-error_free:
- perf_evsel__delete(evsel);
-error:
- return -ENOMEM;
}
int perf_evlist__add_dummy(struct perf_evlist *evlist)