From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2633 invoked by alias); 9 May 2014 03:11:40 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 2618 invoked by uid 89); 9 May 2014 03:11:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail9.hitachi.co.jp Received: from mail9.hitachi.co.jp (HELO mail9.hitachi.co.jp) (133.145.228.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 May 2014 03:11:37 +0000 Received: from mlsv7.hitachi.co.jp (unknown [133.144.234.166]) by mail9.hitachi.co.jp (Postfix) with ESMTP id 736D337C86; Fri, 9 May 2014 12:11:34 +0900 (JST) Received: from mfilter06.hitachi.co.jp by mlsv7.hitachi.co.jp (8.13.1/8.13.1) id s493BYdN032310; Fri, 9 May 2014 12:11:34 +0900 Received: from vshuts01.hitachi.co.jp (vshuts01.hitachi.co.jp [10.201.6.83]) by mfilter06.hitachi.co.jp (Switch-3.3.4/Switch-3.3.4) with ESMTP id s493BW7u005097; Fri, 9 May 2014 12:11:33 +0900 Received: from gxml20a.ad.clb.hitachi.co.jp (unknown [158.213.157.160]) by vshuts01.hitachi.co.jp (Postfix) with ESMTP id 0A3652F0042; Fri, 9 May 2014 12:11:33 +0900 (JST) Received: from [10.198.219.54] by gxml20a.ad.clb.hitachi.co.jp (Switch-3.1.10/Switch-3.1.9) id 64930BWBK0000D370; Fri, 09 May 2014 12:11:32 +0900 Message-ID: <536C4761.9050609@hitachi.com> Date: Fri, 09 May 2014 03:11:00 -0000 From: Masami Hiramatsu User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Andi Kleen , Ananth N Mavinakayanahalli , Sandeepa Prabhu , Frederic Weisbecker , x86@kernel.org, fche@redhat.com, mingo@redhat.com, systemtap@sourceware.org, "H. Peter Anvin" , Thomas Gleixner Subject: Re: Re: [PATCH -tip v10 7/7] ftrace: Introduce FTRACE_OPS_FL_SELF_FILTER for ftrace-kprobe References: <20140508093842.31767.43766.stgit@ltc230.yrl.intra.hitachi.co.jp> <20140508093930.31767.86419.stgit@ltc230.yrl.intra.hitachi.co.jp> <20140508065947.214f4951@gandalf.local.home> In-Reply-To: <20140508065947.214f4951@gandalf.local.home> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-q2/txt/msg00137.txt.bz2 (2014/05/08 19:59), Steven Rostedt wrote: > On Thu, 08 May 2014 18:39:30 +0900 > Masami Hiramatsu wrote: > >> Since the kprobes itself owns a hash table to get a kprobe >> data structure corresponding to the given ip address, there >> is no need to test ftrace hash in ftrace side. >> To achive better performance on ftrace-based kprobe, >> FTRACE_OPS_FL_SELF_FILTER flag to ftrace_ops which means >> that ftrace skips testing its own hash table. >> >> Without this patch, ftrace_lookup_ip() is biggest cycles >> consumer when 20,000 kprobes are enabled. >> ---- >> Samples: 1K of event 'cycles', Event count (approx.): 340068894 >> + 20.77% [k] ftrace_lookup_ip >> + 8.33% [k] kprobe_trace_func >> + 4.83% [k] get_kprobe_cached >> ---- >> >> With this patch, ftrace_lookup_ip() vanished from the >> cycles consumer list (of course, there is no caller on >> hotpath anymore :)) >> ---- >> Samples: 1K of event 'cycles', Event count (approx.): 186861492 >> + 9.95% [k] kprobe_trace_func >> + 6.00% [k] kprobe_ftrace_handler >> + 5.53% [k] get_kprobe_cached > > I should look at your filtering methods, maybe it can make ftrace > filtering better? Ah! Yes, it could be better :) At least the hash-table cache is good for ftrace too. Currently it is just for fixed-size hash-table, but is easy to expand for resizable one. (however, I guess with the cache we don't need to resize that anymore.) > >> ---- >> >> Changes from v7: >> - Re-evaluate the performance improvement. >> >> Signed-off-by: Masami Hiramatsu >> Cc: Steven Rostedt >> Cc: Frederic Weisbecker >> Cc: Ingo Molnar >> --- >> include/linux/ftrace.h | 3 +++ >> kernel/kprobes.c | 2 +- >> kernel/trace/ftrace.c | 3 ++- >> 3 files changed, 6 insertions(+), 2 deletions(-) >> >> diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h >> index ae9504b..f1fa7d27 100644 >> --- a/include/linux/ftrace.h >> +++ b/include/linux/ftrace.h >> @@ -93,6 +93,8 @@ typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip, >> * INITIALIZED - The ftrace_ops has already been initialized (first use time >> * register_ftrace_function() is called, it will initialized the ops) >> * DELETED - The ops are being deleted, do not let them be registered again. >> + * SELF_FILTER - The ftrace_ops function filters ip by itself. Do not need to >> + * check hash table on each hit. > > - The ftrace_ops function has its own ip filter and does not need to > rely on the ftrace internal ip filtering. OK, I'll update that. > > >> */ >> enum { >> FTRACE_OPS_FL_ENABLED = 1 << 0, >> @@ -105,6 +107,7 @@ enum { >> FTRACE_OPS_FL_STUB = 1 << 7, >> FTRACE_OPS_FL_INITIALIZED = 1 << 8, >> FTRACE_OPS_FL_DELETED = 1 << 9, >> + FTRACE_OPS_FL_SELF_FILTER = 1 << 10, >> }; >> >> /* >> diff --git a/kernel/kprobes.c b/kernel/kprobes.c >> index 0f5f23c..5c6e410 100644 >> --- a/kernel/kprobes.c >> +++ b/kernel/kprobes.c >> @@ -1027,7 +1027,7 @@ static struct kprobe *alloc_aggr_kprobe(struct kprobe *p) >> #ifdef CONFIG_KPROBES_ON_FTRACE >> static struct ftrace_ops kprobe_ftrace_ops __read_mostly = { >> .func = kprobe_ftrace_handler, >> - .flags = FTRACE_OPS_FL_SAVE_REGS, >> + .flags = FTRACE_OPS_FL_SAVE_REGS | FTRACE_OPS_FL_SELF_FILTER, >> }; >> static int kprobe_ftrace_enabled; >> >> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c >> index 4a54a25..062ca20 100644 >> --- a/kernel/trace/ftrace.c >> +++ b/kernel/trace/ftrace.c >> @@ -4501,7 +4501,8 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, >> */ >> preempt_disable_notrace(); >> do_for_each_ftrace_op(op, ftrace_ops_list) { >> - if (ftrace_ops_test(op, ip, regs)) >> + if (op->flags & FTRACE_OPS_FL_SELF_FILTER || >> + ftrace_ops_test(op, ip, regs)) > > Hmm, I wonder if I should add the check for: > > !(op->flags & FTRACE_OPS_FL_STUB) > > here too? But that's another change that I'll do. Indeed. BTW, should I change ftrace_ops_control_func() too? > > Just update the flag description as I commented and the rest looks good. OK, thanks! -- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com