Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1412205rdg; Sat, 14 Oct 2023 00:45:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH++D6w/O0rbIpU5i0PA3BGb/6zdojNvH1aKO38RmZZ1ReKf+Wqm24rTzovS+R+u2uEM4Es X-Received: by 2002:a05:6808:a97:b0:3a8:4dfd:4f02 with SMTP id q23-20020a0568080a9700b003a84dfd4f02mr28112528oij.11.1697269553466; Sat, 14 Oct 2023 00:45:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697269553; cv=none; d=google.com; s=arc-20160816; b=Mr8GDWUZ1gX0/38pvpkAoQHXHk9ar8Tf7jYq1wPk7q0JSANlqX5MV6mz5oKjj0em3Q 4jTO+0nVlQw7D8iK3fDm6Yna0yNhO7vttWEdO6rpjkGQTFxCeUeBcbUBUaWZ7XdKhoJY ExuClDwzUk+CPNnmON0YAiZ/cKqtwfAs3KCBHvI30E+pTlrS1GqVjsNsfsTdF5SceQgu RZOMff46Yse7q87QJJ+QSG9w5TEcALG60pkoQxSCaPHhBraskFyYPy69gq5KZ332GsBp /9sePDZGvbj18aSq1SmjAlSrRa7LtanMB8ZjBRU42Mw/fsBlGx8G+vrpus3QeYanHlyq V7rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=96NwI+szUWVaDtq9XwWAR7aU5/19oJgtQRo7AsJZv38=; fh=l4iAVwDO61LIwaniIgzRha+ULreFBpZU+fcJCDhl18U=; b=Ghg+EfFp933wr2pQFuops88seNvWfuZTCJR3M7ufXp7l3XBycIErYdFC4Yit/uSqoQ rJzn3Mi/MMglnmVb0la6sgW6wzeMa1vqA4RU9aWC3JlMSF5sCsH5Mgia0OfoFQwbO7Ce BbkhC4pS3gM6Wl2x+JDLnqWO2clbFh4f5UJJFnHI9jyH1xSSkqwf0OQdG0g/SZesvbJ9 FURzt1/7aHVjjb+/eJrm62gKf9Q7jMQv2dV2ebYnyPQS2uwRVtaU/1LpW3CtYdFFbCVy kfmzYFz1shzKRqQr0gVsYND5ahSTli6lbkcZQD3dnVvp4y/ddko9VN66kxlGkGr1xB+D ngOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZzRS508k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id 23-20020a631957000000b0056a1a149034si6321046pgz.650.2023.10.14.00.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 00:45:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZzRS508k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 8155D80295CB; Sat, 14 Oct 2023 00:45:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232999AbjJNHpj (ORCPT + 99 others); Sat, 14 Oct 2023 03:45:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232941AbjJNHpg (ORCPT ); Sat, 14 Oct 2023 03:45:36 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE2E3CA for ; Sat, 14 Oct 2023 00:45:34 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-694ed84c981so2311317b3a.3 for ; Sat, 14 Oct 2023 00:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697269534; x=1697874334; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=96NwI+szUWVaDtq9XwWAR7aU5/19oJgtQRo7AsJZv38=; b=ZzRS508kUmxaJDRrD/5gZIOzVl1Lcl+4eIkhYEqeQJUCTxSMimNhKfiMf+aOEGOy/t NlnUJBcCQk+ePgoVqQz++/soPpPdGuVReHj2BbDJfAtGWVKlh2TDbzLYeN3eQtZ7xd/k apwLE6UxG6wYL3zZF4DmeQEpu3Ejru2XraknN0PeNu1NXQodg0fGuicl1TPfFxfJyXOZ VOxJ8VAnjFFUCYsd7UH1jJU0zuGCAnnSL9KpuDlH754MsIq+L2abjn4VVxaD59DrJEtY yYMrHtLzlR7qYKA2JCJxIeFgWmxFf2u0zNP8HB4Zp32up6A46kesV9Vw0kXONApDQ5wr Cg5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697269534; x=1697874334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=96NwI+szUWVaDtq9XwWAR7aU5/19oJgtQRo7AsJZv38=; b=COxyDyLmoylz+aEEAQamNsZJdWFSLHHGvIX67ZjQKblvRspaVwVZM9kjCX+hQyuYcd xQ/63qcgJX8nKg/y2GhTVflDNl8AmfQG5mlwnfJKbk4xx291g+OYiMt3iwaqNQstfJKf r79lTi0X96yhMSb49TzpV3Eo7VYPoQDVW6E+ImiaIB58jy4t4CatO79su5JWnOmJwF78 rEpqjamRyuPX9UKmckvg0RleNTjM2qS45Bl19zqSA4G7OoZG3HfUvoVTIeiCNVn52rPv Kavgs/TwH1ALmEPtiNTSFJLJyQxdNtVavW9ANGUQ/SvwuRfISuhitJ4iG60s8RKoVuty e/Ew== X-Gm-Message-State: AOJu0Yz+c2l8d6zWl7glILnyy67u7D/M8ldZgOLo8itAX4o5I2C3Jl8X 3sCTpE47Va+2uOR38ec93shfgw== X-Received: by 2002:a17:902:ca14:b0:1c9:ca02:6451 with SMTP id w20-20020a170902ca1400b001c9ca026451mr7855265pld.39.1697269533953; Sat, 14 Oct 2023 00:45:33 -0700 (PDT) Received: from leoy-huanghe.lan ([98.98.49.106]) by smtp.gmail.com with ESMTPSA id r8-20020a170902be0800b001c3e732b8dbsm4965124pls.168.2023.10.14.00.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 00:45:33 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , James Clark , Suzuki K Poulose , Mike Leach Cc: John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Leo Yan Subject: [PATCH v1 2/2] perf cs-etm: Enable itrace option 'T' Date: Sat, 14 Oct 2023 15:45:13 +0800 Message-Id: <20231014074513.1668000-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231014074513.1668000-1-leo.yan@linaro.org> References: <20231014074513.1668000-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sat, 14 Oct 2023 00:45:50 -0700 (PDT) Prior to Armv8.4, the feature FEAT_TRF is not supported by Arm CPUs. Consequently, the sysfs node 'ts_source' will not be set as 1 by the CoreSight ETM driver. On the other hand, the perf tool relies on the 'ts_source' node to determine whether the kernel timestamp is traced. Since the 'ts_source' is not set for Arm CPUs prior to Armv8.4, platforms in this case cannot utilize the traced timestamp as the kernel time. This patch enables the 'T' itrace option, which forcibly utilizes the traced timestamp as the kernel time. If users are aware that their working platform's Arm CoreSight shares the same counter with the kernel time, they can specify 'T' option to decode the traced timestamp as the kernel time. An usage example is: # perf record -e cs_etm// -- test_program # perf script --itrace=i10ibT # perf report --itrace=i10ibT Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 9729d006550d..4a37fdeb1795 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -3322,12 +3322,27 @@ int cs_etm__process_auxtrace_info_full(union perf_event *event, etm->metadata = metadata; etm->auxtrace_type = auxtrace_info->type; - /* Use virtual timestamps if all ETMs report ts_source = 1 */ - etm->has_virtual_ts = cs_etm__has_virtual_ts(metadata, num_cpu); + if (etm->synth_opts.use_timestamp) + /* + * Prior to Armv8.4, Arm CPUs don't support FEAT_TRF feature, + * therefore the decoder cannot know if the timestamp trace is + * same with the kernel time. + * + * If a user has knowledge for the working platform and can + * specify itrace option 'T' to tell decoder to forcely use the + * traced timestamp as the kernel time. + */ + etm->has_virtual_ts = true; + else + /* Use virtual timestamps if all ETMs report ts_source = 1 */ + etm->has_virtual_ts = cs_etm__has_virtual_ts(metadata, num_cpu); if (!etm->has_virtual_ts) ui__warning("Virtual timestamps are not enabled, or not supported by the traced system.\n" - "The time field of the samples will not be set accurately.\n\n"); + "The time field of the samples will not be set accurately.\n" + "For Arm CPUs prior to Armv8.4 or without support FEAT_TRF,\n" + "you can specify the itrace option 'T' for timestamp decoding\n" + "if the Coresight timestamp on the platform is same with the kernel time.\n\n"); etm->auxtrace.process_event = cs_etm__process_event; etm->auxtrace.process_auxtrace_event = cs_etm__process_auxtrace_event; -- 2.34.1