提交 320ebf09 编写于 作者: P Peter Zijlstra 提交者: Ingo Molnar

perf, x86: Restrict the ANY flag

The ANY flag can show SMT data of another task (like 'top'),
so we want to disable it when system-wide profiling is
disabled.
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 bb1165d6
...@@ -503,6 +503,9 @@ static int __hw_perf_event_init(struct perf_event *event) ...@@ -503,6 +503,9 @@ static int __hw_perf_event_init(struct perf_event *event)
*/ */
if (attr->type == PERF_TYPE_RAW) { if (attr->type == PERF_TYPE_RAW) {
hwc->config |= x86_pmu.raw_event(attr->config); hwc->config |= x86_pmu.raw_event(attr->config);
if ((hwc->config & ARCH_PERFMON_EVENTSEL_ANY) &&
perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN))
return -EACCES;
return 0; return 0;
} }
......
...@@ -857,6 +857,21 @@ extern int sysctl_perf_event_paranoid; ...@@ -857,6 +857,21 @@ extern int sysctl_perf_event_paranoid;
extern int sysctl_perf_event_mlock; extern int sysctl_perf_event_mlock;
extern int sysctl_perf_event_sample_rate; extern int sysctl_perf_event_sample_rate;
static inline bool perf_paranoid_tracepoint_raw(void)
{
return sysctl_perf_event_paranoid > -1;
}
static inline bool perf_paranoid_cpu(void)
{
return sysctl_perf_event_paranoid > 0;
}
static inline bool perf_paranoid_kernel(void)
{
return sysctl_perf_event_paranoid > 1;
}
extern void perf_event_init(void); extern void perf_event_init(void);
extern void perf_tp_event(int event_id, u64 addr, u64 count, void *record, int entry_size); extern void perf_tp_event(int event_id, u64 addr, u64 count, void *record, int entry_size);
extern void perf_bp_event(struct perf_event *event, void *data); extern void perf_bp_event(struct perf_event *event, void *data);
......
...@@ -56,21 +56,6 @@ static atomic_t nr_task_events __read_mostly; ...@@ -56,21 +56,6 @@ static atomic_t nr_task_events __read_mostly;
*/ */
int sysctl_perf_event_paranoid __read_mostly = 1; int sysctl_perf_event_paranoid __read_mostly = 1;
static inline bool perf_paranoid_tracepoint_raw(void)
{
return sysctl_perf_event_paranoid > -1;
}
static inline bool perf_paranoid_cpu(void)
{
return sysctl_perf_event_paranoid > 0;
}
static inline bool perf_paranoid_kernel(void)
{
return sysctl_perf_event_paranoid > 1;
}
int sysctl_perf_event_mlock __read_mostly = 512; /* 'free' kb per user */ int sysctl_perf_event_mlock __read_mostly = 512; /* 'free' kb per user */
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册