linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: tom.leiming@gmail.com (Ming Lei)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: perf: do not handle deleted counter in irq handler to avoid oops
Date: Tue, 21 Feb 2012 12:37:38 +0800	[thread overview]
Message-ID: <1329799058-27082-1-git-send-email-tom.leiming@gmail.com> (raw)

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

             reply	other threads:[~2012-02-21  4:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-21  4:37 Ming Lei [this message]
2012-02-21 13:32 ` [PATCH] ARM: perf: do not handle deleted counter in irq handler to avoid oops 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329799058-27082-1-git-send-email-tom.leiming@gmail.com \
    --to=tom.leiming@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).