From patchwork Sat Oct 14 07:45:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13421938 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3BECBCDB465 for ; Sat, 14 Oct 2023 07:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Yun9XphCkGb8EZhyi/D52gefTAPa/lnOB99HskzEXHg=; b=xNTFlsjFVq9Y17 /FBIpAZlZtDgGaTKmIKIFlPfAw5xtjHMVNwo0EcIHie/Zx7poIPofvf/zuVjh2cxZbss5oudttYoU nazN1Hu9BhJx8g53WNv/Ci+yiz4NQt1pjO2YBZVSf6JjHZjty4k6h8mEAPeY44+vFjCbxwIs35nkj qtR6nJieEJMfLf0x2ueOOFsADgbYE9XlGRc8pkayeOEfHQeX24i9UDCZb0fdUPY4kZ1ZYGZpwATwc +idpTimTIhqXpJJYJPl/beSOq27Dsn6Mg7oPn23F6fGzCV1khivQIPFll+GnDu2VPBssr3p7LVDqQ wEZ/43KLBXzjVv9cFuSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrZL4-004vcP-0P; Sat, 14 Oct 2023 07:45:34 +0000 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrZL0-004vbO-2O for linux-arm-kernel@lists.infradead.org; Sat, 14 Oct 2023 07:45:32 +0000 Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-79fce245bf6so111859239f.1 for ; Sat, 14 Oct 2023 00:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697269529; x=1697874329; darn=lists.infradead.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=pUGayCjdfCKVMoAdEORZ5NxIXkJ/ofSNrTgGs/xtftE=; b=S5T8pP0NrlquZ5xQx5Vmyjdy+Dut7p+6QAbAPvc0dqLEkPyY3iGTlN1/6jVjF8j5w1 3OJIrIgHLJd+2oK/Ht8WAeifrv79bPLdMezFGf6JfQ3AqbRvHXc+kBGbgirtLjV8jtNT +xorJ14cTbDneJ7aZXt9/VMDUoLGdyv67oQytwXlubJEg3zkjQbQF7zIindTauefmdpg 6fYH8V+mGDZEtoPQrMLR4HN1Mm/HIbIeSWxzWbbuPgwUMwfTWXPc9zJ4FexamPdKYHyg PvQdZc6pNbBCLkYjNlNffFECzY0o0472wSJcsEr51nw/WFbuzhxnaq0iuZOhjF+wUT2Y +chg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697269529; x=1697874329; 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=pUGayCjdfCKVMoAdEORZ5NxIXkJ/ofSNrTgGs/xtftE=; b=Ro+hnyYcp2Z3o51JliEpb3zmMsrLmFXzGazMr+FpFU7gDo6Kjjw0bqGm6SqbfUGJe/ vFi1YSAJZaneZ35c2SWnWEg449E/NZmXHYMe6lzsKO2TqPjVJtWuRgZgM4FXbRQKmAFV khaDOkrPhP+4ofv98s99yaxmSGddreC71dRbEcJsj2jvb9SoYDyFkGmzTqbry3sJwANP o+uOeKS4c2nMh4hrKf7ehv8xGD+YVmh7+9MH6bUazri7Z6fRxufHdR45Njk8g/8iKr4r SEI8+pdxYi4eTXwJYSWE+vyHlY+1BejzxJy7K5Yjt7JqPv8NLn2/jXQxAQp6TnhTfy/n fKHQ== X-Gm-Message-State: AOJu0Yy4Mjr/Kx404SKWEG/VFuXf99Liz/oRhidnWhlyGjgLtmjIdIvi wTSP4cEw5EgcK+VX0t+NFA+0Jg== X-Google-Smtp-Source: AGHT+IFu4IpYYh0fEp9h0zOOlOY34CAXroKMc6faHAM0eY/L+xaLENO/R/YjFnAwiYbWYfOexjgEcQ== X-Received: by 2002:a92:c269:0:b0:357:5234:802d with SMTP id h9-20020a92c269000000b003575234802dmr10535089ild.10.1697269529372; Sat, 14 Oct 2023 00:45:29 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 00:45:28 -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 1/2] perf auxtrace: Add 'T' itrace option for timestamp trace Date: Sat, 14 Oct 2023 15:45:12 +0800 Message-Id: <20231014074513.1668000-2-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231014_004530_780883_67F1A71E X-CRM114-Status: GOOD ( 16.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org An AUX trace can contain timestamp, but in some situations, the hardware trace module (e.g. Arm CoreSight) cannot decide the traced timestamp is the same source with CPU's time, thus the decoder can not use the timestamp trace for samples. This patch introduces 'T' itrace option. If users know the platforms they are working on have the same time counter with CPUs, users can use this new option to tell a decoder for using timestamp trace as kernel time. Signed-off-by: Leo Yan --- tools/perf/Documentation/itrace.txt | 1 + tools/perf/util/auxtrace.c | 3 +++ tools/perf/util/auxtrace.h | 3 +++ 3 files changed, 7 insertions(+) diff --git a/tools/perf/Documentation/itrace.txt b/tools/perf/Documentation/itrace.txt index a97f95825b14..19cc179be9a7 100644 --- a/tools/perf/Documentation/itrace.txt +++ b/tools/perf/Documentation/itrace.txt @@ -25,6 +25,7 @@ q quicker (less detailed) decoding A approximate IPC Z prefer to ignore timestamps (so-called "timeless" decoding) + T use the timestamp trace as kernel time The default is all events i.e. the same as --itrace=iybxwpe, except for perf script where it is --itrace=ce diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index a0368202a746..f528c4364d23 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1638,6 +1638,9 @@ int itrace_do_parse_synth_opts(struct itrace_synth_opts *synth_opts, case 'Z': synth_opts->timeless_decoding = true; break; + case 'T': + synth_opts->use_timestamp = true; + break; case ' ': case ',': break; diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 29eb82dff574..55702215a82d 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -99,6 +99,7 @@ enum itrace_period_type { * @remote_access: whether to synthesize remote access events * @mem: whether to synthesize memory events * @timeless_decoding: prefer "timeless" decoding i.e. ignore timestamps + * @use_timestamp: use the timestamp trace as kernel time * @vm_time_correlation: perform VM Time Correlation * @vm_tm_corr_dry_run: VM Time Correlation dry-run * @vm_tm_corr_args: VM Time Correlation implementation-specific arguments @@ -146,6 +147,7 @@ struct itrace_synth_opts { bool remote_access; bool mem; bool timeless_decoding; + bool use_timestamp; bool vm_time_correlation; bool vm_tm_corr_dry_run; char *vm_tm_corr_args; @@ -678,6 +680,7 @@ bool auxtrace__evsel_is_auxtrace(struct perf_session *session, " q: quicker (less detailed) decoding\n" \ " A: approximate IPC\n" \ " Z: prefer to ignore timestamps (so-called \"timeless\" decoding)\n" \ +" T: use the timestamp trace as kernel time\n" \ " PERIOD[ns|us|ms|i|t]: specify period to sample stream\n" \ " concatenate multiple options. Default is iybxwpe or cewp\n" From patchwork Sat Oct 14 07:45:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13421939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E83F4CDB465 for ; Sat, 14 Oct 2023 07:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gpA4OzWNJgSXqNwL4ndE4M7fnzZumr1r0QhrZ+a3rhE=; b=j3OlqHLfupMCcl Y5YLbUdVAfrN6JUcgQlg4R16Hm54fLrF/8kST6IkwnXGkTG8ZsUUZldRQKSU+nqLwHYNju+DEY1Xx priEXh+vomdKCWOwIUHeTR9i/Qr7A0ExIQiKIt+xoo7tl1NM4RfvPLvt1RSFBPy1fEruo9RnybRiS hk1LMWeRFvD4keYmJZQteQwFYSOH/jQVE8vpUwNIAO7lsPMovkx/WWkFWPyol9g62TqRYCMQ3IndA KSwbtZvV6KrR3rdQyW/Lv8im5X0dgnGxRv5Jc0F3xWAFJGRwEu4+/Gy8Tq4t+MODrQYdynJVf79my c153to1yZ1Zkqqp30ZHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrZLE-004vf5-0M; Sat, 14 Oct 2023 07:45:44 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrZLB-004vcf-0e for linux-arm-kernel@lists.infradead.org; Sat, 14 Oct 2023 07:45:42 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5aed4f0e90bso576444a12.1 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=lists.infradead.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=WKFcjBfxBCgGmG4Dh1e6F/cDFgPeLuDEFJ2DslIVlnCMuKX/xpZKy+QGKTlcB+pf8T tGVz0PUHA7kVsGHw19tDAgdrUOzqncGu79FI50SLtvlt6Qkn+yWyVS/UTjWOU0YUyDcX 8Hbr++HEqJREx4q2KAEelPeZRnyti4bcLAavztvRyGeb7/PDsgTYBUSMl/l9MuW4Y7oS z53kAnInsZlvns05DmU8CDXwfoGLSz2nfW0HMXLKNgcJ+IMy7io/jdBWc1uea6S3LjHX YfGu94P+A7e3ff7L+mlu2qrf8wff9oLuG2vEyWz1ipRbWuRygpurbc3l5HgejWoRkAZu IJBg== 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=clMVLF7thEad7m8ZmeOAo7sRyeMTpxf3ncFNsK6DHsoUhfyQbc5NjHJTbuHCen3r6C v/x2heWUdUFmElx39DE1njNGrel3jAdmcNhKF+1N6/ylVTMU3oOEhzh+DDG6Wyipwk37 gxMmSq5RcACgitHja/zbXjfj1+qmNacZV778xXut0PBW17GvaJxlhIwiwK7cw7WVk3gB Jud7Zd7pexPYfcSYwuQRAMp8n5EjH+iFziTIyjNbaBQ6N/oP5dOMyU8K9PB1PzqJnQC5 zJiHIRCJBmQsH6tb7IHMfQ+3WcticoDVBsm/7VbyJQwGb8sUzo7uJLaTts/SON+hBSif TXSw== X-Gm-Message-State: AOJu0YxLU7QMALyq/hIwzRTrRjVn5xK3dqjoOE+stxRPl7nu3UsxkG4V M5QPP/ots9vlhw8wLYmVs6VkJA== X-Google-Smtp-Source: AGHT+IFSuZzpRXBPpMB17Gk7j0z/3Vjzu2h3MJXxx77CEHZ/SOKVJBuTBUwkprQY5woSpJTwPmvLxQ== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231014_004541_240764_D7CB87F3 X-CRM114-Status: GOOD ( 19.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: James Clark --- 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;