From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030456AbbKDPDn (ORCPT ); Wed, 4 Nov 2015 10:03:43 -0500 Received: from smtprelay0157.hostedemail.com ([216.40.44.157]:57598 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1030346AbbKDPDm (ORCPT ); Wed, 4 Nov 2015 10:03:42 -0500 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::,RULES_HIT:41:69:355:379:541:599:800:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1543:1593:1594:1605:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2689:2693:2731:3138:3139:3140:3141:3142:3622:3865:3866:3867:3868:3870:3871:3874:4250:4321:5007:6261:7514:7875:9707:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12296:12438:12517:12519:12555:12740:13255:14659:21080:30029:30036: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:2,LUA_SUMMARY:none X-HE-Tag: blood42_3d2751892c32a X-Filterd-Recvd-Size: 4937 Date: Wed, 4 Nov 2015 10:03:39 -0500 From: Steven Rostedt To: Jiaxing Wang Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: Re: [PATCH RESEND] tracing: Make tracing work when debugfs is not compiled or initialized. Message-ID: <20151104100339.583e1bc9@gandalf.local.home> In-Reply-To: <1446599478-8723-1-git-send-email-hello.wjx@gmail.com> References: <20151102091637.0fcc05b2@gandalf.local.home> <1446599478-8723-1-git-send-email-hello.wjx@gmail.com> X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; 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 Wed, 4 Nov 2015 09:11:18 +0800 Jiaxing Wang wrote: > Currently tracing_init_dentry() returns -ENODEV when debugfs is not > initialized, which causes tracefs not populated with tracing files and > directories, so we will get an empty directory even after we manually > mount tracefs. > > We can make tracing_init_dentry() return NULL as long as tracefs > is initialized and get a populated tracefs. > > We also need to make global_trace.dir not NULL in order to pass the checks > in tracing_get_dentry() and add_tracer_options(). > > Also added stub debugfs_create_automount() for when debugfs is not > configured in. > > Signed-off-by: Jiaxing Wang > --- > include/linux/debugfs.h | 8 ++++++++ > kernel/trace/Kconfig | 1 - > kernel/trace/trace.c | 29 +++++++++++++++++------------ > 3 files changed, 25 insertions(+), 13 deletions(-) > > diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h > index 9beb636..b42ef88 100644 > --- a/include/linux/debugfs.h > +++ b/include/linux/debugfs.h > @@ -160,6 +160,14 @@ static inline struct dentry *debugfs_create_symlink(const char *name, > return ERR_PTR(-ENODEV); > } > > +static inline struct dentry *debugfs_create_automount(const char *name, > + struct dentry *parent, > + struct vfsmount *(*f)(void *), > + void *data) > +{ > + return ERR_PTR(-ENODEV); > +} This part needs an Acked-by from Greg KH. > + > static inline void debugfs_remove(struct dentry *dentry) > { } > > diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig > index 1153c43..59f6377f 100644 > --- a/kernel/trace/Kconfig > +++ b/kernel/trace/Kconfig > @@ -95,7 +95,6 @@ config RING_BUFFER_ALLOW_SWAP > > config TRACING > bool > - select DEBUG_FS > select RING_BUFFER > select STACKTRACE if STACKTRACE_SUPPORT > select TRACEPOINTS > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > index 6e79408..6dd064e 100644 > --- a/kernel/trace/trace.c > +++ b/kernel/trace/trace.c > @@ -6706,6 +6706,8 @@ static struct vfsmount *trace_automount(void *ingore) > return mnt; > } > > +#define TRACE_TOP_DIR_ENTRY ((struct dentry *)1) > + > /** > * tracing_init_dentry - initialize top level trace array > * > @@ -6716,27 +6718,30 @@ static struct vfsmount *trace_automount(void *ingore) > struct dentry *tracing_init_dentry(void) > { > struct trace_array *tr = &global_trace; > + struct dentry *traced; > > /* The top level trace array uses NULL as parent */ > if (tr->dir) > return NULL; > > - if (WARN_ON(!debugfs_initialized())) > + if (WARN_ON(!tracefs_initialized())) > return ERR_PTR(-ENODEV); > > - /* > - * As there may still be users that expect the tracing > - * files to exist in debugfs/tracing, we must automount > - * the tracefs file system there, so older tools still > - * work with the newer kerenl. > - */ > - tr->dir = debugfs_create_automount("tracing", NULL, > - trace_automount, NULL); > - if (!tr->dir) { > - pr_warn_once("Could not create debugfs directory 'tracing'\n"); > - return ERR_PTR(-ENOMEM); > + if (debugfs_initialized()) { > + /* > + * As there may still be users that expect the tracing > + * files to exist in debugfs/tracing, we must automount > + * the tracefs file system there, so older tools still > + * work with the newer kerenl. > + */ > + traced = debugfs_create_automount("tracing", NULL, > + trace_automount, NULL); > + if (!traced) > + pr_warn_once("Could not create debugfs directory 'tracing'\n"); This should return a warning, and please keep the tr->dir instead of this new traced variable. > } > > + tr->dir = TRACE_TOP_DIR_ENTRY; > + Also, no need to add this, because if debugfs is not initialize, then tr->dir would be ERR_PTR(-ENODEV), which still works as tr->dir is not NULL. -- Steve > return NULL; > } >