Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp696804ybg; Thu, 19 Mar 2020 07:12:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsYR4f3ew8RNynY+pWr1C+rAm/M0Z8w6JnTPCGfAb/WItLW7+6mz6BQLEXCE69OaNbI7wXJ X-Received: by 2002:aca:bfc2:: with SMTP id p185mr2569470oif.57.1584627131575; Thu, 19 Mar 2020 07:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584627131; cv=none; d=google.com; s=arc-20160816; b=hdbGqNUnfZh+fpI1j5jNODOj4HbvTgnAbW/CqsKEq59gzYji7eKMY7C0/CHMuqNlnB flB8b4GCB/CycRjwnQuSbaCy4aLJtoYH8WB64iJEFYUDTkhRlzx4iG58BsoCbqW3TZZP RMEkVnm9i9nzcbnljArKLbxjDQCINTj1aFYQL+t8QAbaJu0syu9VUOOYAwJJQ1XSJafG mi5p94r1jHceC1ol1QiCbYgmQWao+w3ijHSOV1oZXuRJwIOhwTF+CqTrna6SpHkwPBMy emel3ORT0/VfgP1dZf3puITtZnS/NEhu4fHJ3tnT8p+Vs7dNBFmhtVY4MXeCcrGtndfO HgbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=5b+VnqIN+GKl0cZMF6yeV8mw6lLY84wooK8xhZoD+3o=; b=EGiqr55jG43bF4jlD4oEv2rAaytJDeIzeVEo3LwkaNX0hjphEI00JmbQSBjd0EravW JwevlSxV9TUGMyZ7bHAmeCcoVC5VtTOXTaUYd3mUjqzdlOlagUqwW0YCEmJHZlUWe8AN KSleWn4AArh4KWPy+2wju0vBJVnQfjEmBiwYsc53iixcGRQRq+je7m0V8odWdWxcklVD s2iskFOliIneVrGLYfB3PZVgBRL/smJ+oHjJoT6pNC/SYYSpG/CmVveLUdmd6YHUpr08 /PusxXGSfYWuUGGRen5m0wm0fX6+q3U+nNfuCNfuG91Bg15282idm6H6mUoFSNl5BsTD kfqw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si1029834oie.124.2020.03.19.07.11.38; Thu, 19 Mar 2020 07:12:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727876AbgCSOLD (ORCPT + 99 others); Thu, 19 Mar 2020 10:11:03 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:60946 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727668AbgCSOLA (ORCPT ); Thu, 19 Mar 2020 10:11:00 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jEvsn-00022q-EN; Thu, 19 Mar 2020 15:10:49 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 14B551C22A3; Thu, 19 Mar 2020 15:10:44 +0100 (CET) Date: Thu, 19 Mar 2020 14:10:43 -0000 From: "tip-bot2 for Leo Yan" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf cs-etm: Optimize copying last branches Cc: Leo Yan , Mathieu Poirier , Mike Leach , Alexander Shishkin , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Robert Walker , Suzuki Poulouse , coresight ml , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo , x86 , LKML In-Reply-To: <20200219021811.20067-5-leo.yan@linaro.org> References: <20200219021811.20067-5-leo.yan@linaro.org> MIME-Version: 1.0 Message-ID: <158462704380.28353.5443824245007794941.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: 695378b567df1fe6631c6684fcc9eeb4257df70f Gitweb: https://git.kernel.org/tip/695378b567df1fe6631c6684fcc9eeb4257df70f Author: Leo Yan AuthorDate: Wed, 19 Feb 2020 10:18:10 +08:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Wed, 11 Mar 2020 10:48:44 -03:00 perf cs-etm: Optimize copying last branches If an instruction range packet can generate multiple instruction samples, these samples share the same last branches; it's not necessary to copy the same last branches repeatedly for these samples within the same packet. This patch moves out the last branches copying from function cs_etm__synth_instruction_sample(), and execute it prior to generating instruction samples. Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Reviewed-by: Mike Leach Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Robert Walker Cc: Suzuki Poulouse Cc: coresight ml Cc: linux-arm-kernel@lists.infradead.org Link: http://lore.kernel.org/lkml/20200219021811.20067-5-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 1ddcc67..87d9943 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1151,10 +1151,8 @@ static int cs_etm__synth_instruction_sample(struct cs_etm_queue *etmq, cs_etm__copy_insn(etmq, tidq->trace_chan_id, tidq->packet, &sample); - if (etm->synth_opts.last_branch) { - cs_etm__copy_last_branch_rb(etmq, tidq); + if (etm->synth_opts.last_branch) sample.branch_stack = tidq->last_branch; - } if (etm->synth_opts.inject) { ret = cs_etm__inject_event(event, &sample, @@ -1431,6 +1429,10 @@ static int cs_etm__sample(struct cs_etm_queue *etmq, u64 offset = etm->instructions_sample_period - instrs_prev; u64 addr; + /* Prepare last branches for instruction sample */ + if (etm->synth_opts.last_branch) + cs_etm__copy_last_branch_rb(etmq, tidq); + while (tidq->period_instructions >= etm->instructions_sample_period) { /* @@ -1508,6 +1510,11 @@ static int cs_etm__flush(struct cs_etm_queue *etmq, if (etmq->etm->synth_opts.last_branch && tidq->prev_packet->sample_type == CS_ETM_RANGE) { + u64 addr; + + /* Prepare last branches for instruction sample */ + cs_etm__copy_last_branch_rb(etmq, tidq); + /* * Generate a last branch event for the branches left in the * circular buffer at the end of the trace. @@ -1515,7 +1522,7 @@ static int cs_etm__flush(struct cs_etm_queue *etmq, * Use the address of the end of the last reported execution * range */ - u64 addr = cs_etm__last_executed_instr(tidq->prev_packet); + addr = cs_etm__last_executed_instr(tidq->prev_packet); err = cs_etm__synth_instruction_sample( etmq, tidq, addr, @@ -1560,11 +1567,16 @@ static int cs_etm__end_block(struct cs_etm_queue *etmq, */ if (etmq->etm->synth_opts.last_branch && tidq->prev_packet->sample_type == CS_ETM_RANGE) { + u64 addr; + + /* Prepare last branches for instruction sample */ + cs_etm__copy_last_branch_rb(etmq, tidq); + /* * Use the address of the end of the last reported execution * range. */ - u64 addr = cs_etm__last_executed_instr(tidq->prev_packet); + addr = cs_etm__last_executed_instr(tidq->prev_packet); err = cs_etm__synth_instruction_sample( etmq, tidq, addr,