linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: perf: do not handle deleted counter in irq handler to avoid oops
@ 2012-02-21  4:37 Ming Lei
  2012-02-21 13:32 ` Will Deacon
  0 siblings, 1 reply; 9+ messages in thread
From: Ming Lei @ 2012-02-21  4:37 UTC (permalink / raw)
  To: linux-arm-kernel

The patch adds one check in irq handler to skip handling deleted
counter for avoiding oops.

When one counter is deleted, event reference(hw_events->events[idx])
will be cleared but the hw overflow status may be kept, so the
hw event may be handled and oops will be triggered in irq handler if
pmu irq from other events come.

The another candidate fix is to clear the overflow status for the
event in arm_pmu->disable(), but looks it is a bit more complicated
and has no obvious advantage than the fix in this patch.
---
 arch/arm/kernel/perf_event_v7.c     |    3 ++-
 arch/arm/kernel/perf_event_xscale.c |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/perf_event_v7.c b/arch/arm/kernel/perf_event_v7.c
index 54964dc..05762e4 100644
--- a/arch/arm/kernel/perf_event_v7.c
+++ b/arch/arm/kernel/perf_event_v7.c
@@ -1082,8 +1082,9 @@ static irqreturn_t armv7pmu_handle_irq(int irq_num, void *dev)
 		/*
 		 * We have a single interrupt for all counters. Check that
 		 * each counter has overflowed before we process it.
+		 * Do not handle deleted counter.
 		 */
-		if (!armv7_pmnc_counter_has_overflowed(pmnc, idx))
+		if (!armv7_pmnc_counter_has_overflowed(pmnc, idx) || !event)
 			continue;
 
 		hwc = &event->hw;
diff --git a/arch/arm/kernel/perf_event_xscale.c b/arch/arm/kernel/perf_event_xscale.c
index 831e019..1e07aec 100644
--- a/arch/arm/kernel/perf_event_xscale.c
+++ b/arch/arm/kernel/perf_event_xscale.c
@@ -592,7 +592,7 @@ xscale2pmu_handle_irq(int irq_num, void *dev)
 		struct perf_event *event = cpuc->events[idx];
 		struct hw_perf_event *hwc;
 
-		if (!xscale2_pmnc_counter_has_overflowed(pmnc, idx))
+		if (!xscale2_pmnc_counter_has_overflowed(pmnc, idx) || !event)
 			continue;
 
 		hwc = &event->hw;
-- 
1.7.9

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-02-21 17:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-21  4:37 [PATCH] ARM: perf: do not handle deleted counter in irq handler to avoid oops Ming Lei
2012-02-21 13:32 ` Will Deacon
2012-02-21 14:02   ` Ming Lei
2012-02-21 15:19     ` Will Deacon
2012-02-21 15:34       ` Ming Lei
2012-02-21 15:40         ` Will Deacon
2012-02-21 15:49           ` Ming Lei
2012-02-21 15:57             ` Will Deacon
2012-02-21 17:36               ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).