From patchwork Wed Aug 19 08:47:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11723281 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 2940D618 for ; Wed, 19 Aug 2020 08:49:55 +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 01E4F207BB for ; Wed, 19 Aug 2020 08:49:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="2w+yMVa8"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gTNIAuMQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 01E4F207BB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.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:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id: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:In-Reply-To:References:List-Owner; bh=NBElUIKY9uin7dqWbjPwScTECX4FuXCx0JhQ10o7Kcg=; b=2w+yMVa8LPORuxXQasuBPS+8xr NqNtQYaV9JkcTiqWw3Cnak8dZ1JCIlpZSPwHphnIFvx9h+be1tVW39RqEBy4QoAfjNdhqkgXbQIik Y/h27e7SIc6S6W9UoNntNT8oZXr/J85/tvyd5kgCwKNeR9gOAp+ZvcdMln+ky8wf2bhgmdUYPSoD6 NaeGzASStOZ+LZYq+uoRy+D9LiS6ffkyWvdxUlBXlfEizcS3OLpZNtJWlrIkC3KvtZReJkMApY0YV RT5aB2O8JLkNHof5KZbIULH5eywUngBvQXxgqpa2WWpnhi6Ygfy0TK1EDGA4+xJ+9LjIPY/+aG8W4 oXjJOPlw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8Jlh-0005b8-UJ; Wed, 19 Aug 2020 08:48:25 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8Jlf-0005a5-3U for linux-arm-kernel@lists.infradead.org; Wed, 19 Aug 2020 08:48:24 +0000 Received: by mail-pj1-x1042.google.com with SMTP id ha11so795587pjb.1 for ; Wed, 19 Aug 2020 01:48:22 -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; bh=Rx3HhZp0uE5X/bW9a/q8+qzsFbhTQfzF+43SkTUPg9s=; b=gTNIAuMQTY8Lvc5UP14BLPihF+M1nvXwR88UCt5QqSEiOCRMamMULGYW1Anh3T5tZn NWtqatFdWocT9No/CYkQfwfxN5pJn61WCIOkEecstyEQL76boB4LfF0qTtdS+/7HNzXO v8U8Iml3Xf5cTkD+H/Mjyv8vpINPaDwPqTvkGo0V3vbvufBaw6BD9vaDMRKXrrmnbscy LTstqgkbETC435s5Noy3jko49qHxDwUoVFNPOER/g0aIQBx236rx4XfNnAeLA2tpENLq kqVmWe+4YXsypN+LAqInM3uRG2e/e0WY2SJf1tN7tAAlfXzn0h0yUCIZQvmNyer5wfIj hptw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Rx3HhZp0uE5X/bW9a/q8+qzsFbhTQfzF+43SkTUPg9s=; b=Ao/tSYS5pnCxmfTJsjSJcHJCWV1kCtdAQAPWbUql7U9KYaxbBTwG5sgYb92rs3Nek5 BqFaMYHUkB/93Vf6Io9aOJrFR9AqHWosUE030DIVgeOAWmRiXK0iTNK3MQ2h6UE5PwoV t1LXjycnoOmC5b+O1o4CIp+ezy5TEAvzqYED6G8hYkrb+PwrfmcTL3HhVIHf6qO2SQWU Y+z9TyYcTKaePtvfmjBmg5msCpaiQSILchkImpLNwjQQzBo3eMFyYnD1OU1mlVYbBpqw K22GOT8nl9k4XRLouYqaG9HPKeaQzBTFRr+F6T4Jy35D2c+52DoIPeOY+PXpzjLE49e8 eQYA== X-Gm-Message-State: AOAM531l5fbhU9ARp/BtPezjik3/kWHSF618xotN0nPSXKHWiyf9D+Fl 9rksACp7MvDeXhHDEW9uFXiKDA== X-Google-Smtp-Source: ABdhPJymN378icNoISpPWEPx+twM+ttOqTAsgUY2Y3A9jKX584elnuebuLI7utTqJnZVJTNhFPaoQA== X-Received: by 2002:a17:902:9349:: with SMTP id g9mr18292755plp.313.1597826901058; Wed, 19 Aug 2020 01:48:21 -0700 (PDT) Received: from localhost ([2600:3c01::f03c:91ff:fe8a:bb03]) by smtp.gmail.com with ESMTPSA id l24sm24795414pff.20.2020.08.19.01.48.20 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Aug 2020 01:48:20 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Andi Kleen , Kan Liang , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] perf cs-etm: Fix corrupt data after perf inject from Date: Wed, 19 Aug 2020 16:47:50 +0800 Message-Id: <20200819084751.17686-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200819_044823_452954_5F2F2414 X-CRM114-Status: GOOD ( 17.18 ) X-Spam-Score: 3.4 (+++) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (3.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [2600:3c01:0:0:f03c:91ff:fe8a:bb03 listed in] [zen.spamhaus.org] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1042 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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: Al Grant , Leo Yan MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Al Grant Commit 42bbabed09ce ("perf tools: Add hw_idx in struct branch_stack") changed the format of branch stacks in perf samples. When samples use this new format, a flag must be set in the corresponding event. Synthesized branch stacks generated from CoreSight ETM trace were using the new format, but not setting the event attribute, leading to consumers seeing corrupt data. This patch fixes the issue by setting the event attribute to indicate use of the new format. Fixes: 42bbabed09ce ("perf tools: Add hw_idx in struct branch_stack") Signed-off-by: Al Grant Reviewed-by: Andrea Brunato Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index c283223fb31f..a2a369e2fbb6 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1344,8 +1344,15 @@ static int cs_etm__synth_events(struct cs_etm_auxtrace *etm, attr.sample_type &= ~(u64)PERF_SAMPLE_ADDR; } - if (etm->synth_opts.last_branch) + if (etm->synth_opts.last_branch) { attr.sample_type |= PERF_SAMPLE_BRANCH_STACK; + /* + * We don't use the hardware index, but the sample generation + * code uses the new format branch_stack with this field, + * so the event attributes must indicate that it's present. + */ + attr.branch_sample_type |= PERF_SAMPLE_BRANCH_HW_INDEX; + } if (etm->synth_opts.instructions) { attr.config = PERF_COUNT_HW_INSTRUCTIONS;