From patchwork Fri Jun 5 05:37:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 49554 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9BE9E2154F for ; Fri, 5 Jun 2015 05:38:11 +0000 (UTC) Received: by labc7 with SMTP id c7sf16583118lab.1 for ; Thu, 04 Jun 2015 22:38:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:date:message-id :subject:from:to:cc:content-type:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=fRLTfU9Y4WsEgAw6swGAXuQNfK8USl+r4lBxVwsODls=; b=cPohALRVxxzkzJk5K3TLQpaAUjZxiy1RasLxg4LInEVZq9t3RmplADcCDXdULNI8p3 Km/Ovx+mmtbRW4MwfLDhQQx6UcLGzlPOpO9sIEkPM7QCpmOUUwhj4FuGxgeiJwFvNz7Q B9R22G9WQ7Fwh0fLuCAztmrToTwu6JHMdgr4OABeSr3YJBw96bmuKznubGQHarh6Wz7j 8PemY/p5uwfDoE2bSkH9M+ig/ZCQiNgW0kTd3YDYQ4zU6rHdvy7gfGNGKSULPhWJuN9T 4UeNX50uQMbU9Q4AkJ0UhMflJpocyCi2IoWT17GxzMRV+XzSEZ1j4JeOLPzSOno7veE3 2/WQ== X-Gm-Message-State: ALoCoQkHevzMH2LQDyEY5Bo51zcTbVh0IuteEFfVsTiOOO8D9JEnmuKUdnnfL1hVPGKovZhbFAnp X-Received: by 10.180.198.172 with SMTP id jd12mr24393762wic.5.1433482690069; Thu, 04 Jun 2015 22:38:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.105 with SMTP id lb9ls317686lab.10.gmail; Thu, 04 Jun 2015 22:38:09 -0700 (PDT) X-Received: by 10.112.24.233 with SMTP id x9mr1635681lbf.7.1433482689866; Thu, 04 Jun 2015 22:38:09 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id cj8si3877452lad.8.2015.06.04.22.38.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jun 2015 22:38:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by labko7 with SMTP id ko7so46736072lab.2 for ; Thu, 04 Jun 2015 22:38:09 -0700 (PDT) X-Received: by 10.152.7.7 with SMTP id f7mr1630682laa.106.1433482689425; Thu, 04 Jun 2015 22:38:09 -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 hn6csp1138683lbb; Thu, 4 Jun 2015 22:38:08 -0700 (PDT) X-Received: by 10.66.66.197 with SMTP id h5mr3123276pat.29.1433482687448; Thu, 04 Jun 2015 22:38:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2si9252110pda.257.2015.06.04.22.38.06; Thu, 04 Jun 2015 22:38:07 -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 S932281AbbFEFiC (ORCPT + 28 others); Fri, 5 Jun 2015 01:38:02 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:33357 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750957AbbFEFiA (ORCPT ); Fri, 5 Jun 2015 01:38:00 -0400 Received: by wiwd19 with SMTP id d19so9461675wiw.0 for ; Thu, 04 Jun 2015 22:37:59 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.194.235.4 with SMTP id ui4mr3194332wjc.0.1433482679250; Thu, 04 Jun 2015 22:37:59 -0700 (PDT) Received: by 10.194.14.194 with HTTP; Thu, 4 Jun 2015 22:37:59 -0700 (PDT) Date: Fri, 5 Jun 2015 13:37:59 +0800 Message-ID: Subject: [RFC PATCH 2/3] Trace log handler for logging into STM blocks From: Chunyan Zhang To: Steven Rostedt , mingo@redhat.com Cc: Mathieu Poirier , Kaixu Xia , Serge Broslavsky , Mark Brown , alexander.shishkin@linux.intel.com, "linux-kernel@vger.kernel.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.215.46 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(+) * 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 -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ 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..cc1b426 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h @@ -302,6 +302,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, \ @@ -683,6 +727,7 @@ ftrace_raw_event_##call(void *__data, proto) \ { assign; } \ \ ftrace_event_buffer_commit(&fbuffer); \ + trace_event_stm_log(&fbuffer); \ } /*