ftrace: make extra rcu_is_watching() validation check optional
Andrii Nakryiko
maintainerPATCH v2 1/1 ftrace: make extra rcu_is_watching() validation check optional
Introduce CONFIG_FTRACE_VALIDATE_RCU_IS_WATCHING config option to control whether ftrace low-level code performs additional rcu_is_watching()-based validation logic in an attempt to catch noinstr violations.
This check is expected to never be true and is mostly useful for low-level debugging of ftrace subsystem. For most users it should probably be kept disabled to eliminate unnecessary runtime overhead.
Cc Steven Rostedt <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Paul E. McKenney <[email protected]>
Signed-off-by Andrii Nakryiko <[email protected]>
--- include/linux/trace_recursion.h | 2 +- kernel/trace/Kconfig | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)
include/linux/trace_recursion.h +1 -1
@@ -135,7 +135,7 @@ extern void ftrace_record_recursion(unsigned long ip, unsigned long parent_ip);# define do_ftrace_record_recursion (ip, pip) do { } while (0)#endif -#ifdef CONFIG_ARCH_WANTS_NO_INSTR +#ifdef CONFIG_FTRACE_VALIDATE_RCU_IS_WATCHING # define trace_warn_on_no_rcu (ip) \ ({ \ bool __ret = !rcu_is_watching(); \
kernel/trace/Kconfig +14 -0
@@ -974,6 +974,20 @@ config FTRACE_RECORD_RECURSION_SIZE This file can be reset, but the limit can not change in size at runtime. +config FTRACE_VALIDATE_RCU_IS_WATCHING + bool "Validate RCU is on during ftrace recursion check" + depends on FUNCTION_TRACER + depends on ARCH_WANTS_NO_INSTR + help + All callbacks that attach to the function tracing have some sort + of protection against recursion. This option performs additional + checks to make sure RCU is on when ftrace callbacks recurse. + + This is a feature useful for debugging ftrace. This will add more + overhead to all ftrace-based invocations. + + If unsure, say N + config RING_BUFFER_RECORD_RECURSION bool "Record functions that recurse in the ring buffer" depends on FTRACE_RECORD_RECURSION
Signature · 1 line
2.43.0