Re: [patch 06/41] x86/traps: Simplify pagefault tracing logic

From: Thomas Gleixner
Date: Fri Aug 25 2017 - 11:12:05 EST


On Fri, 25 Aug 2017, Steven Rostedt wrote:

> On Fri, 25 Aug 2017 12:31:09 +0200
> Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> > dotraplinkage void notrace
> > -trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
> > +do_page_fault(struct pt_regs *regs, unsigned long error_code)
> > {
> > + unsigned long address = read_cr2(); /* Get the faulting address */
> > + enum ctx_state prev_state;
> > +
> > /*
> > - * The exception_enter and tracepoint processing could
> > - * trigger another page faults (user space callchain
> > - * reading) and destroy the original cr2 value, so read
> > - * the faulting address now.
> > + * We must have this function tagged with __kprobes, notrace and call
> > + * read_cr2() before calling anything else. To avoid calling any kind
> > + * of tracing machinery before we've observed the CR2 value.
> > + *
> > + * exception_{enter,exit}() contain all sorts of tracepoints.
> > */
> > - unsigned long address = read_cr2();
> > - enum ctx_state prev_state;
> > + if (trace_irqvectors_enabled())
> > + trace_page_fault_entries(address, regs, error_code);
> >
> > prev_state = exception_enter();
> > - trace_page_fault_entries(address, regs, error_code);
>
> I believe you need to keep the tracing after the "exception_enter()", as
> for NO_HZ_FULL, that enables RCU again, and the tracepoint needs RCU
> enabled.

Indeed. Thanks for spotting it.