From patchwork Tue Jul 7 10:10:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 50815 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3057922A03 for ; Tue, 7 Jul 2015 10:13:20 +0000 (UTC) Received: by wgwk7 with SMTP id k7sf4075589wgw.0 for ; Tue, 07 Jul 2015 03:13:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=RyBio5oqu2EdO7nFfhynNtDw6BGLACB9Pbo83EN3nAk=; b=PCepyxisO74IuCU/s5AnoqXeI/yt+frd7qtwiD97rbEIat/LPgGhxThojDjIN0eUgL J4K+HxjGutWu1Ds56y2wba5rNHa4O0kBD000O/f+yXwnM5L7Ll+3UaZkRcSB1B3/Z0no /I5A7Q/BpA4kui7ymXNqr7ykWZU89RK9XnWT+furqGoATzFzo4kZdM3or3pidtrPMNnA LkkZHw7mDXcPvZP+dpx+el5gKwiGcTb2nGdnUKKQspOCnSP2UrP8/eJiMYnmXGLE04/H rcWfKaFTy8L3xMvM0BemN66V8zQNke6SQbxEZRTm1BLS6aqq5kDbj3yfqKev7pjJhwTD PwKQ== X-Gm-Message-State: ALoCoQmLwtwj9859XAWHL1BQSh2aspOqyy86xH7gLjyet7nRquhFCYJSi8ZMy6PIuRQgBJquKns8 X-Received: by 10.112.171.41 with SMTP id ar9mr1742196lbc.24.1436263998418; Tue, 07 Jul 2015 03:13:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.102 with SMTP id s6ls736648lag.102.gmail; Tue, 07 Jul 2015 03:13:18 -0700 (PDT) X-Received: by 10.152.43.134 with SMTP id w6mr2988095lal.120.1436263998170; Tue, 07 Jul 2015 03:13:18 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id qb5si17753753lbb.28.2015.07.07.03.13.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2015 03:13:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by labgy5 with SMTP id gy5so36338260lab.2 for ; Tue, 07 Jul 2015 03:13:18 -0700 (PDT) X-Received: by 10.153.5.38 with SMTP id cj6mr3305681lad.36.1436263998040; Tue, 07 Jul 2015 03:13:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp2283130lbb; Tue, 7 Jul 2015 03:13:16 -0700 (PDT) X-Received: by 10.70.45.168 with SMTP id o8mr7328724pdm.152.1436263996113; Tue, 07 Jul 2015 03:13:16 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xv3si33913038pab.185.2015.07.07.03.13.15; Tue, 07 Jul 2015 03:13:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756864AbbGGKNK (ORCPT + 29 others); Tue, 7 Jul 2015 06:13:10 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:36462 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756815AbbGGKMU (ORCPT ); Tue, 7 Jul 2015 06:12:20 -0400 Received: by pddu5 with SMTP id u5so35870887pdd.3 for ; Tue, 07 Jul 2015 03:12:20 -0700 (PDT) X-Received: by 10.67.4.201 with SMTP id cg9mr7368372pad.53.1436263940014; Tue, 07 Jul 2015 03:12:20 -0700 (PDT) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id o7sm21361821pdi.16.2015.07.07.03.12.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jul 2015 03:12:18 -0700 (PDT) From: Chunyan Zhang To: rostedt@goodmis.org, mingo@redhat.com Cc: mathieu.poirier@linaro.org, serge.broslavsky@linaro.org, broonie@kernel.org, alexander.shishkin@linux.intel.com, zhang.lyra@gmail.com, linux-kernel@vger.kernel.org Subject: [RFC PATCH v3 4/4] trace: Trace log handler for logging into STM blocks Date: Tue, 7 Jul 2015 18:10:43 +0800 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zhang.chunyan@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add the function 'trace_event_stm_output_##call' for printing events trace log into STM blocks. This patch also adds a function call at where the events have been committed to ring buffer to export the trace event information to STM blocks. Signed-off-by: Chunyan Zhang --- include/linux/trace_events.h | 8 ++++++++ include/trace/perf.h | 3 +++ include/trace/trace_events.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index 28dcdff..705bd4e 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -418,6 +418,14 @@ enum event_trigger_type { #ifdef CONFIG_STM_TRACE_EVENT extern void stm_trace_event_write(const char *buf, unsigned len); +extern void trace_event_stm_log(struct trace_event_buffer *buffer); +extern void trace_event_buf_vprintf(struct trace_buffer_stm *tb, + const char *fmt, ...) __attribute__ ((weak)); +#else +static inline void trace_event_stm_log(struct trace_event_buffer *buffer) {} +static inline void trace_event_buf_vprintf(struct trace_buffer_stm *tb, + const char *fmt, ...) {} + #endif extern int filter_match_preds(struct event_filter *filter, void *rec); diff --git a/include/trace/perf.h b/include/trace/perf.h index 1b5443c..79906de 100644 --- a/include/trace/perf.h +++ b/include/trace/perf.h @@ -175,6 +175,7 @@ trace_event_raw_event_##call(void *__data, proto) \ { assign; } \ \ trace_event_buffer_commit(&fbuffer); \ + trace_event_stm_log(&fbuffer); \ } /* * The ftrace_test_probe is compiled out, it is only here as a build time check @@ -234,6 +235,7 @@ static struct trace_event_call __used event_##call = { \ .event.funcs = &trace_event_type_funcs_##template, \ .print_fmt = print_fmt_##template, \ .flags = TRACE_EVENT_FL_TRACEPOINT, \ + .output_stm = trace_event_stm_output_##template, \ }; \ static struct trace_event_call __used \ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call @@ -251,6 +253,7 @@ static struct trace_event_call __used event_##call = { \ .event.funcs = &trace_event_type_funcs_##call, \ .print_fmt = print_fmt_##call, \ .flags = TRACE_EVENT_FL_TRACEPOINT, \ + .output_stm = trace_event_stm_output_##call, \ }; \ static struct trace_event_call __used \ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h index 43be3b0..db4d8a7 100644 --- a/include/trace/trace_events.h +++ b/include/trace/trace_events.h @@ -303,6 +303,50 @@ TRACE_MAKE_SYSTEM_STR(); #undef DECLARE_EVENT_CLASS #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ +static notrace void \ +trace_event_stm_output_##call(struct trace_seq *tmp_seq, \ + void *entry, \ + struct trace_buffer_stm *trace_buf) \ +{ \ + struct trace_event_raw_##call *field = entry; \ + struct trace_seq *p = tmp_seq; \ + \ + trace_seq_init(p); \ + \ + trace_event_buf_vprintf(trace_buf, print); \ + \ + return; \ +} + +#undef DEFINE_EVENT_PRINT +#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ +static notrace void \ +trace_event_stm_output_##call(struct trace_seq *tmp_seq, \ + void *entry, \ + struct trace_buffer_stm *trace_buf) \ +{ \ + struct trace_seq *p = tmp_seq; \ + struct trace_entry *ent = entry; \ + struct trace_event_raw_##template *field; \ + \ + if (ent->type != event_##call.event.type) { \ + WARN_ON_ONCE(1); \ + return; \ + } \ + \ + field = (typeof(field))entry; \ + \ + trace_seq_init(p); \ + \ + trace_event_buf_vprintf(trace_buf, print); \ + \ + return; \ +} + +#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) + +#undef DECLARE_EVENT_CLASS +#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ static notrace enum print_line_t \ trace_raw_output_##call(struct trace_iterator *iter, int flags, \ struct trace_event *trace_event) \