Re: [PATCH] trace: add graph output support for wakeup tracer

Steven Rostedt
2010-09-07T15:07:53Z

On Tue, 2010-09-07 at 16:18 +0200, Frederic Weisbecker wrote:
> On Thu, Aug 05, 2010 at 04:57:27PM +0200, Jiri Olsa wrote:

> > +static void wakeup_graph_return(struct ftrace_graph_ret *trace)
> > +{
> > + struct trace_array *tr = wakeup_trace;
> > + struct trace_array_cpu *data;
> > + unsigned long flags;
> > + long disabled;
> > + int cpu, pc;
> > +
> > + if (likely(!wakeup_task))
> > + return;
> > +
> > + pc = preempt_count();
> > + preempt_disable_notrace();
> > +
> > + cpu = raw_smp_processor_id();
> > + if (cpu != wakeup_current_cpu)
> > + goto out_enable;
> > +
> > + data = tr->data[cpu];
> > + disabled = atomic_inc_return(&data->disabled);
> > + if (unlikely(disabled != 1))
> > + goto out;
> > +
> > + local_irq_save(flags);
> > + __trace_graph_return(tr, trace, flags, pc);
> > + local_irq_restore(flags);
>
>
>
> Do you disable irqs to avoid losing traces? If so there is a race
> window between the recursion barrier in data->disabled and the
> time you disable irqs.
>
> If you don't want to lose anything (except NMIs), you need to
> replace the preempt_disable by the local_irq_save, ie disable
> irqs before the recursion protection.
>

Or is it just to get the flags variable? If so then use
local_save_flags() instead.

-- Steve