From patchwork Wed Aug 19 08:47:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11723283 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 282D213A4 for ; Wed, 19 Aug 2020 08:49:58 +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 01C81207DE for ; Wed, 19 Aug 2020 08:49:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oe2w02Qm"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OqfYIi+H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 01C81207DE 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: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=sFzbTYKLYPYpEhiC9TdP7l70u9JRqAfivXsY4wtF7DI=; b=oe2w02QmtD3OaBP+oh3i0X0R0s oWD/L/xVTuXtTuwV3MWE0nP0kr+3bW60xSBCBr3/6qg8CeY2I2Z/ULhAiaoWT1JVvvctVwaS9nssT BrmPJG582LrSfcjvMH/AsMWmMuad8YChZbaBUMUCF8hhpd6vn+ISz9toiagPa0/W2wM8/KdhGFHTK LxGKXwp8vYpz38MC3nA3kewQVPf5MJCeEDO+VqAsXiLmxKAgMjozatCsxYjqxM/feihaY/xSnECHc GFuzAUd2HczNAdgt40XQQUc14aLiYHO6pASTFdrRRD32XCar50sFYBYGBKeiFIHcXVISj2kvTxu+S /lgdvozA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8Jln-0005cd-Db; Wed, 19 Aug 2020 08:48:31 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8Jlk-0005bP-42 for linux-arm-kernel@lists.infradead.org; Wed, 19 Aug 2020 08:48:30 +0000 Received: by mail-pl1-x644.google.com with SMTP id s14so4518026plp.4 for ; Wed, 19 Aug 2020 01:48:27 -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=yFi8zTtrImZDILchnlZzIR1IxDR1uqiy2tgSbT1x9s8=; b=OqfYIi+HkhrNDJaXoxGNw9xfIPQWaGQbceAbY/S48XEG94k3Imgo6Hg4slYsNTHK9K 0LEXROlE6/nW7Nb6voPpSBVnaS1rIBBgsgz2QUNH2Mx/XCE2Ro7aG1lABGqAIxYKEL6b zsMxhkj/uz45O7VtOvSYZtAA+C4DdCu3QyOF4W+jWK86J5IJyVTVKBcrJ04Q/1M0pzGN mHsKp/LlUtNLllvRy55f3EMeXPCGLD/S1iH17joZJ8WE750GuyHkFICKI2GrHTlTKGNG B8jDLrhPhXTVqQ45EM1fw24MhpOrc/LicvB5y7Qp1sXQZaUaK/wG7//6nw1q0QQ/k7gf XVtA== 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:in-reply-to :references; bh=yFi8zTtrImZDILchnlZzIR1IxDR1uqiy2tgSbT1x9s8=; b=E7H2kL8DYdNbyEPsAuS1Yqq5gcVzi6sq2pYxsXbf3dwaD4p99Wdmh5IeTC/AGPgjAg eIZY6HuHZrMVj5R9IZ4J7CnnxlI0iJVyt9/d0pd6l8K6z87c6DDcF6hrYesjfE4j259u /lF7+SxpLyJHFwLjr2dw9rKCaqsNlgBkcLoIzgvoHb746staoNTpdUBWshPSxuWcGTG3 lhnEmd8tgf2H56CLvbtobAOACOUdOIX5nNiRGDXpcSVRa8IUSHTJFH8/1yyvuMsv1SkH xm4bT34RPPwThiAuY7U3JtBLv6g76PSP2BDrrzoSKaTEQIZLEaPo6hjnsMgqoQ3uiaJL Iumg== X-Gm-Message-State: AOAM531G5bFR4SXCYGTWb9IysA6kLFT1rYX53WfnnEeETgRxjJ1upSyK 8H2wwqk8St1LKo32gMEeTEz2oA== X-Google-Smtp-Source: ABdhPJwWbnU935IzaGsltr+HTXM80XTYPnZrgfrNRJD2kJjhKoPlGyc+WMVx87B7iNrVY/YI89PEbA== X-Received: by 2002:a17:90a:ee8d:: with SMTP id i13mr3368081pjz.19.1597826906130; Wed, 19 Aug 2020 01:48:26 -0700 (PDT) Received: from localhost ([2600:3c01::f03c:91ff:fe8a:bb03]) by smtp.gmail.com with ESMTPSA id z25sm28153492pfg.150.2020.08.19.01.48.25 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Aug 2020 01:48:25 -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 2/2] perf intel-pt: Fix corrupt data after perf inject from Date: Wed, 19 Aug 2020 16:47:51 +0800 Message-Id: <20200819084751.17686-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819084751.17686-1-leo.yan@linaro.org> References: <20200819084751.17686-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200819_044828_271937_8291BCB2 X-CRM114-Status: GOOD ( 18.73 ) 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:644 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 Intel PT 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 Signed-off-by: Leo Yan Acked-by: Adrian Hunter Reviewed-by: Mathieu Poirier --- tools/perf/util/intel-pt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index 2a8d245351e7..0af4e81c46e2 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -3017,8 +3017,15 @@ static int intel_pt_synth_events(struct intel_pt *pt, if (pt->synth_opts.callchain) attr.sample_type |= PERF_SAMPLE_CALLCHAIN; - if (pt->synth_opts.last_branch) + if (pt->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 (pt->synth_opts.instructions) { attr.config = PERF_COUNT_HW_INSTRUCTIONS;