From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754031AbcGDOVq (ORCPT ); Mon, 4 Jul 2016 10:21:46 -0400 Received: from smtprelay0026.hostedemail.com ([216.40.44.26]:34969 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753416AbcGDOVo (ORCPT ); Mon, 4 Jul 2016 10:21:44 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::,RULES_HIT:41:355:379:541:599:800:960:966:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1534:1543:1593:1594:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2553:2559:2562:2693:2902:3138:3139:3140:3141:3142:3355:3622:3865:3867:3868:3870:3871:3872:3874:4250:4321:4385:5007:6261:6690:7774:7875:7903:8660:9592:10004:10400:10450:10455:10848:10967:11026:11232:11473:11658:11914:12043:12050:12295:12296:12438:12517:12519:12555:12740:13148:13230:13439:14096:14097:14181:14659:14721:19904:19999:21080:21433:30012:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:5,LUA_SUMMARY:none X-HE-Tag: shirt94_eca9730c240b X-Filterd-Recvd-Size: 4663 Date: Mon, 4 Jul 2016 10:21:39 -0400 From: Steven Rostedt To: Arnd Bergmann Cc: Ingo Molnar , Dmitry Safonov <0x7f454c46@gmail.com>, linux-kernel@vger.kernel.org, Stephen Rothwell Subject: Re: [PATCH] ftrace: move function_stats out of __initdata Message-ID: <20160704102139.19cbc0d9@gandalf.local.home> In-Reply-To: <20160704131005.933647-1-arnd@arndb.de> References: <20160704131005.933647-1-arnd@arndb.de> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 4 Jul 2016 15:09:44 +0200 Arnd Bergmann 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 > 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) {