From patchwork Fri Jan 22 15:18:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 12039651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA562C433DB for ; Fri, 22 Jan 2021 15:20:32 +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 7B3DA23A84 for ; Fri, 22 Jan 2021 15:20:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B3DA23A84 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.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=Id49jffuHDMptkkD4k9aYOVGs7LTVQyKCWVuU/l1o4g=; b=jskwheYnH2yVpS35fP6dwvfjg V2CMR95YylREG46uiWLn2Zw9r09fJB3daQtGWRtAAFHNCWw1OniNhHHJIxFV71C3K/dhSQvq92tz0 PjQjLwTjyCY0qdujXebTwc6469IVayBbbQwvYdyfqpldcBF3fdSmjD9ycx310lD1OZ8GWtE1bIQ1K lHJ3gzzaIwoXjh/n5ZZgTGaB8jiCArtpt3nr7M94Nw46txBkwdMHgB+mlcLpCLOzo8UWFMWegaupq TL9zChxJwB5X/qUyTnTD7eQts0yJm61vbsedCm2LN7nivrbuA3LztUoFlu8RsVGElz4MgrfQJ3CIh ocKgeJlrA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2yDC-0008AP-Un; Fri, 22 Jan 2021 15:18:59 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2yCx-00085A-RG for linux-arm-kernel@lists.infradead.org; Fri, 22 Jan 2021 15:18:45 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 34C87139F; Fri, 22 Jan 2021 07:18:43 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 48A6A3F66E; Fri, 22 Jan 2021 07:18:41 -0800 (PST) From: Suzuki K Poulose To: Peter Zijlstra Subject: [RFC PATCH] perf: Handle multiple formatted AUX records Date: Fri, 22 Jan 2021 15:18:29 +0000 Message-Id: <20210122151829.2890484-2-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20210122151829.2890484-1-suzuki.poulose@arm.com> References: <20210122151829.2890484-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210122_101844_283574_50AD2E41 X-CRM114-Status: GOOD ( 17.37 ) 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: mark.rutland@arm.com, al.grant@arm.com, mathieu.poirier@linaro.org, anshuman.khandual@arm.com, Alexander Shishkin , jolsa@redhat.com, coresight@lists.linaro.org, Suzuki K Poulose , linux-kernel@vger.kernel.org, acme@kernel.org, Ingo Molnar , will@kernel.org, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org CoreSight PMU supports aux-buffer for the ETM tracing. The trace generated by the ETM (associated with individual CPUs, like Intel PT) is captured by a separate IP (CoreSight TMC-ETR/ETF until now). The TMC-ETR applies formatting of the raw ETM trace data, as it can collect traces from multiple ETMs, with the TraceID to indicate the source of a given trace packet. Arm Trace Buffer Extension is new "sink" IP, attached to individual CPUs and thus do not provide additional formatting, like TMC-ETR. Additionally, a system could have both TRBE *and* TMC-ETR for the trace collection. e.g, TMC-ETR could be used as a single trace buffer to collect data from multiple ETMs to correlate the traces from different CPUs. It is possible to have a perf session where some events end up collecting the trace in TMC-ETR while the others in TRBE. Thus we need a way to identify the type of the trace for each AUX record. This patch adds a new flag to indicate the trace format for the given record. Also, includes the changes that demonstrates how this can be used in the CoreSight PMU to solve the problem. Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etm-perf.c | 2 ++ include/linux/coresight.h | 1 + include/uapi/linux/perf_event.h | 1 + 3 files changed, 4 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index e776a07b0852..81602bd8da59 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -429,6 +429,8 @@ static void etm_event_stop(struct perf_event *event, int mode) size = sink_ops(sink)->update_buffer(sink, handle, event_data->snk_config); + if (!sink->formatted_trace) + perf_aux_output_flag(handle, PERF_AUX_FLAG_ALT_FMT); perf_aux_output_end(handle, size); } diff --git a/include/linux/coresight.h b/include/linux/coresight.h index e019182521a1..45c173c391a4 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -241,6 +241,7 @@ struct coresight_device { int nr_links; bool has_conns_grp; bool ect_enabled; /* true only if associated ect device is enabled */ + bool formatted_trace; /* Trace is CoreSight formatted ? */ }; /* diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h index b15e3447cd9f..ea7dcc7b30f0 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h @@ -1109,6 +1109,7 @@ enum perf_callchain_context { #define PERF_AUX_FLAG_OVERWRITE 0x02 /* snapshot from overwrite mode */ #define PERF_AUX_FLAG_PARTIAL 0x04 /* record contains gaps */ #define PERF_AUX_FLAG_COLLISION 0x08 /* sample collided with another */ +#define PERF_AUX_FLAG_ALT_FMT 0x10 /* this record is in alternate trace format */ #define PERF_FLAG_FD_NO_GROUP (1UL << 0) #define PERF_FLAG_FD_OUTPUT (1UL << 1)