From patchwork Fri Nov 1 02:07:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 178239 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp200559ill; Thu, 31 Oct 2019 19:08:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyV3a2AVAauGKl5Dv/9R9jPy7qihHw2kPwAGumUbS5wNG3Pvgw/kKVIYjXphoKnIRBeuWQX X-Received: by 2002:a17:906:4dd5:: with SMTP id f21mr7212289ejw.203.1572574097596; Thu, 31 Oct 2019 19:08:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572574097; cv=none; d=google.com; s=arc-20160816; b=zrXcNUuJfmT+rI3iXGAxMt7QvZDR4x/iin5bya/QFZZOHKJeHFbSsSSYTVN9fKuJAT q387rGbyymYeTAByy3sChZ0q8csjzD+iCmiTlFTbGtkSgByJu/Y5VaMVLPflGGeRhNkR JCYZ5JyrgbFj3jCnTXftyZySwhusm7MoQQL8euldB2OkTpg0VCbTE/BG+L8mfwQgolpp 1RLIKMO79QkPRJqIonjTrYEHOWk1cuoVKZsZg1C+n+DttbHVNNUo8q9LeKWmBBc839vr 2wHYP0UUBmysTQEtZgfErTbl71KXptEK3xFzbgNu2PYetwyVKTzkVWd95llFESBUA55n bJOw== 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=iAgomrDaaw+p9SyPDKe+DIwZEIKyPHeJdp6rMCsSqrc=; b=KF1ba6qqVrbFoK1O/OVTIb4+yGn93cpvJWOTLb2kqSUnIjQYUJh/4MYRHz3apmXBFW GITpukObCTGgqkAIrWyBD1nXtyMOPGR2VGaVYV3RNR/lgaiQmcgXGYJ2uM368sLN2kl7 F/4upuuUXuUgtLDYHh77ZFZOSWngvESP6QBU7YicjyPlA/LVKEZRNcJuEPJcxqgG/yCw 8UvuvDOyKlByJxjs08sLBHrz2WRzfyOP5aO2Mzf/fCuoqDxoxEzl/WBNrXSpGolLLpxn 5gmGDvi1h4cl2vwtMvDB/vbk/TOcnzIHkp6oBg4wvAZI2CHxB+aEoZhIOuVjmfSzTURz S/Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KBf2RlKG; 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 nt21si4458647ejb.119.2019.10.31.19.08.17; Thu, 31 Oct 2019 19:08:17 -0700 (PDT) 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=KBf2RlKG; 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 S1728882AbfKACIL (ORCPT + 26 others); Thu, 31 Oct 2019 22:08:11 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:46611 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726540AbfKACIL (ORCPT ); Thu, 31 Oct 2019 22:08:11 -0400 Received: by mail-yw1-f66.google.com with SMTP id i2so2958491ywg.13 for ; Thu, 31 Oct 2019 19:08:10 -0700 (PDT) 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=iAgomrDaaw+p9SyPDKe+DIwZEIKyPHeJdp6rMCsSqrc=; b=KBf2RlKG/HVF+HdZkZwipGGFDc87+W3TEb3cKUL72YSFO06gGeEQCdgEwVcGArbIEC 0hSgawpERrPxShlj96U8j0EgDlDAsSoXTlAfDF2GR344/R8BofFgqibEFBlB+mtGqpuN yFMWgZDIShlUYgLFAy6VDY/j17XU0RC2KQPP9Zcp0/Fq/zv2fYl5Gzg2C+K9spCxNznK QykUXf43faePtkV1/a+P/HuHQYCopqaTgTTJtmlrkvjthjf5XRXXi8vGr5ds8Y7RcjoL KbYzAlzMi2De7OyKSieTdE1sGOTS6Q/7qt25zBlxC+3NjFCaXNOZpXMQxfg/hFGQtbec FXmA== 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=iAgomrDaaw+p9SyPDKe+DIwZEIKyPHeJdp6rMCsSqrc=; b=KGKj1h/YmuZ6t6FDgjyA5QAqtZ0FjuZB+CQKsNuwdOGl+aXgAqnJYtTBw69xEYZe3t koYMeqMvj7ffkCr3qEwcqEmB9TRHKkgrEJJ8LtHMr7hBSM4pl7dDyusvy2ac2+0xJThI r0L5Cxi3cIrxFoNP7P86q9h8RXtiIDh2dJJhynzqb2K+NXMfqHtSqRotkAFB6pqfBFgf o2mCdc3F3IXw8VNTztEDrIQ3ndk7MXs6yp2m4B0NQEr1wAOARfaI7xi8o5iOvrg2NtAO yxX6thGBjL+rLY3jTPxDrK6uSBMdTZ/R9avVaEX1m1zTNac2EXWBK913f2PIl3BwRgxf tcIg== X-Gm-Message-State: APjAAAWyM6tFOlC3uASKqNbrtgDDZ70VyDXjHHzRt7+erWmzduD7370a E+tEdZDCIpyoShtMBrYgOMzdmw== X-Received: by 2002:a81:8501:: with SMTP id v1mr6501020ywf.406.1572574090230; Thu, 31 Oct 2019 19:08:10 -0700 (PDT) Received: from localhost.localdomain (li1038-30.members.linode.com. [45.33.96.30]) by smtp.gmail.com with ESMTPSA id m5sm3762076ywj.27.2019.10.31.19.08.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 19:08:09 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel , Linux Kernel Mailing List , Coresight ML , Robert Walker Cc: Leo Yan Subject: [PATCH v2 1/4] perf cs-etm: Continuously record last branches Date: Fri, 1 Nov 2019 10:07:47 +0800 Message-Id: <20191101020750.29063-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101020750.29063-1-leo.yan@linaro.org> References: <20191101020750.29063-1-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Every time synthesize instruction sample, the last branches recording will be reset. This would be fine if the instruction period is big enough, for example if we use the option '--itrace=i100000', the last branch array is reset for every instruction sample (10000 instructions per period); before generate the next instruction sample, there has the enough packets coming to fill last branch array. On the other hand, if set a very small period, the packets will be significantly reduced between two continuous instruction samples, thus if the last branch array is reset for the previous instruction sample, it's almost empty for the next instruction sample. To allow the last branches to work for any instruction periods, this patch avoids to reset the last branches for every instruction sample and only reset it when flush the trace data. The last branches will be reset only for two cases, one is for trace starting, another case is for discontinuous trace; thus it can continuously record last branches. Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index f5f855fff412..8be6d010ae84 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1153,9 +1153,6 @@ static int cs_etm__synth_instruction_sample(struct cs_etm_queue *etmq, "CS ETM Trace: failed to deliver instruction event, error %d\n", ret); - if (etm->synth_opts.last_branch) - cs_etm__reset_last_branch_rb(tidq); - return ret; } @@ -1486,6 +1483,10 @@ static int cs_etm__flush(struct cs_etm_queue *etmq, tidq->prev_packet = tmp; } + /* Reset last branches after flush the trace */ + if (etm->synth_opts.last_branch) + cs_etm__reset_last_branch_rb(tidq); + return err; }