perf_counter: Introduce new (non-)paranoia level to allow raw tracepoint access
Commit-ID: 5380c1056d267eff49854c1fa03399bfe761da1e Gitweb: http://git.kernel.org/tip/5380c1056d267eff49854c1fa03399bfe761da1e Author: Ingo Molnar <[email protected]> AuthorDate: Wed, 2 Sep 2009 21:46:00 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 2 Sep 2009 21:47:06 +0200
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 <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <new-submission>
--- kernel/perf_counter.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
kernel/perf_counter.c +10 -3
@@ -46,12 +46,18 @@ static atomic_t nr_task_counters __read_mostly;/* * perf counter paranoia level: -* 0 - not paranoid -* 1 - disallow cpu counters to unpriv -* 2 - disallow kernel profiling to unpriv +* -1 - not paranoid at all +* 0 - disallow raw tracepoint access for unpriv +* 1 - disallow cpu counters for unpriv +* 2 - disallow kernel profiling for unpriv */ int sysctl_perf_counter_paranoid__read_mostly =1 ; +static inline bool perf_paranoid_tracepoint_raw (void ) +{ +return sysctl_perf_counter_paranoid >-1 ; +} +static inline bool perf_paranoid_cpu (void ) {return sysctl_perf_counter_paranoid >0 ;
@@ -3971,6 +3977,7 @@ static const struct pmu *tp_perf_counter_init(struct perf_counter *counter)* have these. */ if ((counter->attr.sample_type &PERF_SAMPLE_RAW ) && + &&perf_paranoid_tracepoint_raw () && !capable (CAP_SYS_ADMIN ))return ERR_PTR (-EPERM );
kernel/perf_counter.c static const struct pmu *tp_perf_counter_init(struct perf_counter *counter) · line 3980
Quoted 8 lines
static inline bool
perf_paranoid_cpu(void)
{kernel/perf_counter.c +1
-0return sysctl_perf_counter_paranoid >0 ;@@ -3971,6 +3977,7 @@ static const struct pmu *tp_perf_counter_init(struct perf_counter *counter)* have these. */ if ((counter->attr.sample_type & PERF_SAMPLE_RAW) && + && perf_paranoid_tracepoint_raw() &&
"&& &&"
This leads to build failure.
Quoted 3 lines
kernel/perf_counter.c +0
-0!capable(CAP_SYS_ADMIN))return ERR_PTR (-EPERM );
Quoted 11 lines · Li Zefan
kernel/perf_counter.c static const struct pmu *tp_perf_counter_init(struct perf_counter *counter) · line 3980
Quoted 8 lines
static inline bool
perf_paranoid_cpu(void)
{kernel/perf_counter.c +1
-0return sysctl_perf_counter_paranoid >0 ;@@ -3971,6 +3977,7 @@ static const struct pmu *tp_perf_counter_init(struct perf_counter *counter)* have these. */ if ((counter->attr.sample_type & PERF_SAMPLE_RAW) && + && perf_paranoid_tracepoint_raw() &&"&& &&"
Quoted 1 line
This leads to build failure.
Yeah - fixed that yesterday, forgot to push out :-/
Ingo