Skip to content

Commit

Permalink
perf_counter: x86: Allow unpriviliged use of NMIs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed May 15, 2009
1 parent f5a5a2f commit a026dfe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion arch/x86/kernel/cpu/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,11 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
* If privileged enough, allow NMI events:
*/
hwc->nmi = 0;
if (capable(CAP_SYS_ADMIN) && hw_event->nmi)
if (hw_event->nmi) {
if (sysctl_perf_counter_priv && !capable(CAP_SYS_ADMIN))
return -EACCES;
hwc->nmi = 1;
}

hwc->irq_period = hw_event->irq_period;
if ((s64)hwc->irq_period <= 0 || hwc->irq_period > x86_pmu.max_period)
Expand Down

0 comments on commit a026dfe

Please sign in to comment.