Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9002252imu; Tue, 4 Dec 2018 19:00:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/VhAjiDxYsQpCGLIhA4VbGWkGrwNX488jnrRBacmnwc+RfC18ECOmydWt/sO+rMvVdlb3Yv X-Received: by 2002:a63:5ec6:: with SMTP id s189mr17122827pgb.357.1543978845884; Tue, 04 Dec 2018 19:00:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543978845; cv=none; d=google.com; s=arc-20160816; b=AlgCmB0WgBob/adXPMZY+QAYmAvLsdcoaRmVGQqvddGi6bDKpcECm9o6EkJhbstM6S 8mJmMV5fDf0JpQKePEVkCLbNh5VMWoMwMnocLhN3jv2aTlx2DLd2GPrpdPZfpy9rH5lg JcZv5j2keeCKrMyM0VcXG8SUuvZmUTgTKsFZAO4HL1CamAQ21LHq5cf9xSDeu0PMgDfj 0nfdOS4QGj1MKSIEDRTOXiLKp8b5c7yZXGFkP71SlyymbTvum2kQL9oxv5gbtduZ1E6H G/4v9T7OQXqjty8b4R4w9IbB51GOG9TlullE82Ea/hh1QICCJWw0SrjHYSCVEDTmXunN K4YA== 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=JtHvc1wKR8UzHTWCRtECIwbWEcC9WmtTV1sPBssAB/8=; b=sF2PZxluXG6tHj0n4xHfmhTnuLkLUWHiA8LGPbHR+8L1lD5FZHqoJuVYWGH4IyQAOP /0PZ7wylRB19O+/41g7dExqw5WxM8/oWRwxKOsiCfI1eVbRB3iKjhxJ0ezdo3F6i7sLo pqi1ddpntn1hHa21ZCty5JXxS68uw0wsDuNYm95ME9U6UqONmpLA3laeS++6hhaMSjiy o+nAwABRB6Yp6IjcxjxOM6e6jByp2UakWkZQHDkjRKY/fhU80nVLzhcZ+jHk1kGXNzFs dh+LOGzDX1rsRkm+Ado8eI+vNgj/AUcuKp/8t/PqvOtVS67b0mN6oy1wqw4NBro0SW3i 78xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jd2XerM9; 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 r22si16700908pgl.537.2018.12.04.19.00.29; Tue, 04 Dec 2018 19:00:45 -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=jd2XerM9; 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 S1726768AbeLEC6m (ORCPT + 99 others); Tue, 4 Dec 2018 21:58:42 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35787 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbeLEC6m (ORCPT ); Tue, 4 Dec 2018 21:58:42 -0500 Received: by mail-wr1-f66.google.com with SMTP id 96so18072292wrb.2 for ; Tue, 04 Dec 2018 18:58:41 -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=JtHvc1wKR8UzHTWCRtECIwbWEcC9WmtTV1sPBssAB/8=; b=jd2XerM9WriBcE6UWG5K+DgtOKnCM5pYBNbTHSuHJZt7/xbuBc2ndhYzORMnpLFOkY sjHBYAboFCueFIbGZy38z6mkZ8CDt1/3b24ZjbtyoAFhRH9Ci3aO1bBR3o0krWw/us/R Y0bXKhiKav/++dV38NcUYRTuUK5ATnRZOf6PQ= 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=JtHvc1wKR8UzHTWCRtECIwbWEcC9WmtTV1sPBssAB/8=; b=LIbw7oLyUagNJwZ4guK0Zdj6fhM0gkBUYLTsBtMN2092vub4oVAwACoXHRgNGxPzyv zJZZn0mKtUEZLLeQIkrUzrvuXxd7colAoa3o19bz89AwuOzbg8ghlDAyD6LRPiEhdrP4 fUxXwBsMGL4dimYWzHrbZbOHIGTIpLKcM9IKZ8yiMIu/2RI1+EgV9TofYt0TSaEVaDr3 YKMsNu6G0Jzu/T6zG5g4zuu/EQJyxq7fI7lPvByl4pZPAyW6I52qqqYkuIzYVeF/ExdC Nrcrss82d05A5R/VrlvbjXhr5XXi8RoSznabESQvEJUIOwrzYFOK3YJDOvH5chSqTE9E 5jBA== X-Gm-Message-State: AA+aEWbJKmffPt4yaEG0phBvILNNV22jH62bJPcMooUIoHicwxbJkcGm yq1+JaJ1ztWiAIIsiTPOxLSObQ== X-Received: by 2002:adf:c612:: with SMTP id n18mr19396951wrg.174.1543978720427; Tue, 04 Dec 2018 18:58:40 -0800 (PST) Received: from leoy-ThinkPad-X240s ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id t6sm16910200wru.11.2018.12.04.18.58.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 18:58:39 -0800 (PST) Date: Wed, 5 Dec 2018 10:58:32 +0800 From: leo.yan@linaro.org To: Mathieu Poirier 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 2/5] perf cs-etm: Avoid stale branch samples when flush packet Message-ID: <20181205025832.GA13305@leoy-ThinkPad-X240s> References: <1541912383-19915-1-git-send-email-leo.yan@linaro.org> <1541912383-19915-3-git-send-email-leo.yan@linaro.org> <20181116230511.GB25258@xps15> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181116230511.GB25258@xps15> User-Agent: Mutt/1.10+31 (9cdd884) (2018-06-19) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 16, 2018 at 04:05:11PM -0700, Mathieu Poirier wrote: [...] > > -static int cs_etm__flush(struct cs_etm_queue *etmq) > > +static int cs_etm__flush(struct cs_etm_queue *etmq, bool new_packet) > > { > > int err = 0; > > struct cs_etm_auxtrace *etm = etmq->etm; > > @@ -989,6 +989,20 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) > > > > } > > > > + /* > > + * If 'new_packet' is false, this time call has no a new packet > > + * coming and 'etmq->packet' contains the stale packet which is > > + * set at the previous time with packets swapping. In this case > > + * this function is invoked only for flushing branch stack at > > + * the end of buffer handling. > > + * > > + * Simply to say, branch samples should be generated when every > > + * time receive one new packet; otherwise, directly bail out to > > + * avoid generate branch sample with stale packet. > > + */ > > + if (!new_packet) > > + return 0; > > + > > if (etm->sample_branches && > > etmq->prev_packet->sample_type == CS_ETM_RANGE) { > > err = cs_etm__synth_branch_sample(etmq); > > @@ -1075,7 +1089,7 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) > > * Discontinuity in trace, flush > > * previous branch stack > > */ > > - cs_etm__flush(etmq); > > + cs_etm__flush(etmq, true); > > break; > > case CS_ETM_EMPTY: > > /* > > @@ -1092,7 +1106,7 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) > > > > if (err == 0) > > /* Flush any remaining branch stack entries */ > > - err = cs_etm__flush(etmq); > > + err = cs_etm__flush(etmq, false); > > I understand what you're doing and it will yield the correct results. What I'm > not sure about is if we wouldn't be better off splitting cs_etm__flush() > in order to reduce the complexity of the main decoding loop. That is rename > cs_etm__flush() to something like cs_etm__trace_on() and spin off a new > cs_etm__end_block(). > > It does introduce a little bit of code duplication but I think we'd win in terms > of readability and flexibility. Sorry for long delay, Mathieu. Agree with the idea of splitting cs_etm__flush() into two functions. Will spin patch for new version. Thanks, Leo Yan > > } > > > > return err; > > -- > > 2.7.4 > >