Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936178AbcKNS4W (ORCPT ); Mon, 14 Nov 2016 13:56:22 -0500 Received: from smtprelay0104.hostedemail.com ([216.40.44.104]:47023 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933699AbcKNS4S (ORCPT ); Mon, 14 Nov 2016 13:56:18 -0500 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::,RULES_HIT:41:355:379:541:599:800:960:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1543:1593:1594:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2553:2559:2562:2693:2895:3138:3139:3140:3141:3142:3355:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4385:5007:6261:7875:8660:9108:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12296:12438:12555:12740:12760:13148:13230:13439:13972:14096:14097:14181:14659:14721:14819:21080:21451:30051:30054:30070: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: bone68_70ead215b6b1c X-Filterd-Recvd-Size: 3942 Date: Mon, 14 Nov 2016 13:56:14 -0500 From: Steven Rostedt To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, Kees Cook , Ingo Molnar Subject: Re: [PATCH 1/2] ftrace: Provide API to use global filtering for ftrace ops Message-ID: <20161114135614.7e3e250e@gandalf.local.home> In-Reply-To: <1476927103-21230-1-git-send-email-joelaf@google.com> References: <1476927103-21230-1-git-send-email-joelaf@google.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; 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 Content-Length: 2971 Lines: 77 On Wed, 19 Oct 2016 18:31:42 -0700 Joel Fernandes wrote: > Currently the global_ops filtering hash is not available to outside > users registering for function tracing. Provide an API for those > users to be able to choose global filtering. > > This is in preparation for pstore's ftrace feature to be able to > use the global filters. > > Suggested-by: Steven Rostedt > Signed-off-by: Joel Fernandes > --- > include/linux/ftrace.h | 2 ++ > kernel/trace/ftrace.c | 13 +++++++++++++ > 2 files changed, 15 insertions(+) > > diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h > index 7d565af..653600a 100644 > --- a/include/linux/ftrace.h > +++ b/include/linux/ftrace.h > @@ -398,6 +398,7 @@ int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf, > void ftrace_set_global_filter(unsigned char *buf, int len, int reset); > void ftrace_set_global_notrace(unsigned char *buf, int len, int reset); > void ftrace_free_filter(struct ftrace_ops *ops); > +void ftrace_ops_set_global_filter(struct ftrace_ops *ops); > > int register_ftrace_command(struct ftrace_func_command *cmd); > int unregister_ftrace_command(struct ftrace_func_command *cmd); > @@ -645,6 +646,7 @@ static inline unsigned long ftrace_location(unsigned long ip) > #define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; }) > #define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; }) > #define ftrace_free_filter(ops) do { } while (0) > +#define ftrace_ops_set_global_filter(ops) do { } while (0) > > static inline ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf, > size_t cnt, loff_t *ppos) { return -ENODEV; } > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index 84752c8..c768c7a 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -4233,6 +4233,19 @@ int ftrace_set_filter_ip(struct ftrace_ops *ops, unsigned long ip, > } > EXPORT_SYMBOL_GPL(ftrace_set_filter_ip); > > +/** > + * ftrace_ops_set_global_filter - setup ops to use global filters > + * @ops - the ops which will use the global filters > + * > + * ftrace users who need global function trace filtering should call this. > + */ > +void ftrace_ops_set_global_filter(struct ftrace_ops *ops) > +{ I think we should add: if (ops->flags & FTRACE_OPS_FL_INITIALIZED) return; This function must only be called if ops hasn't been initialized yet. Probably need to add that in the comment for the function as well. But other than that, this looks good. Post an update, and since the next patch is dependent on this one, It may be best to go through your tree (after I ack the next version of this patch). -- Steve > + ftrace_ops_init(ops); > + ops->func_hash = &global_ops.local_hash; > +} > +EXPORT_SYMBOL_GPL(ftrace_ops_set_global_filter); > + > static int > ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len, > int reset, int enable)