From patchwork Tue Jun 16 07:06:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 49941 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6E4D4205DE for ; Tue, 16 Jun 2015 07:07:03 +0000 (UTC) Received: by wizw5 with SMTP id w5sf2631344wiz.2 for ; Tue, 16 Jun 2015 00:07:01 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=MW3/kfLheukZEMzCmZDoNEySX1IsOFxQCIEKYCkCh8A=; b=LdRCySrOsnp2yY0bOdcNQpXPjzh9pIyGRy0qnsHuQFSXgIV8R9w0i16yJWXJvdfaql X0jF2tSRmpOv2k3g5pKOmnKobPgbfYNcT8ZnAF+gqGFgbgEBpBd0mim/MwWkp/wLTPE0 4nhxooA5go6tnD0kf76Fdm+ger7f3vi5ypUOWfJJn+T0rc6nFf4GsLG2IoKBhzaUfAcE zw2bFTu/oy2XiHXltNBqSksubWrZR1C2FOJ7IZDl+dr6tUzVQzO15of1Px3j7VRQ5qHB 6ffrWlEAHej+yNPiOu+2wWOFtArlXtbmkP4B0nxp9eB1m7antUisd2F/9NhwYzOzBTGU 5p2A== X-Gm-Message-State: ALoCoQn4N41jrKc+dyLC50mxLRav/sCpjqu37H3p+91pUjTQ3WBB97pZoB4Mv6O01PJwMlfsQr4P X-Received: by 10.180.90.106 with SMTP id bv10mr1649090wib.6.1434438421794; Tue, 16 Jun 2015 00:07:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.166 with SMTP id z6ls36083laj.64.gmail; Tue, 16 Jun 2015 00:07:01 -0700 (PDT) X-Received: by 10.152.5.164 with SMTP id t4mr31130130lat.16.1434438421601; Tue, 16 Jun 2015 00:07:01 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id u7si102101lae.10.2015.06.16.00.07.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jun 2015 00:07:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbwc1 with SMTP id wc1so4713937lbb.2 for ; Tue, 16 Jun 2015 00:07:01 -0700 (PDT) X-Received: by 10.112.155.197 with SMTP id vy5mr4468033lbb.29.1434438421490; Tue, 16 Jun 2015 00:07:01 -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 hn6csp1912849lbb; Tue, 16 Jun 2015 00:07:00 -0700 (PDT) X-Received: by 10.70.45.16 with SMTP id i16mr56000782pdm.51.1434438419214; Tue, 16 Jun 2015 00:06:59 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si184357pbs.27.2015.06.16.00.06.58; Tue, 16 Jun 2015 00:06:59 -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 S1756234AbbFPHGy (ORCPT + 30 others); Tue, 16 Jun 2015 03:06:54 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:34840 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751535AbbFPHGv (ORCPT ); Tue, 16 Jun 2015 03:06:51 -0400 Received: by pacyx8 with SMTP id yx8so7052745pac.2 for ; Tue, 16 Jun 2015 00:06:51 -0700 (PDT) X-Received: by 10.70.130.198 with SMTP id og6mr55417318pdb.153.1434438410998; Tue, 16 Jun 2015 00:06:50 -0700 (PDT) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id xo3sm162094pbb.74.2015.06.16.00.06.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Jun 2015 00:06:49 -0700 (PDT) From: Chunyan Zhang To: rostedt@goodmis.org, mingo@redhat.com Cc: mathieu.poirier@linaro.org, serge.broslavsky@linaro.org, broonie@linaro.org, alexander.shishkin@linux.intel.com, zhang.lyra@gmail.com, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 2/3] Trace log handler for logging into STM blocks Date: Tue, 16 Jun 2015 15:06:12 +0800 Message-Id: <1434438373-32226-3-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434438373-32226-1-git-send-email-zhang.chunyan@linaro.org> References: <1434438373-32226-1-git-send-email-zhang.chunyan@linaro.org> 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.217.169 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: , Adding the function 'trace_event_stm_output_##call' for printing events trace log into STM blocks. This patch also added 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/ftrace_event.h | 15 ++++++++++++++ include/trace/ftrace.h | 47 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index 46e83c2..f0c7426 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h @@ -14,6 +14,7 @@ struct trace_buffer; struct tracer; struct dentry; struct bpf_prog; +struct trace_buffer_stm; struct trace_print_flags { unsigned long mask; @@ -304,6 +305,9 @@ struct ftrace_event_call { */ int flags; /* static flags of different events */ + void (*output_stm)(struct trace_seq *tmp_seq, void *entry, + struct trace_buffer_stm *tb); + #ifdef CONFIG_PERF_EVENTS int perf_refcount; struct hlist_head __percpu *perf_events; @@ -423,6 +427,17 @@ enum event_trigger_type { ETT_EVENT_ENABLE = (1 << 3), }; +#ifdef CONFIG_STM_TRACE_EVENT +extern void trace_event_stm_log(struct ftrace_event_buffer *fbuffer); +extern void trace_event_buf_vprintf(struct trace_buffer_stm *tb, + const char *fmt, ...) __attribute__ ((weak)); +extern void stm_trace_event_write(const char *buf, unsigned len); +#else +static inline void trace_event_stm_log(struct ftrace_event_buffer *fbuffer) {} +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); extern int filter_check_discard(struct ftrace_event_file *file, void *rec, diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index 37d4b10..20c7228 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.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 ftrace_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 ftrace_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 \ ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \ struct trace_event *trace_event) \ @@ -683,6 +727,7 @@ ftrace_raw_event_##call(void *__data, proto) \ { assign; } \ \ ftrace_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 @@ -742,6 +787,7 @@ static struct ftrace_event_call __used event_##call = { \ .event.funcs = &ftrace_event_type_funcs_##template, \ .print_fmt = print_fmt_##template, \ .flags = TRACE_EVENT_FL_TRACEPOINT, \ + .output_stm = trace_event_stm_output_##template, \ }; \ static struct ftrace_event_call __used \ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call @@ -759,6 +805,7 @@ static struct ftrace_event_call __used event_##call = { \ .event.funcs = &ftrace_event_type_funcs_##call, \ .print_fmt = print_fmt_##call, \ .flags = TRACE_EVENT_FL_TRACEPOINT, \ + .output_stm = trace_event_stm_output_##call, \ }; \ static struct ftrace_event_call __used \ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call