aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/perf_counter.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-09-02 15:46:00 -0400
committerIngo Molnar <mingo@elte.hu>2009-09-02 15:53:02 -0400
commit0fbdea19e9394a5cb5f2f5081b028c50b558910a (patch)
treec3eae68d53504ed1f1615dcb7b5de58ce5d6ff98 /kernel/perf_counter.c
parentf76bd108e5031202bb40849306f98c4afebe4ef6 (diff)
perf_counter: Introduce new (non-)paranoia level to allow raw tracepoint access
I want to sample inherited tracepoint workloads as a normal user and the CAP_SYS_ADMIN check prevents me from doing that right now. Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_counter.c')
-rw-r--r--kernel/perf_counter.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index d988dfb4bbab..0aa609f69103 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -46,12 +46,18 @@ static atomic_t nr_task_counters __read_mostly;
46 46
47/* 47/*
48 * perf counter paranoia level: 48 * perf counter paranoia level:
49 * 0 - not paranoid 49 * -1 - not paranoid at all
50 * 1 - disallow cpu counters to unpriv 50 * 0 - disallow raw tracepoint access for unpriv
51 * 2 - disallow kernel profiling to unpriv 51 * 1 - disallow cpu counters for unpriv
52 * 2 - disallow kernel profiling for unpriv
52 */ 53 */
53int sysctl_perf_counter_paranoid __read_mostly = 1; 54int sysctl_perf_counter_paranoid __read_mostly = 1;
54 55
56static inline bool perf_paranoid_tracepoint_raw(void)
57{
58 return sysctl_perf_counter_paranoid > -1;
59}
60
55static inline bool perf_paranoid_cpu(void) 61static inline bool perf_paranoid_cpu(void)
56{ 62{
57 return sysctl_perf_counter_paranoid > 0; 63 return sysctl_perf_counter_paranoid > 0;
@@ -3971,6 +3977,7 @@ static const struct pmu *tp_perf_counter_init(struct perf_counter *counter)
3971 * have these. 3977 * have these.
3972 */ 3978 */
3973 if ((counter->attr.sample_type & PERF_SAMPLE_RAW) && 3979 if ((counter->attr.sample_type & PERF_SAMPLE_RAW) &&
3980 perf_paranoid_tracepoint_raw() &&
3974 !capable(CAP_SYS_ADMIN)) 3981 !capable(CAP_SYS_ADMIN))
3975 return ERR_PTR(-EPERM); 3982 return ERR_PTR(-EPERM);
3976 3983