ftrace: add ftrace_enabled sysctl to disable mcount function
Subsystems (3)
PATCH 18/19 ftrace: add ftrace_enabled sysctl to disable mcount function
From: Steven Rostedt <[email protected]>
This patch adds back the sysctl ftrace_enabled. This time it is defaulted to on, if DYNAMIC_FTRACE is configured. When ftrace_enabled is disabled, the ftrace function is set to the stub return.
If DYNAMIC_FTRACE is also configured, on ftrace_enabled = 0, the registered ftrace functions will all be set to jmps, but no more new calls to ftrace recording (used to find the ftrace calling sites) will be called.
Signed-off-by Steven Rostedt <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- include/linux/ftrace.h | 6 ++ kernel/sysctl.c | 11 ++++ kernel/trace/ftrace.c | 125 +++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 124 insertions(+), 18 deletions(-)
include/linux/ftrace.h +6 -0
@@ -5,6 +5,12 @@#include <linux/linkage.h> +extern int ftrace_enabled; +extern int +ftrace_enable_sysctl (struct ctl_table *table,int write, +struct file *filp,void __user *buffer,size_t *lenp, +loff_t *ppos); +typedef void (*ftrace_func_t )(unsigned long ip,unsigned long parent_ip);struct ftrace_ops {
kernel/sysctl.c +11 -0
@@ -45,6 +45,7 @@#include <linux/nfs_fs.h> #include <linux/acpi.h> #include <linux/reboot.h> +#include <linux/ftrace.h> #include <asm/uaccess.h> #include <asm/processor.h>
@@ -488,6 +489,16 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = &proc_dointvec, }, +#ifdef CONFIG_FTRACE + { + .ctl_name = CTL_UNNUMBERED, + .procname = "ftrace_enabled", + .data = &ftrace_enabled, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &ftrace_enable_sysctl, + }, +#endif #ifdef CONFIG_KMOD { .ctl_name = KERN_MODPROBE,
kernel/trace/ftrace.c +107 -18
204 lines not on this page · raw message