Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5130512imu; Tue, 8 Jan 2019 12:04:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN45hkAhmpfVYawvEujCta92KlJnCO03jhjh4adu65uonz7YAj2PbsPT0PhxElB4K40uprjR X-Received: by 2002:a17:902:2006:: with SMTP id n6mr3203681pla.66.1546977887883; Tue, 08 Jan 2019 12:04:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546977887; cv=none; d=google.com; s=arc-20160816; b=IwlzmP6VSa0yJuVcqU8QYHduXUpQ/5jJyNiNDYXq8QeaPIScootUPGqDOuX4ihxBlD pMQK8yDDxdJ3HcBMHQ3DDJAm+cYU7Y0j/NbgTk5KSqOKJH7xOl6auNEqRCY4DgDgaimS CMJxDICQ4gZla7fUJcH3cSZfNlRpqBaiNOnVhxrF2fjzehv5WbPo0DjSiQge5N7EujuW et39Gb2n9WZ5wIDMcZd3i8Zr3Q6RJSEnwzeAWxfJHkbgSF5eEJAsoiOP2LQ5im34SvOJ FlVtiLjcBmylKYhYRuFf+iiHJgc1/dVp2CUrIHP3ZBCJ8w1epkCsHnonxExAcbcwOKOn mUbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Eo1n/x24pB4Zomkeutgn9vziFhacODDjWzykBxy7bL4=; b=Icj5yENWKabrbmbxC34Wh1XfjyFbjMNcBKHTRyNrXV223MSj04hseyeSxXhiJdy2iA kcd/ahSxF/ZhKMskHirgHk1Qin7p2N+LvDS9czNopEaMZ6/jH4FzZJiJvB72e91R0fMr s/H1r1KCFKDix3w07P/LOPALRLcBte/6A74Qd7lLibMIWFzIUfPrLFkdW5TS84sv6vni G60alvt/Qst7EhwrDx1bzRoHbb8xGy6/Tu7glXBkYMjNGHoc0prsj8UtzSAaZoLC5Am3 7Gy3pu47qCf2rItnV7mhgAM1dxjeOlsxKjd64Supkjo091BG3zXscvP0AXQdg3zeihUV 5UEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j9tKqR5E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c21si14553932plo.165.2019.01.08.12.04.32; Tue, 08 Jan 2019 12:04:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j9tKqR5E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730324AbfAHT3K (ORCPT + 99 others); Tue, 8 Jan 2019 14:29:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:36350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730299AbfAHT3I (ORCPT ); Tue, 8 Jan 2019 14:29:08 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BFE64217D9; Tue, 8 Jan 2019 19:29:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546975747; bh=/eMAqon4sbmlcoffqcqn6Vd+qXRrh/+GdEtfmQfROh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j9tKqR5EBFr1xGE7iLKNH+LXKVszxYiP2ifk1ltczLsj3qDJCKIdJDkS1pbmkZzxd TsC7tBz31yoPeIZ4qEUedIXoHh2PnR2/hoIWiUnmCk9bRWKGHlxvMhBdAm7Hcf35Dw Oa4jS1ozQZnbDFQQLC0hJySwCmM5/o94c2Ts14zo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Leo Yan , Alexander Shishkin , Jiri Olsa , Mike Leach , Namhyung Kim , Robert Walker , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL 4.20 093/117] perf cs-etm: Correct packets swapping in cs_etm__flush() Date: Tue, 8 Jan 2019 14:26:01 -0500 Message-Id: <20190108192628.121270-93-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190108192628.121270-1-sashal@kernel.org> References: <20190108192628.121270-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan [ Upstream commit 43fd56669c28cd354e9228bdb58e4bca1c1a8b66 ] The structure cs_etm_queue uses 'prev_packet' to point to previous packet, this can be used to combine with new coming packet to generate samples. In function cs_etm__flush() it swaps packets only when the flag 'etm->synth_opts.last_branch' is true, this means that it will not swap packets if without option '--itrace=il' to generate last branch entries; thus for this case the 'prev_packet' doesn't point to the correct previous packet and the stale packet still will be used to generate sequential sample. Thus if dump trace with 'perf script' command we can see the incorrect flow with the stale packet's address info. This patch corrects packets swapping in cs_etm__flush(); except using the flag 'etm->synth_opts.last_branch' it also checks the another flag 'etm->sample_branches', if any flag is true then it swaps packets so can save correct content to 'prev_packet'. Finally this can fix the wrong program flow dumping issue. The patch has a minor refactoring to use 'etm->synth_opts.last_branch' instead of 'etmq->etm->synth_opts.last_branch' for condition checking, this is consistent with that is done in cs_etm__sample(). Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Mike Leach Cc: Namhyung Kim Cc: Robert Walker Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1544513908-16805-2-git-send-email-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/cs-etm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 73430b73570d..c2f0c92623f0 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1005,7 +1005,7 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) } swap_packet: - if (etmq->etm->synth_opts.last_branch) { + if (etm->sample_branches || etm->synth_opts.last_branch) { /* * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for * the next incoming packet. -- 2.19.1