Re: [RFC 2/3] preempt_tracer: Disable IRQ while starting/stopping due to a preempt_counter change

From: Peter Zijlstra
Date: Wed May 29 2019 - 09:54:31 EST


On Wed, May 29, 2019 at 09:42:13AM -0400, Steven Rostedt wrote:
> > And the preempt_irqoff tracer had better also consume the IRQ events,
> > and if it does that it can DTRT without extra bits on, even with that
> > race.
> >
> > Consider:
> >
> > preempt_disable()
> > preempt_count += 1;
> > <IRQ>
> > trace_irq_enter();
> >
> > trace_irq_exit();
> > </IRQ>
> > trace_preempt_disable();
> >
> > /* does stuff */
> >
> > preempt_enable()
> > preempt_count -= 1;
> > trace_preempt_enable();
> >
> > You're saying preempt_irqoff() fails to connect the two because of the
> > hole between trace_irq_exit() and trace_preempt_disable() ?
> >
> > But trace_irq_exit() can see the raised preempt_count and set state
> > for trace_preempt_disable() to connect.
>
> That's basically what I was suggesting as the solution to this ;-)

You were wanting changes to preempt_disable() and task_struct, neither
of which is required. The above only needs some per-cpu storage in the
tracer implementation.