ARM: perf: hook up perf_sample_event_took around pmu irq handling
authorWill Deacon <will.deacon@arm.com>
Tue, 11 Feb 2014 18:08:41 +0000 (18:08 +0000)
committerWill Deacon <will.deacon@arm.com>
Fri, 21 Feb 2014 11:11:21 +0000 (11:11 +0000)
Since we indirect all of our PMU IRQ handling through a dispatcher, it's
trivial to hook up perf_sample_event_took to prevent applications such
as oprofile from generating interrupt storms due to an unrealisticly
low sample period.

Reported-by: Robert Richter <rric@kernel.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm/kernel/perf_event.c

index 361a1aaee7c8df33ce26fe8057c8f00e4c893078..a6bc431cde701037ca6146d6931a56aa96838cb1 100644 (file)
@@ -302,6 +302,8 @@ static irqreturn_t armpmu_dispatch_irq(int irq, void *dev)
        struct arm_pmu *armpmu;
        struct platform_device *plat_device;
        struct arm_pmu_platdata *plat;
+       int ret;
+       u64 start_clock, finish_clock;
 
        if (irq_is_percpu(irq))
                dev = *(void **)dev;
@@ -309,10 +311,15 @@ static irqreturn_t armpmu_dispatch_irq(int irq, void *dev)
        plat_device = armpmu->plat_device;
        plat = dev_get_platdata(&plat_device->dev);
 
+       start_clock = sched_clock();
        if (plat && plat->handle_irq)
-               return plat->handle_irq(irq, dev, armpmu->handle_irq);
+               ret = plat->handle_irq(irq, dev, armpmu->handle_irq);
        else
-               return armpmu->handle_irq(irq, dev);
+               ret = armpmu->handle_irq(irq, dev);
+       finish_clock = sched_clock();
+
+       perf_sample_event_took(finish_clock - start_clock);
+       return ret;
 }
 
 static void