aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-05-13 04:02:57 -0400
committerIngo Molnar <mingo@elte.hu>2009-05-15 03:46:57 -0400
commita026dfecc035f213c1cfa0bf6407ce3155f6a9df (patch)
treef65ed18c367f5856b0d643e46377de8463971d77
parentf5a5a2f6e69e88647ae12da39f0ff3a510bcf0a6 (diff)
perf_counter: x86: Allow unpriviliged use of NMIs
Apply sysctl_perf_counter_priv to NMIs. Also, fail the counter creation instead of silently down-grading to regular interrupts. [ Impact: allow wider perf-counter usage ] Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/kernel/cpu/perf_counter.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c
index 88ae8cebf3c..c19e927b697 100644
--- a/arch/x86/kernel/cpu/perf_counter.c
+++ b/arch/x86/kernel/cpu/perf_counter.c
@@ -280,8 +280,11 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
280 * If privileged enough, allow NMI events: 280 * If privileged enough, allow NMI events:
281 */ 281 */
282 hwc->nmi = 0; 282 hwc->nmi = 0;
283 if (capable(CAP_SYS_ADMIN) && hw_event->nmi) 283 if (hw_event->nmi) {
284 if (sysctl_perf_counter_priv && !capable(CAP_SYS_ADMIN))
285 return -EACCES;
284 hwc->nmi = 1; 286 hwc->nmi = 1;
287 }
285 288
286 hwc->irq_period = hw_event->irq_period; 289 hwc->irq_period = hw_event->irq_period;
287 if ((s64)hwc->irq_period <= 0 || hwc->irq_period > x86_pmu.max_period) 290 if ((s64)hwc->irq_period <= 0 || hwc->irq_period > x86_pmu.max_period)