From patchwork Fri Jun 15 17:08:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9325 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 4BDBF23E5A for ; Fri, 15 Jun 2012 17:10:51 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 1A432A18174 for ; Fri, 15 Jun 2012 17:10:51 +0000 (UTC) Received: by mail-gh0-f180.google.com with SMTP id z12so2723876ghb.11 for ; Fri, 15 Jun 2012 10:10:50 -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=voZhmn3bvoEj8lLveuwY1ubNSU4/qHAYaFCeBUWpEIk=; b=EQhe0geDI4ibgid0qT0JzXIL5Ee9FKzyCdNaP9DUbEEUCUWAk4hx6tNM0mtMGONj8K UTMs3fN+3IK8CBAxaz0T3Lv2MBcrR4qnFiDhxowfnhxwxP12BHj/D8qCugmmhhawn5/T 1xDtwKC3bR2vriAepDY/i2eUoU4ivjxEUTEE5tXDkCpLUfMCE3Z19+kyxgTHHHbbpis7 RxQb6eg/SVnz41aiV2MNTSqkuORR80hswXvNUUkQomC4cjiPtE6t93bOMDuP2Ps8JJgk DLRl/0ZXp/gp/lcBpi22lKU5i2wFlcbcTxyKxRQTPcKfvNVXRfJdnCAuzZS9Ih/htuj5 f0fA== Received: by 10.50.193.196 with SMTP id hq4mr2730650igc.57.1339780250779; Fri, 15 Jun 2012 10:10:50 -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 v20csp158958ibb; Fri, 15 Jun 2012 10:10:50 -0700 (PDT) Received: by 10.68.220.163 with SMTP id px3mr6457070pbc.167.1339780250119; Fri, 15 Jun 2012 10:10:50 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id mo5si109272pbc.298.2012.06.15.10.10.49 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jun 2012 10:10:50 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.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 danh15 with SMTP id h15so4705967dan.37 for ; Fri, 15 Jun 2012 10:10:49 -0700 (PDT) Received: by 10.68.193.195 with SMTP id hq3mr21533806pbc.30.1339780249784; Fri, 15 Jun 2012 10:10:49 -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 os1sm13818306pbb.49.2012.06.15.10.10.47 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jun 2012 10:10:49 -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/6] tracing/function: Introduce persistent trace option Date: Fri, 15 Jun 2012 10:08:29 -0700 Message-Id: <1339780111-12075-4-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120615170659.GA4060@lizard> References: <20120615170659.GA4060@lizard> X-Gm-Message-State: ALoCoQn1vEp+LuJ4EuP6Wx+wE4LpCdBZ9lCneyh+16sRNhtZ11jp9uM/cP0Elk0TsgC1opgtPuv/ 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..269627c 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 */ }; @@ -219,6 +232,8 @@ static int func_set_flag(u32 old_flags, u32 bit, int set) return 0; } + if (bit == TRACE_FUNC_OPT_PSTORE) + return 0; return -EINVAL; }