linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ftrace: move function_stats out of __initdata
@ 2016-07-04 13:09 Arnd Bergmann
  2016-07-04 14:21 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2016-07-04 13:09 UTC (permalink / raw)
  To: Steven Rostedt, Ingo Molnar; +Cc: Arnd Bergmann, Dmitry Safonov, linux-kernel

Not marking ftrace_init_tracefs() as __init causes a link time warning:

WARNING: vmlinux.o(.text+0xf5fcc): Section mismatch in reference from the function ftrace_init_tracefs() to the (unknown reference) .init.data:(unknown)

The problem here is that ftrace_init_tracefs() now gets called by
init_tracer_tracefs(), which cannot be __init because it is called
post init-time from instance_mkdir(). The function calls to the
init-time ftrace_init_dyn_tracefs() and ftrace_profile_tracefs()
functions apparently only happen for the initial call to
ftrace_init_tracefs(), so we could safely ignore the warning, but
at the same time, it all gets inlined anyway and we may as well
remove the annotations.

The alternative would be restructuring the code so we only call
trace_create_file() from init_tracer_tracefs(), but not the other
init-time functions.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 345ddcc882d8 ("ftrace: Have set_ftrace_pid use the bitmap like events do")
---
 kernel/trace/ftrace.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index a486d7def6f4..815170769022 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1011,7 +1011,7 @@ static const struct file_operations ftrace_profile_fops = {
 };
 
 /* used to initialize the real stat files */
-static struct tracer_stat function_stats __initdata = {
+static struct tracer_stat function_stats = {
 	.name		= "functions",
 	.stat_start	= function_stat_start,
 	.stat_next	= function_stat_next,
@@ -1020,7 +1020,7 @@ static struct tracer_stat function_stats __initdata = {
 	.stat_show	= function_stat_show
 };
 
-static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
+static void ftrace_profile_tracefs(struct dentry *d_tracer)
 {
 	struct ftrace_profile_stat *stat;
 	struct dentry *entry;
@@ -1061,7 +1061,7 @@ static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
 }
 
 #else /* CONFIG_FUNCTION_PROFILER */
-static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
+static void ftrace_profile_tracefs(struct dentry *d_tracer)
 {
 }
 #endif /* CONFIG_FUNCTION_PROFILER */
@@ -4797,7 +4797,7 @@ void ftrace_destroy_filter_files(struct ftrace_ops *ops)
 	mutex_unlock(&ftrace_lock);
 }
 
-static __init int ftrace_init_dyn_tracefs(struct dentry *d_tracer)
+static int ftrace_init_dyn_tracefs(struct dentry *d_tracer)
 {
 
 	trace_create_file("available_filter_functions", 0444,
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ftrace: move function_stats out of __initdata
  2016-07-04 13:09 [PATCH] ftrace: move function_stats out of __initdata Arnd Bergmann
@ 2016-07-04 14:21 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2016-07-04 14:21 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Ingo Molnar, Dmitry Safonov, linux-kernel, Stephen Rothwell

On Mon,  4 Jul 2016 15:09:44 +0200
Arnd Bergmann <arnd@arndb.de> wrote:

> Not marking ftrace_init_tracefs() as __init causes a link time warning:
> 
> WARNING: vmlinux.o(.text+0xf5fcc): Section mismatch in reference from the function ftrace_init_tracefs() to the (unknown reference) .init.data:(unknown)
> 
> The problem here is that ftrace_init_tracefs() now gets called by
> init_tracer_tracefs(), which cannot be __init because it is called
> post init-time from instance_mkdir(). The function calls to the
> init-time ftrace_init_dyn_tracefs() and ftrace_profile_tracefs()
> functions apparently only happen for the initial call to
> ftrace_init_tracefs(), so we could safely ignore the warning, but
> at the same time, it all gets inlined anyway and we may as well
> remove the annotations.
> 
> The alternative would be restructuring the code so we only call
> trace_create_file() from init_tracer_tracefs(), but not the other
> init-time functions.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 345ddcc882d8 ("ftrace: Have set_ftrace_pid use the bitmap like events do")

I know about this, and this is not the fix. The issue is that
ftrace_init_tracefs() has:

	if (tr->flags & TRACE_ARRAY_FL_GLOBAL) {
		ftrace_init_dyn_tracefs(d_tracer);
		ftrace_profile_tracefs(d_tracer);
	}

Where that condition is only true on boot up. Hence, those two
functions will never get called during normal runtime situations.

I have a patch to fix this, I just haven't gotten around to running it
through my test suite, or even committing it for that matter. It's a US
holiday today and I wont be doing any more with this till tomorrow.

Below is the patch. Feel free to test it out (I haven't done much with
it yet).

-- Steve

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 8b488f4dd8e8..84752c8e28b5 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5539,16 +5539,20 @@ static const struct file_operations ftrace_pid_fops = {
 
 void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d_tracer)
 {
-	/* Only the top level directory has the dyn_tracefs and profile */
-	if (tr->flags & TRACE_ARRAY_FL_GLOBAL) {
-		ftrace_init_dyn_tracefs(d_tracer);
-		ftrace_profile_tracefs(d_tracer);
-	}
-
 	trace_create_file("set_ftrace_pid", 0644, d_tracer,
 			    tr, &ftrace_pid_fops);
 }
 
+void __init ftrace_init_tracefs_toplevel(struct trace_array *tr,
+					 struct dentry *d_tracer)
+{
+	/* Only the top level directory has the dyn_tracefs and profile */
+	WARN_ON(!(tr->flags & TRACE_ARRAY_FL_GLOBAL));
+
+	ftrace_init_dyn_tracefs(d_tracer);
+	ftrace_profile_tracefs(d_tracer);
+}
+
 /**
  * ftrace_kill - kill ftrace
  *
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 3d9f31b576f3..5fd53a7847bc 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -7369,6 +7369,7 @@ static __init int tracer_init_tracefs(void)
 		return 0;
 
 	init_tracer_tracefs(&global_trace, d_tracer);
+	ftrace_init_tracefs_toplevel(&global_trace, d_tracer);
 
 	trace_create_file("tracing_thresh", 0644, d_tracer,
 			&global_trace, &tracing_thresh_fops);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index eaee458755a4..d751ed7c663b 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -857,6 +857,8 @@ void ftrace_init_array_ops(struct trace_array *tr, ftrace_func_t func);
 void ftrace_reset_array_ops(struct trace_array *tr);
 int using_ftrace_ops_list_func(void);
 void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d_tracer);
+void ftrace_init_tracefs_toplevel(struct trace_array *tr,
+				  struct dentry *d_tracer);
 #else
 static inline int ftrace_trace_task(struct trace_array *tr)
 {

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-04 14:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-04 13:09 [PATCH] ftrace: move function_stats out of __initdata Arnd Bergmann
2016-07-04 14:21 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).