Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3381523imu; Mon, 10 Dec 2018 00:54:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ua1ni7aBC5R6/1pXjwhVn2Kmys01dVX348+JeoqYdrqHPtdRKc/CSvKHZmNh0eC/uwDurg X-Received: by 2002:a17:902:722:: with SMTP id 31mr11435552pli.271.1544432084751; Mon, 10 Dec 2018 00:54:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544432084; cv=none; d=google.com; s=arc-20160816; b=n5VO1l9kSw2FqEz6KZDt0zCIxQ9UyFzNBAGMzZg8btcCz6RPAoJX6EZUDO/idaFaNq q6wVPnxk5WA21dZkH3wijEO0t6wg4jT++WH9WuQLOd5zNgJVas1ygvIDDLtbNUiKdWf2 qklAHhBbWP+1JhSzOGfWK9vKa+Vsx0FvhUdrete6yGrb2W4IVGGA711RBd8Pj9p8mgPq 2GU4uL8ughyKWTWdmMlFQi0r1MLm3+0/q2rvU/pDIOH+qkGUq/i0Po9AKXzHmbGPqw3q HOq+fRSE/pMn/FepV53KCf2YZ+3gtzBPrFuMA5BExBfKGjU9gBbRGuv1sQLyn3uzZZ62 tLew== 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=39wBlDXGyPZlvdOM4v0qZ1Ghil7xJLHLF05MaMBQC4c=; b=qZQhY6FvN55euBpu/1SrulwI+8f0be3yOtHiHH7W9oMkj36jTAwikwXUi1gq7VQmrd d4cpGYuOziAO+nXH071qfJddipKeIUZK4gPjjIh/rCLobXK3Rb3OYisq7yhbOwsYbsj4 hIxSHi9IrS7xBCyjUk1EkrA+6fErGKxQmkoLjlsbCKsFxJCWFvnMhX+SMIDBaS3gQ0MN rdyyS4oiIEdTnZeIar6MrcSGIoJmTdKH7n4Z2Syshuk/vgiHq2ic+xy73IpmuBxNZ0k4 yr4KAO/8ITW/Xod5gbtJ4VuPy+7UtqBze/3uwAB29IN5Cilw7mxqSWe93mAkZrDLwo7I HXCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bxt7r7e1; 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 v25si9063722pgk.341.2018.12.10.00.54.16; Mon, 10 Dec 2018 00:54:44 -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=bxt7r7e1; 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 S1726680AbeLJIxZ (ORCPT + 99 others); Mon, 10 Dec 2018 03:53:25 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41710 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbeLJIxY (ORCPT ); Mon, 10 Dec 2018 03:53:24 -0500 Received: by mail-wr1-f68.google.com with SMTP id x10so9538678wrs.8 for ; Mon, 10 Dec 2018 00:53:23 -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=39wBlDXGyPZlvdOM4v0qZ1Ghil7xJLHLF05MaMBQC4c=; b=bxt7r7e1AGI4295LFa3jazbFqPFJ32MDDhQyDn4+GuLOA0SEIMz9uk5rORpI2g3oZN qDMO3WpYTVfLKNe8SNjhp0YhRcwg2b6cjABzskwJK1WY2p+BK0xRMR3B0NehJEMpd2LE HL5EBnL+r1UUHKvB2FEbsUt2ojc/XuzWq95W4= 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=39wBlDXGyPZlvdOM4v0qZ1Ghil7xJLHLF05MaMBQC4c=; b=X9+eTCgBe049Soovy1WhuDz2QgmL3RS/sXPqSJxuzI6FG8RZdfoVoUppfxZH0ocoAx wJwuCWPmrJbijsa1Mz3tndIbaUn85/H42Zmiu/NScZyRzz6rXXDEOkX/4PDBhnkZqF9P 1dmip+IaRl6PZnZw+3TK+E0hLQfuPx89MYiE6Z24k5GIu0myP8hIGv9i1z67pDbPcW6m m+NsycQVuVvDYyYvsfwCFMMYJj5pFNYvl2aD5o9PoG7erbFc7l8R29TjOtUbsFP/XIAW 3t0D/AE0W1hrTpJb5lzC3ZK0IFiHwvcVmKthEgrQuKo4z6rIz5eU7+/H3bfGS2fcPItM UXqA== X-Gm-Message-State: AA+aEWaZlDf39rbP7WOk/nRJJlkn2lN2v81flFEAvC+CE7+flvcZjscV Am5b6e2VqqJv1zCDss8BJ2mq0w== X-Received: by 2002:adf:be0f:: with SMTP id n15mr9403212wrh.267.1544432002659; Mon, 10 Dec 2018 00:53:22 -0800 (PST) Received: from localhost.localdomain ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id m4sm9097351wml.2.2018.12.10.00.53.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Dec 2018 00:53:21 -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 v2 1/6] perf cs-etm: Correct packets swapping in cs_etm__flush() Date: Mon, 10 Dec 2018 16:52:56 +0800 Message-Id: <1544431981-24144-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544431981-24144-1-git-send-email-leo.yan@linaro.org> References: <1544431981-24144-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(). Reviewed-by: Mathieu Poirier Cc: Mike Leach Cc: Robert Walker 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 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