From patchwork Thu Sep 3 00:17:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tingwei Zhang X-Patchwork-Id: 11752119 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45830138A for ; Thu, 3 Sep 2020 00:18:43 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08CA620758 for ; Thu, 3 Sep 2020 00:18:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="C9GcIsCp"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="rb9dpDcH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08CA620758 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UpI/IQFuGZBcpxaarzjyNPVa2xEM2CJUC3oXr2ywKBs=; b=C9GcIsCp9YTbuFXu2bhXjNA9j 7UqELuy1LOYFSGX0WX6vUMuv5WvhXXaVNumreBpVGhGSolatfFgdlpbj/yj9uVP8kbdv56Sw5Plbg LdNReMwGpQM8yhZRzrskR2YOHw5zdFwrx76D5lw8U5IUiLarpO2CEz1eMf0OivW72iDvi/C7UILK0 PLuXkPlHMrlnnhnSN591i90OPyfYYOJS8LNah06VWHRTcldu3mNQjZ/pqP5arGjf2buuZHDqQxfTm /tDM3+oDcgaa8/QEbzULiNUeLlH2+4LeJDsMdvTKDmqG2p2SK/gKwW8w63XytxDOWt2IJe05FTqXk tvBA7MoNw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDcxV-0000Qc-QS; Thu, 03 Sep 2020 00:18:33 +0000 Received: from m43-7.mailgun.net ([69.72.43.7]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDcxQ-0008Sk-6D for linux-arm-kernel@lists.infradead.org; Thu, 03 Sep 2020 00:18:31 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1599092310; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=J+GkYlJeue+xhm0JgHaodonblQjXsPYjEk8/Vc2LCdw=; b=rb9dpDcHIqkgPlRs7kRtLKSxRf8l6qzd8fr1h4fdkAw+dVHjGJ1/kqHsJiMYMQUYnrqcgx4o lzO3ztvTuyJ7+iTVNijR7KV6Dm6nwhr2P4oahsMGDlecIFUGI0CzBQc1TruEgPCiBCvA1xnR L9Vs2v7c8tka68A6imaLCMQnC9E= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyJiYzAxZiIsICJsaW51eC1hcm0ta2VybmVsQGxpc3RzLmluZnJhZGVhZC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n02.prod.us-east-1.postgun.com with SMTP id 5f50362b73afa3417ecc01fd (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 03 Sep 2020 00:17:47 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id D1690C43395; Thu, 3 Sep 2020 00:17:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from tingweiz-gv.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tingwei) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2A74CC433C9; Thu, 3 Sep 2020 00:17:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2A74CC433C9 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=tingwei@codeaurora.org From: Tingwei Zhang To: Steven Rostedt , Ingo Molnar , Alexander Shishkin , Maxime Coquelin , Alexandre Torgue Subject: [PATCH v3 4/6] tracing: add trace_export support for trace_marker Date: Thu, 3 Sep 2020 08:17:04 +0800 Message-Id: <20200903001706.28147-5-tingwei@codeaurora.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20200903001706.28147-1-tingwei@codeaurora.org> References: <20200903001706.28147-1-tingwei@codeaurora.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200902_201830_355121_D5682341 X-CRM114-Status: GOOD ( 16.12 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [69.72.43.7 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [69.72.43.7 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tsoni@codeaurora.org, Sai Prakash Ranjan , Mathieu Poirier , Suzuki K Poulose , Mao Jinlong , linux-kernel@vger.kernel.org, Tingwei Zhang , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add the support to route trace_marker buffer to other destination via trace_export. Signed-off-by: Tingwei Zhang Reviewed-by: Steven Rostedt (VMware) --- include/linux/trace.h | 1 + kernel/trace/trace.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/linux/trace.h b/include/linux/trace.h index 5a01eeffb254..80b7df68bc0f 100644 --- a/include/linux/trace.h +++ b/include/linux/trace.h @@ -6,6 +6,7 @@ #define TRACE_EXPORT_FUNCTION BIT(0) #define TRACE_EXPORT_EVENT BIT(1) +#define TRACE_EXPORT_MARKER BIT(2) /* * The trace export - an export of Ftrace output. The trace_export diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 2f9302a8b322..67993abda394 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -271,6 +271,7 @@ static struct trace_export __rcu *ftrace_exports_list __read_mostly; static DEFINE_STATIC_KEY_FALSE(trace_function_exports_enabled); static DEFINE_STATIC_KEY_FALSE(trace_event_exports_enabled); +static DEFINE_STATIC_KEY_FALSE(trace_marker_exports_enabled); static inline void ftrace_exports_enable(struct trace_export *export) { @@ -279,6 +280,9 @@ static inline void ftrace_exports_enable(struct trace_export *export) if (export->flags & TRACE_EXPORT_EVENT) static_branch_inc(&trace_event_exports_enabled); + + if (export->flags & TRACE_EXPORT_MARKER) + static_branch_inc(&trace_marker_exports_enabled); } static inline void ftrace_exports_disable(struct trace_export *export) @@ -288,6 +292,9 @@ static inline void ftrace_exports_disable(struct trace_export *export) if (export->flags & TRACE_EXPORT_EVENT) static_branch_dec(&trace_event_exports_enabled); + + if (export->flags & TRACE_EXPORT_MARKER) + static_branch_dec(&trace_marker_exports_enabled); } static void ftrace_exports(struct ring_buffer_event *event, int flag) @@ -6648,6 +6655,8 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, } else entry->buf[cnt] = '\0'; + if (static_branch_unlikely(&trace_marker_exports_enabled)) + ftrace_exports(event, TRACE_EXPORT_MARKER); __buffer_unlock_commit(buffer, event); if (tt)