Skip to contentSkip to conversation

ftrace: add ftrace_enabled sysctl to disable mcount function

PATCH In review Ingo Molnar 1 participant 1 message Feb 10, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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.

---
 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
Index: linux/include/linux/ftrace.h
===================================================================
@@ -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
Index: linux/kernel/sysctl.c
===================================================================
@@ -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