Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp1380518imk; Mon, 4 Jul 2022 01:44:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uBxh6wMHCxz9NANX7GW6BNDzziyd0qrnohGWexVKWV4UWpsQ7Bd3vlwYYrbqq09CBdBF0O X-Received: by 2002:a17:907:1741:b0:726:b8e8:7dc1 with SMTP id lf1-20020a170907174100b00726b8e87dc1mr28635714ejc.0.1656924293903; Mon, 04 Jul 2022 01:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656924293; cv=none; d=google.com; s=arc-20160816; b=OTxXRAmXDYW+Qv+2mNYc9vvYoi/DTo4RDk5GRCtLP+KzBCN7TIda8G8mdgPjIamQRA URaehilkjOIRIdnFQ7kQxgDzuLmGw/hkSnv2NCIB06B+1ztFVDK39Z/JSyaEM8vJnjBG m8iifVruLT91wYCL+ORUfPkxA1fuBCYgc7nNGbVyAvHZzZJ36e5ASKQBGjl6N3mxH4rC +VZd05IMSgqmSyZAK7GjHtMnAguXDZx6FwB0BztVmrfa8C9lWLwxW4H+aG7lR3nmyYjB rchfsm2blahMA3UNbjAISsM2ct5go4EvdLneY1VTg8hhYtQ0cPCzHjBc0jZSXLkUmHPl S5Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=jVURNUygCeW21dF6Em3WQRHaxEsapZQYIGA6mQ8Wh5Q=; b=nhik+mQhm7sFx/t1cXjR81qOkjqftu24Tp9rMqEGUGb16mqFNYQKSvT2+Qk3TWNTlU whM/tlBZE3KaGM5vrJxUH9KHF8+3IUnUlpybYQtxJ59om+UyL4lqg5VlDunVYpGlrJDt q+reAIWuoSa0GofDrxeD1fzrn5EVxSjunJ4/JRsXkS+t1oFWXJTtlq4tQkD+8mc7Uce1 8BlW8pFtQQjjrBQSb0Iw1oxKnLwF4OsoaMSTHTN2F/x/gHAO49m9/6fpRCcKf0hFY2kB OD20uWXMzorUIofCg5Iq/0yJwosZ+Q3xZ4Bi/bgmrPIxghIGKDRO6tMZ7qVQyjyXQqHn gjsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xtC6GuwC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr11-20020a170906d54b00b0072a9a683407si9414084ejc.118.2022.07.04.01.44.28; Mon, 04 Jul 2022 01:44:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xtC6GuwC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233664AbiGDIMj (ORCPT + 99 others); Mon, 4 Jul 2022 04:12:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232950AbiGDIML (ORCPT ); Mon, 4 Jul 2022 04:12:11 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA651B48D for ; Mon, 4 Jul 2022 01:12:04 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id be14-20020a05600c1e8e00b003a04a458c54so5136451wmb.3 for ; Mon, 04 Jul 2022 01:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jVURNUygCeW21dF6Em3WQRHaxEsapZQYIGA6mQ8Wh5Q=; b=xtC6GuwCyAlyb/Zr988UgFE2vSgoZVJSqHHdAbdoCn2zXTTQ95bcxpfeRtuATBDlcR ugx4TMAyenDTPaFmGks19eHk2LlsMtEcga5TUTWYvyhDU2Dvo9P5JtDTEt34gXFV9o0d aQctUj7kAgLvyXixRFaCHlTUAQVingSCGnKW/5fNUHOGJQUWvGIz0AVwODty3IPI8JkG wEX8ibacACiG1/J5ABwyFx4tDjFtnrNVkSDJ4sSwUyGGEKiGsS/RnSHEJnXPmblXHWWO 3TbhXgvCiKMkwKNBTPRzkZt2hi503wi+9uD0dAWkczQ74VGxLRLAUkn/KD6QLW5AJ4iO cYzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jVURNUygCeW21dF6Em3WQRHaxEsapZQYIGA6mQ8Wh5Q=; b=w2xSrcFFYjcdrVHM5ChEmrDjUea9Qt8flOizxi4rZ89+Y4f0eRmuEK6DrTa1XgxjEn A1NohBlreCWwaBUSEjA2A71EBsxczhugXwqJGSylb7TRWWLb0Gy2ivD7cLlra9Nenim2 9ty9EfM2l0/byKz1lbxodVzhOJy2CoGJmyBAv14EDxOEbC9012gFBhGJDx1H8pBcaRQX 0T6IzFas/ZCZ2kpiGX3PSUlb8HjCCiOLF7Le66pDpJa9sbbXhICfTglgRwaRyXcrr2E8 91L0llTHPF86YdQIkjw+C8fDSfa9WX5NUAjp8DeaL/y/fKRFmKY9PVTLMZwNEKa6Z3fO 5zow== X-Gm-Message-State: AJIora8lh4LtKjmmS7Fis/E55H23f9YOW1cmdJIkkRPQCDxH7hCVXt+2 k10boMp9frQbuML6PWmFLd8Nf6isCYp95A== X-Received: by 2002:a05:600c:4e49:b0:3a0:4c17:c67f with SMTP id e9-20020a05600c4e4900b003a04c17c67fmr32310009wmq.1.1656922323276; Mon, 04 Jul 2022 01:12:03 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6809:2201:c4c4:4ed1:ae43:27f2]) by smtp.gmail.com with ESMTPSA id u3-20020adfdd43000000b0021d650e4df4sm4388276wrm.87.2022.07.04.01.12.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 01:12:02 -0700 (PDT) From: Mike Leach To: suzuki.poulose@arm.com, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: mathieu.poirier@linaro.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-perf-users@vger.kernel.org, leo.yan@linaro.org, quic_jinlmao@quicinc.com, Mike Leach Subject: [PATCH v2 12/13] coresight: events: PERF_RECORD_AUX_OUTPUT_HW_ID used for Trace ID Date: Mon, 4 Jul 2022 09:11:48 +0100 Message-Id: <20220704081149.16797-13-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220704081149.16797-1-mike.leach@linaro.org> References: <20220704081149.16797-1-mike.leach@linaro.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the perf_report_aux_output_id() call to output the CoreSight trace ID and associated CPU as a PERF_RECORD_AUX_OUTPUT_HW_ID record in the perf.data file. Signed-off-by: Mike Leach --- drivers/hwtracing/coresight/coresight-etm-perf.c | 10 ++++++++++ include/linux/coresight-pmu.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index ad3fdc07c60b..531f5d42272b 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -4,6 +4,7 @@ * Author: Mathieu Poirier */ +#include #include #include #include @@ -437,6 +438,7 @@ static void etm_event_start(struct perf_event *event, int flags) struct perf_output_handle *handle = &ctxt->handle; struct coresight_device *sink, *csdev = per_cpu(csdev_src, cpu); struct list_head *path; + u64 hw_id; if (!csdev) goto fail; @@ -482,6 +484,11 @@ static void etm_event_start(struct perf_event *event, int flags) if (source_ops(csdev)->enable(csdev, event, CS_MODE_PERF)) goto fail_disable_path; + /* output cpu / trace ID in perf record */ + hw_id = FIELD_PREP(CS_AUX_HW_ID_VERSION_MASK, CS_AUX_HW_ID_CURR_VERSION) | + FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, coresight_trace_id_get_cpu_id(cpu)); + perf_report_aux_output_id(event, hw_id); + out: /* Tell the perf core the event is alive */ event->hw.state = 0; @@ -600,6 +607,9 @@ static void etm_event_stop(struct perf_event *event, int mode) /* Disabling the path make its elements available to other sessions */ coresight_disable_path(path); + + /* release the trace ID we read on event start */ + coresight_trace_id_put_cpu_id(cpu); } static int etm_event_add(struct perf_event *event, int mode) diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h index 9f7ee380266b..5572d0e10822 100644 --- a/include/linux/coresight-pmu.h +++ b/include/linux/coresight-pmu.h @@ -7,6 +7,8 @@ #ifndef _LINUX_CORESIGHT_PMU_H #define _LINUX_CORESIGHT_PMU_H +#include + #define CORESIGHT_ETM_PMU_NAME "cs_etm" /* @@ -38,4 +40,16 @@ #define ETM4_CFG_BIT_RETSTK 12 #define ETM4_CFG_BIT_VMID_OPT 15 +/* + * Interpretation of the PERF_RECORD_AUX_OUTPUT_HW_ID payload. + * Used to associate a CPU with the CoreSight Trace ID. + * [63:16] - unused SBZ + * [15:08] - Trace ID + * [07:00] - Version + */ +#define CS_AUX_HW_ID_VERSION_MASK GENMASK_ULL(7, 0) +#define CS_AUX_HW_ID_TRACE_ID_MASK GENMASK_ULL(15, 8) + +#define CS_AUX_HW_ID_CURR_VERSION 0 + #endif -- 2.17.1