From patchwork Tue Jul 10 00:10:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9910 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 18A4D23E01 for ; Tue, 10 Jul 2012 00:13:16 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id C7B22A1875D for ; Tue, 10 Jul 2012 00:13:15 +0000 (UTC) Received: by yhpp61 with SMTP id p61so12357569yhp.11 for ; Mon, 09 Jul 2012 17:13:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=8vlSIukKBvKHGtugqtWLK2n9eToIM4s5nuufhX6bzu4=; b=R+udtv2iDkfIj8Kg91xpk0xapZtKmpsoesU9bm6h55EPxLZj2dAGi4Oq+V5tFK7Bc4 5pO9ve3Soh8qb32PdR/h+bQnOg5fAeuv6BIrN3OSBgygxnyuqfHqsomedP4n9F5+lett YwMAJ3iOIHP7swJbTE0JdkIMpvthzBidkG0cYB62rro5lJeYvwHHK+tyX1CRbSPSBIoM lOspYLfTNtfgcfrcbr7mfhEf8PBjd0muOv0XNg2ExAcfjTCx9MG0HPqSJs3zPrWeRvPk 6gYeN24bBct6hiE0RTdBMY6vQnDBcGW4/Yu/b0pUP6yxgCNt/aC8PfWIzB6gjBN2KG9Y XFTA== Received: by 10.50.57.167 with SMTP id j7mr9721439igq.53.1341879195181; Mon, 09 Jul 2012 17:13:15 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp42692ibb; Mon, 9 Jul 2012 17:13:14 -0700 (PDT) Received: by 10.236.153.104 with SMTP id e68mr49038861yhk.36.1341879194467; Mon, 09 Jul 2012 17:13:14 -0700 (PDT) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by mx.google.com with ESMTPS id d45si11449208yhe.92.2012.07.09.17.13.14 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 17:13:14 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.213.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by yhjj63 with SMTP id j63so6225232yhj.37 for ; Mon, 09 Jul 2012 17:13:14 -0700 (PDT) Received: by 10.66.74.69 with SMTP id r5mr69150219pav.56.1341879193795; Mon, 09 Jul 2012 17:13:13 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id hz10sm28651666pbc.32.2012.07.09.17.13.11 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 17:13:13 -0700 (PDT) From: Anton Vorontsov To: Greg Kroah-Hartman , Kees Cook , Colin Cross , Tony Luck , Steven Rostedt , Frederic Weisbecker , Ingo Molnar Cc: Arnd Bergmann , John Stultz , Shuah Khan , arve@android.com, Rebecca Schultz Zavin , Jesper Juhl , Randy Dunlap , Stephen Boyd , Thomas Meyer , Andrew Morton , Marco Stornelli , WANG Cong , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com Subject: [PATCH 4/8] tracing/function: Introduce persistent trace option Date: Mon, 9 Jul 2012 17:10:42 -0700 Message-Id: <1341879046-5197-4-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120710001004.GA22744@lizard> References: <20120710001004.GA22744@lizard> X-Gm-Message-State: ALoCoQnlMbZMPMeOWVfHSc4r8QeLUaxgUCAPjEb0OO/vWT5NhMVghmaDlACfpq97iMQSsEU8AJkF This patch introduces 'func_ptrace' option, now available in /sys/kernel/debug/tracing/options when function tracer is selected. The patch also adds some tiny code that calls back to pstore to record the trace. The callback is no-op when PSTORE=n. Signed-off-by: Anton Vorontsov --- kernel/trace/trace_functions.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index c7b0c6a..13770ab 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "trace.h" @@ -74,6 +75,14 @@ function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip) preempt_enable_notrace(); } +/* Our two options */ +enum { + TRACE_FUNC_OPT_STACK = 0x1, + TRACE_FUNC_OPT_PSTORE = 0x2, +}; + +static struct tracer_flags func_flags; + static void function_trace_call(unsigned long ip, unsigned long parent_ip) { @@ -97,6 +106,12 @@ function_trace_call(unsigned long ip, unsigned long parent_ip) disabled = atomic_inc_return(&data->disabled); if (likely(disabled == 1)) { + /* + * So far tracing doesn't support multiple buffers, so + * we make an explicit call for now. + */ + if (unlikely(func_flags.val & TRACE_FUNC_OPT_PSTORE)) + pstore_ftrace_call(ip, parent_ip); pc = preempt_count(); trace_function(tr, ip, parent_ip, flags, pc); } @@ -158,15 +173,13 @@ static struct ftrace_ops trace_stack_ops __read_mostly = .flags = FTRACE_OPS_FL_GLOBAL, }; -/* Our two options */ -enum { - TRACE_FUNC_OPT_STACK = 0x1, -}; - static struct tracer_opt func_opts[] = { #ifdef CONFIG_STACKTRACE { TRACER_OPT(func_stack_trace, TRACE_FUNC_OPT_STACK) }, #endif +#ifdef CONFIG_PSTORE_FTRACE + { TRACER_OPT(func_pstore, TRACE_FUNC_OPT_PSTORE) }, +#endif { } /* Always set a last empty entry */ }; @@ -218,6 +231,8 @@ static int func_set_flag(u32 old_flags, u32 bit, int set) } return 0; + } else if (bit == TRACE_FUNC_OPT_PSTORE) { + return 0; } return -EINVAL;