Commit 53b25335 authored by Vince Weaver's avatar Vince Weaver Committed by Ingo Molnar

perf: Disable sampled events if no PMU interrupt

Add common code to generate -ENOTSUPP at event creation time if an
architecture attempts to create a sampled event and
PERF_PMU_NO_INTERRUPT is set.

This adds a new pmu->capabilities flag.  Initially we only support
PERF_PMU_NO_INTERRUPT (to indicate a PMU has no support for generating
hardware interrupts) but there are other capabilities that can be
added later.
Signed-off-by: default avatarVince Weaver <vincent.weaver@maine.edu>
Acked-by: default avatarWill Deacon <will.deacon@arm.com>
[peterz: rename to PERF_PMU_CAP_* and moved the pmu::capabilities word into a hole]
Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1405161708060.11099@vincent-weaver-1.umelst.maine.eduSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent ebf905fc
...@@ -166,6 +166,11 @@ struct perf_event; ...@@ -166,6 +166,11 @@ struct perf_event;
*/ */
#define PERF_EVENT_TXN 0x1 #define PERF_EVENT_TXN 0x1
/**
* pmu::capabilities flags
*/
#define PERF_PMU_CAP_NO_INTERRUPT 0x01
/** /**
* struct pmu - generic performance monitoring unit * struct pmu - generic performance monitoring unit
*/ */
...@@ -178,6 +183,11 @@ struct pmu { ...@@ -178,6 +183,11 @@ struct pmu {
const char *name; const char *name;
int type; int type;
/*
* various common per-pmu feature flags
*/
int capabilities;
int * __percpu pmu_disable_count; int * __percpu pmu_disable_count;
struct perf_cpu_context * __percpu pmu_cpu_context; struct perf_cpu_context * __percpu pmu_cpu_context;
int task_ctx_nr; int task_ctx_nr;
......
...@@ -7120,6 +7120,13 @@ SYSCALL_DEFINE5(perf_event_open, ...@@ -7120,6 +7120,13 @@ SYSCALL_DEFINE5(perf_event_open,
} }
} }
if (is_sampling_event(event)) {
if (event->pmu->capabilities & PERF_PMU_CAP_NO_INTERRUPT) {
err = -ENOTSUPP;
goto err_alloc;
}
}
account_event(event); account_event(event);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment