Skip to contentSkip to conversation

ftrace: move sysctl_ftrace_enabled to ftrace.c

PATCH In review Wei Xiao 2 participants 2 messages Feb 23, 2022 – Feb 26, 2022

Subsystems (4)
lore
Share & tools
lore

Wei Xiao

author
#0 lore raw

PATCH v2 1/1 ftrace: move sysctl_ftrace_enabled to ftrace.c

This moves ftrace_enabled to trace/ftrace.c.

We move sysctls to places where features actually belong to improve the readability of the code and reduce the risk of code merge conflicts. At the same time, the proc-sysctl maintainers do not want to know what sysctl knobs you wish to add for your owner piece of code, we just care about the core logic.

---
v2:
Add subject-prefix of sysctl-next and add the explanation to the commit log to help patch review and subsystem maintainers better understand the context/logic behind the migration.

v1: https://lore.kernel.org/lkml/[email protected]/
1. Lack subject-prefix of sysctl-next to avoid conflicts better.
2. Lack more informations in the commit log to help patch review better.

---
 include/linux/ftrace.h |  3 ---
 kernel/sysctl.c        |  9 ---------
 kernel/trace/ftrace.c  | 22 +++++++++++++++++++++-
 3 files changed, 21 insertions(+), 13 deletions(-)
include/linux/ftrace.h +0 -3
index 9999e29187de..659b2840563a 100644
@@ -94,9 +94,6 @@ static inline int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *val
 #ifdef CONFIG_FUNCTION_TRACER
 
 extern int ftrace_enabled;
-extern int
-ftrace_enable_sysctl(struct ctl_table *table, int write,
-		     void *buffer, size_t *lenp, loff_t *ppos);
 
 #ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
 
kernel/sysctl.c +0 -9
index 5ae443b2882e..55279ec66b28 100644
@@ -1906,15 +1906,6 @@ static struct ctl_table kern_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
-#ifdef CONFIG_FUNCTION_TRACER
-	{
-		.procname	= "ftrace_enabled",
-		.data		= &ftrace_enabled,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= ftrace_enable_sysctl,
-	},
-#endif
 #ifdef CONFIG_STACK_TRACER
 	{
 		.procname	= "stack_tracer_enabled",
kernel/trace/ftrace.c +21 -1
index f9feb197b2da..4a5b4d6996a4 100644
@@ -7846,7 +7846,8 @@ static bool is_permanent_ops_registered(void)
 	return false;
 }
 
-int
+#ifdef CONFIG_SYSCTL
+static int
 ftrace_enable_sysctl(struct ctl_table *table, int write,
 		     void *buffer, size_t *lenp, loff_t *ppos)
 {
@@ -7889,3 +7890,22 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
 	mutex_unlock(&ftrace_lock);
 	return ret;
 }
+
+static struct ctl_table ftrace_sysctls[] = {
+	{
+		.procname       = "ftrace_enabled",
+		.data           = &ftrace_enabled,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = ftrace_enable_sysctl,
+	},
+	{}
+};
+
+static int __init ftrace_sysctl_init(void)
+{
+	register_sysctl_init("kernel", ftrace_sysctls);
+	return 0;
+}
+late_initcall(ftrace_sysctl_init);
+#endif
Signature · 1 line
2.19.1
#1 lore raw
Quoted 7 lines · Wei Xiao

This moves ftrace_enabled to trace/ftrace.c.

We move sysctls to places where features actually belong to improve the readability of the code and reduce the risk of code merge conflicts. At the same time, the proc-sysctl maintainers do not want to know what sysctl knobs you wish to add for your owner piece of code, we just care about the core logic.

Thanks for using a commit log message which helps folks understand why we are doing this.

Quoted 2 lines

Thanks, queued on sysctl-next!

Luis