Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1050806imu; Fri, 16 Nov 2018 14:59:56 -0800 (PST) X-Google-Smtp-Source: AJdET5d4KfDTkhRrF83yIlbWkirn00RYNKg2C/L/eH7s9kmpbZZluQRR/UuebSuStOrcTe3HIoqn X-Received: by 2002:a62:ce85:: with SMTP id y127mr8259351pfg.201.1542409196632; Fri, 16 Nov 2018 14:59:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542409196; cv=none; d=google.com; s=arc-20160816; b=z1MYW64z6NRwoHC2I92oSVXlI4BKrNR53uronpxWQT9zWTbWcW6E+nO/un1uUrfEFG o3MKpib8f4/quQ+iZxdhKD0M1Z9aaHB6lyu7UMz5PwJSNm8xEiX46IV+5zyAiTBLRwPc eEezKVU1iD2lIw+0LxnzFYQRaXrnb2CsA0d1jJ3C4NOXIxcKWQrCMzeBWRToHI0edr/Q KOI9RXEkkMksZ3ghRSoj9GQrAljlV2BxQdSzTguoXHI38sS2aZjSvxG2YdQ0/+OG3EBK 4+YzBGoEqZTnA/Za/PboC5nfiavJ6NCN87Y402QshUbDQKXjwODBp6HZF+UpWfMWFCRS KXjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=RHMU7FC4FSigZnswvFS/blw86ceh/1RAWF2TH8IAqpQ=; b=jRrvlvphM+NRdsdb990LnmD0UXg//RA4lXH7DGLKMcvAT5F6RGvMVjxebrm0IZzDSD V9F837GZKE7ZRJhvgX8VnikrQWcI0VoCshUJQ6wiU3fpV7MCLlRnxBPfc4zMGEIdbO36 gDiYJTHdExirOdiXRq4ghucMgt6Lj4hmR5dtNj0nbpseR+/bEadqF0cGR49oyKwPy6UZ Mlw29NvYbT0Zrwf96LtKR2pPh+xclTAZRPC8KgLbzhbhR1gCaLl8Z/pcBuvZzWGECi8u 7XtLJjLbkjZm0b7b6jgEzN7Y7MN146r2+IKyay3m5BiiwuAdIalaakLzCGGsESZOiDN7 rfow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iPAbaZs1; 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 y72-v6si1686707pfd.254.2018.11.16.14.59.41; Fri, 16 Nov 2018 14:59:56 -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=iPAbaZs1; 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 S1729922AbeKQJM7 (ORCPT + 99 others); Sat, 17 Nov 2018 04:12:59 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44708 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725995AbeKQJM7 (ORCPT ); Sat, 17 Nov 2018 04:12:59 -0500 Received: by mail-pg1-f193.google.com with SMTP id t13so2554369pgr.11 for ; Fri, 16 Nov 2018 14:58:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=RHMU7FC4FSigZnswvFS/blw86ceh/1RAWF2TH8IAqpQ=; b=iPAbaZs1E85xTUioGtNJVgPqwLdjUIofsrNK8VPNQrlTFxVeS6btjL+BqumDTF7rmM kwRO69yw0PtBDGzCrdR2xSdhWAcAw6bw7q1cstABvVG+3pLdiupQSFXugG3hZwv5kHNC gdj95brPl8AGXkmIt2tmq7zrEFngDvQLtinPE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=RHMU7FC4FSigZnswvFS/blw86ceh/1RAWF2TH8IAqpQ=; b=jiMen5xqMdU7Yi/lFZIC83QuNvCwM8KJJP6YGzSEmVqRKq4OELFJlbhzftU/n9/VV6 Fv+i5IZuR63KkP8j/SejuntIaC0uXBGHOHPa55GYd+wVs8r/axitqhYzQZrOVRIyqk0+ 3UUpw+6rw5lV/jkjpNEBORTwNSBWB/FyGekkLg1C86PTr53mFSFJ0aMDqgvAZfTWxc94 7BhObO9MrjWScTVFuTbMQ/YxwrQ5SjSXjqKBcGMrA5qKTkMHc3HN127qWZHlYfDwhQpr yM7PDTX4XCkF0G7yFYpgLPHJeZt0knE7mZuDXMik4/XLgOKngjis49qGFZsWUhGAqixd MVZQ== X-Gm-Message-State: AGRZ1gK8PlxlFJbGCqpZqVSYVS0/Dqpqy433F5+PwUb78wQRp+Pv3yWJ neIoSgBOPoBk1JQrE2vMJcbGaw== X-Received: by 2002:a63:ed15:: with SMTP id d21mr11591576pgi.305.1542409121932; Fri, 16 Nov 2018 14:58:41 -0800 (PST) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o86-v6sm41601034pfk.8.2018.11.16.14.58.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Nov 2018 14:58:41 -0800 (PST) Date: Fri, 16 Nov 2018 15:58:38 -0700 From: Mathieu Poirier To: Leo Yan Cc: Arnaldo Carvalho de Melo , 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 Subject: Re: [PATCH v1 1/5] perf cs-etm: Correct packets swapping in cs_etm__flush() Message-ID: <20181116225838.GA25258@xps15> References: <1541912383-19915-1-git-send-email-leo.yan@linaro.org> <1541912383-19915-2-git-send-email-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1541912383-19915-2-git-send-email-leo.yan@linaro.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 11, 2018 at 12:59:39PM +0800, Leo Yan wrote: > 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) { This seems like the right thing to do, if only to be consistent with that is done in cs_etm__sample(). Reviewed-by: Mathieu Poirier > /* > * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for > * the next incoming packet. > -- > 2.7.4 >