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>hifive-unleashed-5.1
parent
f76bd108e5
commit
0fbdea19e9
|
@ -46,12 +46,18 @@ static atomic_t nr_task_counters __read_mostly;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* perf counter paranoia level:
|
* perf counter paranoia level:
|
||||||
* 0 - not paranoid
|
* -1 - not paranoid at all
|
||||||
* 1 - disallow cpu counters to unpriv
|
* 0 - disallow raw tracepoint access for unpriv
|
||||||
* 2 - disallow kernel profiling to unpriv
|
* 1 - disallow cpu counters for unpriv
|
||||||
|
* 2 - disallow kernel profiling for unpriv
|
||||||
*/
|
*/
|
||||||
int sysctl_perf_counter_paranoid __read_mostly = 1;
|
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)
|
static inline bool perf_paranoid_cpu(void)
|
||||||
{
|
{
|
||||||
return sysctl_perf_counter_paranoid > 0;
|
return sysctl_perf_counter_paranoid > 0;
|
||||||
|
@ -3971,6 +3977,7 @@ static const struct pmu *tp_perf_counter_init(struct perf_counter *counter)
|
||||||
* have these.
|
* have these.
|
||||||
*/
|
*/
|
||||||
if ((counter->attr.sample_type & PERF_SAMPLE_RAW) &&
|
if ((counter->attr.sample_type & PERF_SAMPLE_RAW) &&
|
||||||
|
perf_paranoid_tracepoint_raw() &&
|
||||||
!capable(CAP_SYS_ADMIN))
|
!capable(CAP_SYS_ADMIN))
|
||||||
return ERR_PTR(-EPERM);
|
return ERR_PTR(-EPERM);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue