Re: [PATCH] Ftrace: irqsoff tracer may cause stack overflow

From: Frederic Weisbecker
Date: Fri Jan 08 2010 - 13:27:58 EST


On Fri, Jan 08, 2010 at 10:22:43AM -0500, Steven Rostedt wrote:
> On Fri, 2010-01-08 at 06:18 +0100, Frederic Weisbecker wrote:
> Comment needed here:
>
> /*
> * The irqsoff tracer uses atomic_inc_return to prevent recursion.
> * Unfortunately, in this file, atomic_inc_return disables interrupts
> * which causes the recursion the irqsoff trace was trying to prevent.
> *
> * The irqsoff tracer will define __ATOMIC_NEED_RAW_IRQ_SAVE before
> * including this file, which will make the atomic_inc_return use
> * the raw versions of interrupts disabling. This will allow other
> * users of the atomic_inc_return to still have the interrupt
> * disabling be traced, but will prevent the recursion by the
> * irqsoff tracer itself.
> */
>



Yep, that was a first catch, just to ping opinions, it was even
not tested :)


> I wonder if we could just use a per_cpu variable and increment that
> instead. Since the irqsoff tracer only gets called with interrupts
> disabled (and the preemptoff with preemption disabled), a per_cpu
> variable should be protected well.



Doh! I thought about that but feared about preempt_disable recursion.
I didn't realize this code was under such context already.

True, that's indeed a much better idea!

--
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/