sched,rcu,tracing: Avoid tracing before in_nmi() is correct
authorPeter Zijlstra <peterz@infradead.org>
Wed, 12 Feb 2020 20:01:16 +0000 (21:01 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 19 May 2020 13:51:18 +0000 (15:51 +0200)
commitf93524eb9c54f49be150167918f6546b0a2e09b1
tree2c480d01f1f014baf454abb8ce8f52adac0ad6d4
parent178ba00c354eb15cec6806a812771e60a5ae3ea1
sched,rcu,tracing: Avoid tracing before in_nmi() is correct

If a tracer is invoked before in_nmi() becomes true, the tracer can no
longer detect it is called from NMI context and behave correctly.

Therefore change nmi_{enter,exit}() to use __preempt_count_{add,sub}()
as the normal preempt_count_{add,sub}() have a (desired) function
trace entry.

This fixes a potential issue with the current code; when the function-tracer
has stack-tracing enabled __trace_stack() will malfunction when it hits the
preempt_count_add() function entry from NMI context.

Suggested-by: Steven Rostedt (VMware) <rosted@goodmis.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Link: https://lkml.kernel.org/r/20200505134101.434193525@linutronix.de
include/linux/hardirq.h