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

From: Steven Rostedt
Date: Fri Aug 25 2017 - 11:11:05 EST


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.

-- Steve


> __do_page_fault(regs, error_code, address);
> exception_exit(prev_state);
> }
> -NOKPROBE_SYMBOL(trace_do_page_fault);
> -#endif /* CONFIG_TRACING */
> +NOKPROBE_SYMBOL(do_page_fault);
>