Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp47684imu; Thu, 20 Dec 2018 16:39:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN6BB9Ib9eaW71RT6BP9EtY/yV4DIulfr6czW5cp89IpQaWUk+4ponrRdnLOs42XcMCy8fC9 X-Received: by 2002:a17:902:43e4:: with SMTP id j91mr351540pld.147.1545352751093; Thu, 20 Dec 2018 16:39:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545352751; cv=none; d=google.com; s=arc-20160816; b=iOz1cq8dFcW4T7BehOkHzgR12z3wcam5t0kDys1tQj37mPp9JbYSSS5Usf1NOLL5Pl X1UYlsTP+mDLr9dKglomrVubs2R3pfmCkaAlQJhm7tr3h6NPSV0Ic3hBf9kNueCOymQW fiZuGorm38gel1zz7mu8eYUUv8X43ooEeyCV26XSyLscTB+ufTpxqKzTH/ZBc2ShpNCB tARHH7Jl3Oohw2m8/y7xuBqREVMx1BC+fqjYDl0zkzLRfDpYpUD1iCfnOPxoHcVvk9Rk KajJyoJLUEvU8pCJWHXEszXEyvwZvfBfF/lHFHFrMwjjUSRDhJP4KIamjD2FOP3bQoQa 7Oig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=Cpfo2DookXPpr+WotPIHhbGYyjrVbqclTSyNmy7VLhU=; b=C3tsBQiNQmxuT7TPlTYR+yPi2+iPyIzM8ss/mwvjRaQR6H0Ek1HniDDhVrnRiZeBRJ GwdJ/jBmroTxuN6zmOx+IoOzSC8yb+FJ6U2ZHnoL+t4ErI5QdSCjSCGCT4mxOJ4uhjVc IfH+c4MPPGWSH3+p9mwctn6i7TAwfXMAarFSfs8zEWlNtvthA97Qc2GxgHWKt5LzV3u0 AZrVQoq3D3fRfEy2tc3DmIku/uQvjF9Eloosez2UbFZi1vGEdaWG6EW7+N3DUP380RSF u1pCxWHw9Srf1zyY/0Z4qPf8GjttgKKeujCVHqcrdr/yJA+w2l/MRwqk5wUOJc+7XL3o YXrA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j195si21527064pfd.165.2018.12.20.16.38.55; Thu, 20 Dec 2018 16:39:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729481AbeLTSNc (ORCPT + 99 others); Thu, 20 Dec 2018 13:13:32 -0500 Received: from terminus.zytor.com ([198.137.202.136]:51615 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727993AbeLTSNb (ORCPT ); Thu, 20 Dec 2018 13:13:31 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id wBKICKvT3682308 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 20 Dec 2018 10:12:20 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id wBKICKCO3682305; Thu, 20 Dec 2018 10:12:20 -0800 Date: Thu, 20 Dec 2018 10:12:20 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Leo Yan Message-ID: Cc: mathieu.poirier@linaro.org, namhyung@kernel.org, leo.yan@linaro.org, mingo@kernel.org, acme@redhat.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mike.leach@linaro.org, robert.walker@arm.com, jolsa@redhat.com, alexander.shishkin@linux.intel.com, hpa@zytor.com Reply-To: mike.leach@linaro.org, robert.walker@arm.com, hpa@zytor.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, mathieu.poirier@linaro.org, namhyung@kernel.org, leo.yan@linaro.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, acme@redhat.com, mingo@kernel.org In-Reply-To: <1544513908-16805-2-git-send-email-leo.yan@linaro.org> References: <1544513908-16805-2-git-send-email-leo.yan@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf cs-etm: Correct packets swapping in cs_etm__flush() Git-Commit-ID: 43fd56669c28cd354e9228bdb58e4bca1c1a8b66 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 43fd56669c28cd354e9228bdb58e4bca1c1a8b66 Gitweb: https://git.kernel.org/tip/43fd56669c28cd354e9228bdb58e4bca1c1a8b66 Author: Leo Yan AuthorDate: Tue, 11 Dec 2018 15:38:21 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 18 Dec 2018 12:23:58 -0300 perf cs-etm: Correct packets swapping in cs_etm__flush() 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 --- 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 23159c33db2a..789707bc4e9e 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1042,7 +1042,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.