]> git.ipfire.org Git - people/arne_f/kernel.git/commit
ftrace: Handle tracing when switching between context
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Thu, 29 Oct 2020 23:35:08 +0000 (19:35 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Nov 2020 09:22:19 +0000 (10:22 +0100)
commit735d0265dac9768fd4281b39ee1bdc3e5d42d3ee
tree8e2e77c6714932b2897e354eb14166af3289ae0e
parent4130add27ceb2ce7a73a9fb5f3bf359bd8dc8968
ftrace: Handle tracing when switching between context

commit 726b3d3f141fba6f841d715fc4d8a4a84f02c02a upstream.

When an interrupt or NMI comes in and switches the context, there's a delay
from when the preempt_count() shows the update. As the preempt_count() is
used to detect recursion having each context have its own bit get set when
tracing starts, and if that bit is already set, it is considered a recursion
and the function exits. But if this happens in that section where context
has changed but preempt_count() has not been updated, this will be
incorrectly flagged as a recursion.

To handle this case, create another bit call TRANSITION and test it if the
current context bit is already set. Flag the call as a recursion if the
TRANSITION bit is already set, and if not, set it and continue. The
TRANSITION bit will be cleared normally on the return of the function that
set it, or if the current context bit is clear, set it and clear the
TRANSITION bit to allow for another transition between the current context
and an even higher one.

Cc: stable@vger.kernel.org
Fixes: edc15cafcbfa3 ("tracing: Avoid unnecessary multiple recursion checks")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/trace.h
kernel/trace/trace_selftest.c