diff options
Diffstat (limited to 'tools/perf/util/evsel.c')
-rw-r--r-- | tools/perf/util/evsel.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 87b431886670..413f74df08de 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -273,7 +273,7 @@ struct perf_evsel *perf_evsel__new_cycles(void) | |||
273 | struct perf_event_attr attr = { | 273 | struct perf_event_attr attr = { |
274 | .type = PERF_TYPE_HARDWARE, | 274 | .type = PERF_TYPE_HARDWARE, |
275 | .config = PERF_COUNT_HW_CPU_CYCLES, | 275 | .config = PERF_COUNT_HW_CPU_CYCLES, |
276 | .exclude_kernel = 1, | 276 | .exclude_kernel = geteuid() != 0, |
277 | }; | 277 | }; |
278 | struct perf_evsel *evsel; | 278 | struct perf_evsel *evsel; |
279 | 279 | ||
@@ -298,8 +298,10 @@ struct perf_evsel *perf_evsel__new_cycles(void) | |||
298 | goto out; | 298 | goto out; |
299 | 299 | ||
300 | /* use asprintf() because free(evsel) assumes name is allocated */ | 300 | /* use asprintf() because free(evsel) assumes name is allocated */ |
301 | if (asprintf(&evsel->name, "cycles%.*s", | 301 | if (asprintf(&evsel->name, "cycles%s%s%.*s", |
302 | attr.precise_ip ? attr.precise_ip + 1 : 0, ":ppp") < 0) | 302 | (attr.precise_ip || attr.exclude_kernel) ? ":" : "", |
303 | attr.exclude_kernel ? "u" : "", | ||
304 | attr.precise_ip ? attr.precise_ip + 1 : 0, "ppp") < 0) | ||
303 | goto error_free; | 305 | goto error_free; |
304 | out: | 306 | out: |
305 | return evsel; | 307 | return evsel; |