Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp359159imu; Mon, 10 Dec 2018 23:41:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/WIj2rYux+LN8q+8lpFePE/8chyLmitl6ait9cjMNgf/W0ZzlQD6TXUcrDFqD6j65mk9pmJ X-Received: by 2002:a17:902:2bc5:: with SMTP id l63mr15343936plb.107.1544514103843; Mon, 10 Dec 2018 23:41:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544514103; cv=none; d=google.com; s=arc-20160816; b=jGhy5CLvSlxXRJ5kPNSOp3RFu64s9YRXZqGvIDNj4A+JgRQiSeh/Ue4LJhw87RkPM5 66Y+R0ETAyl5eAKIKbBD8gPAey7zBBrGioGBZCi8Sd1Qp8p+IP7euiB1ohIs4L+I2DQZ Q5Vz9QZ9ZQcr2y/H6Xqyv7hywcSVknVPqhybWUSmXycn0zwdYuWFBibf47Hiq6mCNkKm MqowKCMjKVFsO0s7PPFtTkTX+t8foW7N51EgtrpJrKKlam6CxLzNg7XqHOW+b/A15xxU Q8WfE6j2MqWOpyQ5wq370hgQ0uKSyKcT8SS4zsTePdw5/m85qmHWl2In9WAO5Mwg+TBc 9dJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=DdJei3MXkGiE0iSB4u2n/6IcLLnmeX4skh5tiKXlEYc=; b=YG4GIBPR7mgM2tlQFiBx9FNGqYg1VrKblB+v+czPEZoiWIJ5bJYIf+OC5qq3JwF0/D AQOnKkHyN2QTeb6ZSm+4cYM39Xwx+HFbHJOHcK8XHyvi6lvUPQ36GKgwMM+7N4a3aOBJ oHREQZTEi2RrJ+uRelPoqWX8/kxn94uuPD5t+TYRcVdeD6PStMJpEAlvYpZ6PDAnbI3o FsVqZ3S/oWFuvx0A8Da/TTQ4N716e0kJ95Lh3oT/96Buqwe4FaHkul+NgC7uexi+a7rn kNvMv/6BOzz8p4sxcTf0olbYdWAZfiL02FA3aBjQ16WZmsvUY8w+71yv6eZh8ObGfduh /g9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pelw3oX0; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10si11688339plh.307.2018.12.10.23.41.26; Mon, 10 Dec 2018 23:41:43 -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=@linaro.org header.s=google header.b=Pelw3oX0; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726219AbeLKHkc (ORCPT + 99 others); Tue, 11 Dec 2018 02:40:32 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39291 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbeLKHka (ORCPT ); Tue, 11 Dec 2018 02:40:30 -0500 Received: by mail-wr1-f68.google.com with SMTP id t27so12956178wra.6 for ; Mon, 10 Dec 2018 23:40:29 -0800 (PST) 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=DdJei3MXkGiE0iSB4u2n/6IcLLnmeX4skh5tiKXlEYc=; b=Pelw3oX02t5Wn+zKQ4m+N8Q2Dtp048djj7lyuhalY/P2THi7fEdeG+Bdnq1t9DWCFK fqtZNs8ALDy2Mz2QZiMlVxvS6eXVEY+0sXKLexHhklfSFc8m8IGnjV8dgEgFf4Y9KJS8 mN58fXhibOuSqg/6lEofkfd1OuiHWd5HpeJaA= 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=DdJei3MXkGiE0iSB4u2n/6IcLLnmeX4skh5tiKXlEYc=; b=ZS9bmYD7ThZJc/0r4B2UKrzprMGX2atbNs5mAYoZQ1IzyK7Xj2Rpujatpf6QN0d0zL Zj+86z8A7j4y7PSm6Vz9jx57xHwIprE+MVsMG/nvpvcQrv5+uOQZGeB/vN08MqBNBLzR Rwcc/yvba07Alda3Z3KfXCfCb1SDR+pcNoGx/owYZkjZBSumuItbpfReM0TdwMmK0thq w5EiNioyUsQvq9PeRxyeFuyLRHOLcscZ1yeaJdnykad96dAqjzUKwv+o3u3VW6w5pL2C xL/pKZo4g3oYOjwu6GAWsspg0lB0KKEww60W0Jhx/1sF/HHoopttZzjVCd04tx3OspXz XC9g== X-Gm-Message-State: AA+aEWakqiNlPKu+Bg5qx+yssCc48duOPI4UAvTK07etmzcY+LCVDulc bh4Vpjznvhi+nGDm2Wck3plJ7g== X-Received: by 2002:adf:efd1:: with SMTP id i17mr12066007wrp.200.1544514028756; Mon, 10 Dec 2018 23:40:28 -0800 (PST) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id k7sm14186961wrl.51.2018.12.10.23.40.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Dec 2018 23:40:27 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Coresight ML Cc: Leo Yan , Mike Leach , Robert Walker Subject: [PATCH v3 1/8] perf cs-etm: Correct packets swapping in cs_etm__flush() Date: Tue, 11 Dec 2018 15:38:21 +0800 Message-Id: <1544513908-16805-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544513908-16805-1-git-send-email-leo.yan@linaro.org> References: <1544513908-16805-1-git-send-email-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: Mike Leach Cc: Robert Walker --- 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 23159c33..789707b 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. -- 2.7.4