Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2656141imu; Sat, 10 Nov 2018 21:01:12 -0800 (PST) X-Google-Smtp-Source: AJdET5eRzXFtU5vQdIRivcNhOlmv3xG+WOFPjK4jTXsbVPJnPkHdF+hDAYhwmZfjdGOHG0IY6LRF X-Received: by 2002:a65:5286:: with SMTP id y6mr13054474pgp.439.1541912472599; Sat, 10 Nov 2018 21:01:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541912472; cv=none; d=google.com; s=arc-20160816; b=n+N8mL6V+U7HizalK7nWm1h80Xc3XMt5R0yarVa962lUqtRJDvbMATpUvY0N4RYvlU TBZCPkuGpEJPsTM6oK4JPX1QtoiyEt38aypku9DCjutcZsArC88XQSKQ7g9sI2/QZYgr dS7Dv6ab7Dp/XSTgd3jERoaDHNT16UoEbdkkASi7XRZ/t5oY4elBYtQ0dqXCeEY/tw2v T1oZZb9zNashbntTCnTNZHjnmKmY3fI0h5xYT+bDTgtZVDrc+wAzXLHLkzGCrcmkSzxv kNxihtY+tWBgpZ82qoY0bAkTTrMTP+qVh7o3LpP1cQL3KYopnimTUF5A1QSPFWdH/Gwu EVQA== 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=ZbLjNsAHRTQqCj6a1vHW0MpbOVGBpYLMhVIToqZ+NHM=; b=wP2UCS1epKl+A6mzwL8nThNRRk+8HFkvta+oyRzY884xy7Y+exl7iEl5oLG0HVEI2F +idVg7T/tDpnQBh3XyyuDcnNSR6R+AQ+P142LuVx0tv2lTnCZ+1roNkINIkMYAfiQPM2 1i3WbfBtOMPqRea4wdlpOcE0glsMFXwJdpLKRHGL6XWFlbEwXHjPFugpS6gPk/1obwMp BFoTMk5d98q1oI4evUSon8VZghuWNt+UE1X0cT6rFszoXf22SZp5TFynPzmq04LxqZlP XX38pbsi3ErWa7KBqoLNVILhKCpKti9CK7qFDZIomwIaNcpHyNm+huVg6SE3yhrsnmd/ M74Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kX3Ru026; 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 m63-v6si13693952pld.161.2018.11.10.21.00.44; Sat, 10 Nov 2018 21:01:12 -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=kX3Ru026; 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 S1727490AbeKKOrn (ORCPT + 99 others); Sun, 11 Nov 2018 09:47:43 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36476 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727184AbeKKOrn (ORCPT ); Sun, 11 Nov 2018 09:47:43 -0500 Received: by mail-wm1-f67.google.com with SMTP id v70-v6so4777763wmd.1 for ; Sat, 10 Nov 2018 21:00:14 -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=ZbLjNsAHRTQqCj6a1vHW0MpbOVGBpYLMhVIToqZ+NHM=; b=kX3Ru026f/ESYt6B1mTZGk6Ey5ia7fEi5PJ8IB30wxK77FSFx+/TfmzhW8Rt1b9Mws oOALFaXam6s1cb/uM7MDCMsKmVuZD/KEnnc/V2aTzpS+VR8Sng/OTGhv8T2Hcedq4IC5 /gqUm0MrB1tnHKUHCkfhRdA9rVW2rc1/3D1h0= 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=ZbLjNsAHRTQqCj6a1vHW0MpbOVGBpYLMhVIToqZ+NHM=; b=nKVLLSOz1CWdNmJp5vXSngP3otcpnop2L8gxUNAGtKOsthsQBFUmhFLKrmpftqRUY2 FjHOAd4h6luqUeV9oUa20hC1tqaaBAs9uvk/eqC3YK4MjfAcU/hN1jaLc2v2uBZz5dE3 wPPBEctpNa7qPmOujPxXAAyuit0BfGCudOLr3a1n4kABbA5lHIECHnNmWZXDuH/gggu8 vnit9x1G/M4el/w2MCXlrXMrk2RGxfD9WbKy7iZd9WD8uU5Z8GCvSTKB01QgDEt+3gLS djyAinaGTomr3VAGeNoOgepI5F4SAstx9Ap/4Bvh8Gh7ruQYTWjdCJyJVt/mVybqRG+D xsaA== X-Gm-Message-State: AGRZ1gLlXH++AxEu3E3rvnUDfTIuOWsZ0ddLdcRgnTj4inmDVrGcNhpE q4QiwjUI4dQLXcrwDRjR+zuMbw== X-Received: by 2002:a1c:1a53:: with SMTP id a80-v6mr3928909wma.120.1541912413637; Sat, 10 Nov 2018 21:00:13 -0800 (PST) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id t187-v6sm4463802wmt.45.2018.11.10.21.00.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Nov 2018 21:00:12 -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, Mike Leach , Robert Walker , Al Grant , Coresight ML Cc: Leo Yan Subject: [PATCH v1 1/5] perf cs-etm: Correct packets swapping in cs_etm__flush() Date: Sun, 11 Nov 2018 12:59:39 +0800 Message-Id: <1541912383-19915-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541912383-19915-1-git-send-email-leo.yan@linaro.org> References: <1541912383-19915-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. Signed-off-by: Leo Yan --- 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 48ad217..fe18d7b 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -997,7 +997,7 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) } swap_packet: - if (etmq->etm->synth_opts.last_branch) { + if (etm->sample_branches || etmq->etm->synth_opts.last_branch) { /* * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for * the next incoming packet. -- 2.7.4