Skip to contentSkip to conversation

perf evsel: Fix attr.exclude_kernel setting for default cycles:p

tip:perf/urgent tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Jul 11, 2017 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  d37a369790774af66a4aee61a188384d21b17a43
Gitweb:     http://git.kernel.org/tip/d37a369790774af66a4aee61a188384d21b17a43
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Mon, 10 Jul 2017 16:08:07 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 10 Jul 2017 16:14:48 -0300

perf evsel: Fix attr.exclude_kernel setting for default cycles:p

To allow probing the max attr.precise_ip setting for non-root users we unconditionally set attr.exclude_kernel, which makes the detection work but should be done only for !root, fix it.

Cc Adrian Hunter <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Fixes 97365e81366f ("perf evsel: Set attr.exclude_kernel when probing max attr.precise_ip")
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.c +1 -1
index 87b4318..f2a1876 100644
@@ -273,7 +273,7 @@ struct perf_evsel *perf_evsel__new_cycles(void)
 	struct perf_event_attr attr = {
 		.type	= PERF_TYPE_HARDWARE,
 		.config	= PERF_COUNT_HW_CPU_CYCLES,
-		.exclude_kernel	= 1,
+		.exclude_kernel	= geteuid() != 0,
 	};
 	struct perf_evsel *evsel;