[patch] rt: sysprof hrtimer fix

Ingo Molnar
2009-02-13T07:26:17Z

* Frederic Weisbecker <fweisbec@gmail.com> wrote:

> > > It seems to run fine for all of them except sysprof. It passes the self-test
> > > but doesn't produce any trace when I manually try.
> > >
> > > Not completely sure this is only in -rt so I'm pulling very latest -tip and
> > > will see if I find the same problem there.
> >
> > About sysprof, it's an -rt problem, I don't see it on -tip. The sysprof hrtimer
> > callback is never called.
> >
> > I'm digging to see what is happening.
>
> I didn't put my ftrace_printk at the right place. It doesn't come from hrtimer.
> The problem comes from get_irq_regs() which always returns NULL on the sysprof
> hrtimer calback, then the trace is immediately dropped by sysprof.

Ah, that makes sense - under -rt the default hrtimer execution is to
execute in a softirq context. Could you try the patch below please,
does it fix sysprof?

Ingo

------------------>
Subject: rt: sysprof hrtimer fix
From: Ingo Molnar <mingo@elte.hu>
Date: Fri Feb 13 08:22:14 CET 2009

Frederic Weisbecker noticed that sysprof does not work under
.29-rt2, and tracked it down to a NULL result that get_irq_regs()
gives to the sysprof plugin.

The reason for the NULL is that it executes in the HRTIMER_SOFTIRQ
context, hence it does not interrupt any real context and thus
there's no IRQ registers to take a look at.

Since the sysprof functionality is atomic, the fix is to move the
sysprof hrtimers to hardirq context.

Reported-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/trace/trace_sysprof.c | 1 +
1 file changed, 1 insertion(+)

Index: tip/kernel/trace/trace_sysprof.c
===================================================================
--- tip.orig/kernel/trace/trace_sysprof.c
+++ tip/kernel/trace/trace_sysprof.c
@@ -202,6 +202,7 @@ static void start_stack_timer(void *unus

hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
hrtimer->function = stack_trace_timer_fn;
+ hrtimer->irqsafe = 1;

hrtimer_start(hrtimer, ns_to_ktime(sample_period), HRTIMER_MODE_REL);
}