[PATCH] oprofile, hrtimer: only add samples if regs are available

From: Robert Richter
Date: Wed Apr 28 2010 - 14:43:18 EST


This patch adds a check if the regs pointer is valid. This actually
should not happen since hrtimer notification code should always run in
hard_irq context after this commit (since v2.6.29):

ca10949 hrtimer: removing all ur callback modes

However, if code does not run in interrupt context, regs will be null:

http://www.mail-archive.com/linux-omap@xxxxxxxxxxxxxxx/msg14074.html

Cc: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>
Signed-off-by: Robert Richter <robert.richter@xxxxxxx>
---
drivers/oprofile/timer_int.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
index dc0ae4d..ca3436c 100644
--- a/drivers/oprofile/timer_int.c
+++ b/drivers/oprofile/timer_int.c
@@ -24,8 +24,12 @@ static DEFINE_PER_CPU(struct hrtimer, oprofile_hrtimer);

static enum hrtimer_restart oprofile_hrtimer_notify(struct hrtimer *hrtimer)
{
- oprofile_add_sample(get_irq_regs(), 0);
+ struct pt_regs *regs = get_irq_regs();
+
+ if (regs)
+ oprofile_add_sample(regs, 0);
hrtimer_forward_now(hrtimer, ns_to_ktime(TICK_NSEC));
+
return HRTIMER_RESTART;
}

--
1.7.0.3



--
Advanced Micro Devices, Inc.
Operating System Research Center
email: robert.richter@xxxxxxx

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/