From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756592AbbLAOz6 (ORCPT ); Tue, 1 Dec 2015 09:55:58 -0500 Received: from smtprelay0058.hostedemail.com ([216.40.44.58]:45130 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756569AbbLAOz5 (ORCPT ); Tue, 1 Dec 2015 09:55:57 -0500 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::,RULES_HIT:41: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:1711:1730:1747:1777:1792:1981:2194:2199:2393:2553:2559:2562:2693:3138:3139:3140:3141:3142:3355:3622:3865:3866:3867:3868:3871:3872:3873:3874:4250:4321:4605:5007:6119:6261:7875:8660:9010:9012:9038:10004:10394:10400:10848:10967:11026:11232:11473:11658:11914:12043:12295:12296:12438:12517:12519:12555:12663:12740:13148:13230:13618:14659:21080:30012: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:1,LUA_SUMMARY:none X-HE-Tag: note43_6dedb6b032f20 X-Filterd-Recvd-Size: 4032 Date: Tue, 1 Dec 2015 09:55:54 -0500 From: Steven Rostedt To: Jiri Olsa Cc: LKML , Ingo Molnar , Peter Zijlstra Subject: Re: [PATCH] ftrace: Remove use of control list and ops Message-ID: <20151201095554.7b56bff7@gandalf.local.home> In-Reply-To: <20151201134213.GA14155@krava.brq.redhat.com> References: <20151130173640.2c45b429@gandalf.local.home> <20151201134213.GA14155@krava.brq.redhat.com> X-Mailer: Claws Mail 3.13.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 Tue, 1 Dec 2015 14:42:36 +0100 Jiri Olsa wrote: > On Mon, Nov 30, 2015 at 05:36:40PM -0500, Steven Rostedt wrote: > > > > [ Jiri, can you take a look at this. You can also apply it on top of my > > branch ftrace/core, and run any specific tests. I just need to nuke > > that control structure for further updates with ftrace. ] > > > > > > Currently perf has its own list function within the ftrace infrastructure > > that seems to be used only to allow for it to have per-cpu disabling as well > > as a check to make sure that it's not called while RCU is not watching. It > > uses something called the "control_ops" which is used to iterate over ops > > under it with the control_list_func(). > > > > The problem is that this control_ops and control_list_func unnecessarily > > complicates the code. By replacing FTRACE_OPS_FL_CONTROL with two new flags > > (FTRACE_OPS_FL_RCU and FTRACE_OPS_FL_PER_CPU) we can remove all the code > > that is special with the control ops and add the needed checks within the > > generic ftrace_list_func(). > > hum, > do we need also change for the trampoline, something like below? > > I needed attached patch to get the perf ftrace:function > event work properly.. Hmm, I thought that I forced the list function when RCU or PER_CPU was set. Oh wait. I have CONFIG_PREEMPT set, which will change the logic slightly. I'm guessing you have PREEMPT_VOLUNTARY set. I'll try that out. > > thanks, > jirka > > > --- > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index c4d881200d1f..2705ac2f3487 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -5179,6 +5179,26 @@ static void ftrace_ops_recurs_func(unsigned long ip, unsigned long parent_ip, > trace_clear_recursion(bit); > } > > +static void ftrace_ops_per_cpu_func(unsigned long ip, unsigned long parent_ip, > + struct ftrace_ops *op, struct pt_regs *regs) > +{ > + int bit; > + > + bit = trace_test_and_set_recursion(TRACE_LIST_START, TRACE_LIST_MAX); > + if (bit < 0) > + return; > + > + preempt_disable_notrace(); > + > + if ((!(op->flags & FTRACE_OPS_FL_RCU) || rcu_is_watching()) && > + (!(op->flags & FTRACE_OPS_FL_PER_CPU) || !ftrace_function_local_disabled(op))) { > + op->func(ip, parent_ip, op, regs); > + } > + > + preempt_enable_notrace(); > + trace_clear_recursion(bit); > +} > + > /** > * ftrace_ops_get_func - get the function a trampoline should call > * @ops: the ops to get the function for > @@ -5192,6 +5212,11 @@ static void ftrace_ops_recurs_func(unsigned long ip, unsigned long parent_ip, > */ > ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops) > { > + if (ops->flags & (FTRACE_OPS_FL_PER_CPU|FTRACE_OPS_FL_RCU)) { > + printk("used per cpu trampoline function\n"); > + return ftrace_ops_per_cpu_func; I have a slight different idea on how to handle this. -- Steve > + } > + > /* > * If the func handles its own recursion, call it directly. > * Otherwise call the recursion protected function that