lkml.org 
[lkml]   [2014]   [Jan]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [patch/rfc] perf on raspberry-pi without overflow interrupt
On Thu, 16 Jan 2014, Peter Zijlstra wrote:

> Yeah I suppose we could do something like that. Maybe something like:
>
> # cat /sys/bus/event_source/devices/cpu/flags
> int precise filter

wouldn't that violate the "one value per file" rule?

I guess we could also stick it in the mmap page somewhere, as tools like
PAPI already have to check there for things like rdpmc support.


Anyway, here's a first pass at a generic fix for this issue. I'm sure the
code is pretty horrible, I don't usually mess with the perf code at this
level. I haven't tested yet as it touched enough files that the rasp-pi
is going to take a few hours to finish compiling.

Am I on the right track, or totally off here?

diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index bc3f2ef..6782379 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -397,7 +397,7 @@ __hw_perf_event_init(struct perf_event *event)
*/
hwc->config_base |= (unsigned long)mapping;

- if (!hwc->sample_period) {
+ if (!is_sampling_event(event)) {
/*
* For non-sampling runs, limit the sample_period to half
* of the counter width. That way, the new counter value
diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
index 20d553c..afb3fc8 100644
--- a/arch/arm/kernel/perf_event_cpu.c
+++ b/arch/arm/kernel/perf_event_cpu.c
@@ -97,8 +97,8 @@ static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler)

irqs = min(pmu_device->num_resources, num_possible_cpus());
if (irqs < 1) {
- pr_err("no irqs for PMUs defined\n");
- return -ENODEV;
+ printk_once("no irqs for PMUs defined, sampled events not supported\n");
+ return 0;
}

for (i = 0; i < irqs; ++i) {
@@ -150,6 +150,10 @@ static void cpu_pmu_init(struct arm_pmu *cpu_pmu)
/* Ensure the PMU has sane values out of reset. */
if (cpu_pmu->reset)
on_each_cpu(cpu_pmu->reset, cpu_pmu, 1);
+
+ if (platform_get_irq(cpu_pmu->plat_device, 0) <= 0)
+ cpu_pmu->pmu.capabilities |= PERF_PMU_NO_INTERRUPT;
+
}

/*
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 2e069d1..f5e7f0c 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -251,9 +251,19 @@ struct pmu {
* flush branch stack on context-switches (needed in cpu-wide mode)
*/
void (*flush_branch_stack) (void);
+
+ /*
+ * various common per-pmu feature flags
+ */
+ int capabilities;
};

/**
+ * struct pmu->capabilites flags
+ */
+#define PERF_PMU_NO_INTERRUPT 1
+
+/**
* enum perf_event_active_state - the states of a event
*/
enum perf_event_active_state {
diff --git a/kernel/events/core.c b/kernel/events/core.c
index f574401..f65c6c6 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7056,6 +7056,14 @@ SYSCALL_DEFINE5(perf_event_open,
*/
pmu = event->pmu;

+ if (is_sampling_event(event)) {
+ if (pmu->capabilities & PERF_PMU_NO_INTERRUPT)
+ err = -ENOTSUPP;
+ goto err_alloc;
+ }
+
+
+
if (group_leader &&
(is_software_event(event) != is_software_event(group_leader))) {
if (is_software_event(event)) {

\
 
 \ /
  Last update: 2014-01-17 07:01    [W:1.123 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site