From patchwork Tue Jun 26 23:23:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9631 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 6ED4B23F28 for ; Tue, 26 Jun 2012 23:25:42 +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 27499A18885 for ; Tue, 26 Jun 2012 23:25:42 +0000 (UTC) Received: by ghbz12 with SMTP id z12so547177ghb.11 for ; Tue, 26 Jun 2012 16:25:41 -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=PddG8Xx0Kfa0nhvFPoF1xc6vI6Amhh0xFvbqUIeXaoYGcwJ3N9qBoC+4bh8xXdwsIP YjumYXkSh9piQz/ofU7UssGB2DaVcaO4G/+3pI8PY3PplP4iLaB8AN8u2GqG/v5mx0LJ g/TWnqWdyJTb1kU3IZMxBfNTn9zVxg4dvucwg3kwKFcSkvtgH+s75SyLld9Q11lMjwBi sgdZI9d5owYP8vXnMb2HNNR/pNfSMHdl98d35Jd985H8goihwGznClhaHV/5QvJ9Btpr KrkLEsQuTmUF5yeXvYsuEiOOGDl0vIwBG8qY2g4wUqQTxJwbcxlxuM5ZSy8PKoYG1Cs5 3yFw== Received: by 10.50.193.196 with SMTP id hq4mr12685921igc.57.1340753141382; Tue, 26 Jun 2012 16:25:41 -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 v20csp91711ibb; Tue, 26 Jun 2012 16:25:40 -0700 (PDT) Received: by 10.68.221.74 with SMTP id qc10mr57074157pbc.31.1340753140653; Tue, 26 Jun 2012 16:25:40 -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 wh5si6845470pbc.338.2012.06.26.16.25.40 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 26 Jun 2012 16:25:40 -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 mail-pz0-f50.google.com with SMTP id h15so631212dan.37 for ; Tue, 26 Jun 2012 16:25:40 -0700 (PDT) Received: by 10.68.240.73 with SMTP id vy9mr56247456pbc.102.1340753140413; Tue, 26 Jun 2012 16:25:40 -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 u5sm13186126pbu.76.2012.06.26.16.25.38 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 26 Jun 2012 16:25:39 -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/7] tracing/function: Introduce persistent trace option Date: Tue, 26 Jun 2012 16:23:26 -0700 Message-Id: <1340753009-12483-4-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120626232210.GA11549@lizard> References: <20120626232210.GA11549@lizard> X-Gm-Message-State: ALoCoQkAOjIIHKOgn+vosFagPpThGFJpIagzgH1nxchG83YSOHNr50QH1SzfARk4UIaFnxNBwY0W 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; }