Skip to content

Commit f8b7d2b

Browse files
committed
ftrace: fix building with SYSCTL=n but DYNAMIC_FTRACE=y
One can enable dyanmic tracing but disable sysctls. When this is doen we get the compile kernel warning: CC kernel/trace/ftrace.o kernel/trace/ftrace.c:3086:13: warning: ‘ftrace_shutdown_sysctl’ defined but not used [-Wunused-function] 3086 | static void ftrace_shutdown_sysctl(void) | ^~~~~~~~~~~~~~~~~~~~~~ kernel/trace/ftrace.c:3068:13: warning: ‘ftrace_startup_sysctl’ defined but not used [-Wunused-function] 3068 | static void ftrace_startup_sysctl(void) When CONFIG_DYNAMIC_FTRACE=n the ftrace_startup_sysctl() and routines ftrace_shutdown_sysctl() still compiles, so these are actually more just used for when SYSCTL=y. Fix this then by just moving these routines to when sysctls are enabled. Fixes: 7cde53d ("ftrace: move sysctl_ftrace_enabled to ftrace.c") Reported-by: kernel test robot <[email protected]> Acked-by: Steven Rostedt (Google) <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 5d79fa0 commit f8b7d2b

File tree

1 file changed

+34
-37
lines changed

1 file changed

+34
-37
lines changed

kernel/trace/ftrace.c

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3065,40 +3065,6 @@ int ftrace_shutdown(struct ftrace_ops *ops, int command)
30653065
return 0;
30663066
}
30673067

3068-
static void ftrace_startup_sysctl(void)
3069-
{
3070-
int command;
3071-
3072-
if (unlikely(ftrace_disabled))
3073-
return;
3074-
3075-
/* Force update next time */
3076-
saved_ftrace_func = NULL;
3077-
/* ftrace_start_up is true if we want ftrace running */
3078-
if (ftrace_start_up) {
3079-
command = FTRACE_UPDATE_CALLS;
3080-
if (ftrace_graph_active)
3081-
command |= FTRACE_START_FUNC_RET;
3082-
ftrace_startup_enable(command);
3083-
}
3084-
}
3085-
3086-
static void ftrace_shutdown_sysctl(void)
3087-
{
3088-
int command;
3089-
3090-
if (unlikely(ftrace_disabled))
3091-
return;
3092-
3093-
/* ftrace_start_up is true if ftrace is running */
3094-
if (ftrace_start_up) {
3095-
command = FTRACE_DISABLE_CALLS;
3096-
if (ftrace_graph_active)
3097-
command |= FTRACE_STOP_FUNC_RET;
3098-
ftrace_run_update_code(command);
3099-
}
3100-
}
3101-
31023068
static u64 ftrace_update_time;
31033069
unsigned long ftrace_update_tot_cnt;
31043070
unsigned long ftrace_number_of_pages;
@@ -7267,9 +7233,6 @@ core_initcall(ftrace_nodyn_init);
72677233
static inline int ftrace_init_dyn_tracefs(struct dentry *d_tracer) { return 0; }
72687234
static inline void ftrace_startup_all(int command) { }
72697235

7270-
# define ftrace_startup_sysctl() do { } while (0)
7271-
# define ftrace_shutdown_sysctl() do { } while (0)
7272-
72737236
static void ftrace_update_trampoline(struct ftrace_ops *ops)
72747237
{
72757238
}
@@ -7910,6 +7873,40 @@ int unregister_ftrace_function(struct ftrace_ops *ops)
79107873
EXPORT_SYMBOL_GPL(unregister_ftrace_function);
79117874

79127875
#ifdef CONFIG_SYSCTL
7876+
static void ftrace_startup_sysctl(void)
7877+
{
7878+
int command;
7879+
7880+
if (unlikely(ftrace_disabled))
7881+
return;
7882+
7883+
/* Force update next time */
7884+
saved_ftrace_func = NULL;
7885+
/* ftrace_start_up is true if we want ftrace running */
7886+
if (ftrace_start_up) {
7887+
command = FTRACE_UPDATE_CALLS;
7888+
if (ftrace_graph_active)
7889+
command |= FTRACE_START_FUNC_RET;
7890+
ftrace_startup_enable(command);
7891+
}
7892+
}
7893+
7894+
static void ftrace_shutdown_sysctl(void)
7895+
{
7896+
int command;
7897+
7898+
if (unlikely(ftrace_disabled))
7899+
return;
7900+
7901+
/* ftrace_start_up is true if ftrace is running */
7902+
if (ftrace_start_up) {
7903+
command = FTRACE_DISABLE_CALLS;
7904+
if (ftrace_graph_active)
7905+
command |= FTRACE_STOP_FUNC_RET;
7906+
ftrace_run_update_code(command);
7907+
}
7908+
}
7909+
79137910
static bool is_permanent_ops_registered(void)
79147911
{
79157912
struct ftrace_ops *op;

0 commit comments

Comments
 (0)