On Wed, 3 Feb 2021 22:33:28 +0900 Masami Hiramatsu <mhiramat@xxxxxxxxxx> wrote: > Ah, that is what I worried about. ftrace and kprobes handler usually want to > know "what is the actual status of the system where the probe hits". > > If the new kernel_exception_enter() for ftrace/kprobes or any other kernel > instrumention does > > __preempt_count_add(KEX_OFFSET + NMI_OFFSET + HARDIRQ_OFFSET); > > And we can distinguish the KEX from NMI, and get the original status of the context. > What would you think about? Oh, that reminds me about the obvious difference between an NMI and a ftrace handler. A ftrace handler doesn't disable interrupts nor preemption. Thus, if you set "in_nmi" to a ftrace handler, and an interrupt (or NMI) comes in, then any ftrace handlers called by the interrupt / NMI will be ignored, since it will think it is recursing from NMI context. -- Steve