Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp414655ybl; Fri, 23 Aug 2019 02:50:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFyULcTHvdSWB6AVYpXZdu6afMOdiGE7wOasubJzZtt9q8tjlOJxdGWfpFBdytb+t8PN4N X-Received: by 2002:a17:90a:1b24:: with SMTP id q33mr4226040pjq.80.1566553815495; Fri, 23 Aug 2019 02:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566553815; cv=none; d=google.com; s=arc-20160816; b=rZ3I8sXhnJcExdTeuvYpQS6PHE02+e1zNPVQfkqFWnqPCpkEsUpt6luSwakyFso8Yr Ufovi33TtR4p+gBSMBm0w4iFoSBsUl+A5n3AKLq4JW7Rv7bKF2CgNOKcMNJPzFI+s0Wr e+yVafv1ibTEh9vK2hzW90jnuFR4kFYx7dRJaOq9Wd0PRDprvOhapP9y8y0Y62un8303 a/fYevLHetJZoOM6QR2+rNCMNRobQqiz0A5GGN9ur2tXfekBR+wtI0Rc3OaJkrHj/fyW 1v1odiOA4Dwj0CJKDUE+VsFg4vLqrKq0FDzQbuYmHUfwq/xL+VMWKyGj3zGjkFxlnhaE 70cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:from:date; bh=XdDeR1bHpQPDvbZntBB9/08D4nxkhWOoxQX06jdmLAs=; b=sxl/ROl7o1EI/oPgGyzHWQfSwHEjKoghrRdu5RMJafAPFYYp5MNjDAtHPue7x5MD7h QHp005guDXqcXPx4juNDX5z6i1vwNwsHy+cM8Z8hTOunUaRU0NFftN5/9CvRYDosmxxq GWBFQ9zfOwLZkwBr4hju9UB1IjIhV1rZEbfa28s9hNonlfySdNBIP6O4KsEIyzp5/17S 3YwYzrbt2Uatw2RbpgX+ihZ4zJOJKhXdsz7tJY53Omv39s9IDH7LHuic+Bciv5u+jkIo yX73zfzqNSr6RwDMiYJwZ5zCByy/Of7u2gMbWj3Z07AAAxW9woSWunV/BABMCH41n6gW ypGQ== 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 33si2036184plv.189.2019.08.23.02.50.01; Fri, 23 Aug 2019 02:50:15 -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 S2390913AbfHWC2a (ORCPT + 99 others); Thu, 22 Aug 2019 22:28:30 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:33821 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390502AbfHWC23 (ORCPT ); Thu, 22 Aug 2019 22:28:29 -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 1i0zJA-00019X-TL; Fri, 23 Aug 2019 04:28:09 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 6DC2A1C0883; Fri, 23 Aug 2019 04:28:08 +0200 (CEST) Date: Fri, 23 Aug 2019 02:28:08 -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: Support sample flags 'insn' and 'insnlen' Cc: linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, Suzuki Poulouse , Robert Walker , Namhyung Kim , Mike Leach , Jiri Olsa , Alexander Shishkin , Mathieu Poirier , Leo Yan In-Reply-To: <20190815082854.18191-1-leo.yan@linaro.org> References: <20190815082854.18191-1-leo.yan@linaro.org> MIME-Version: 1.0 Message-ID: <156652728831.12701.17501120781804999488.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-Disposition: inline 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: a4973d8f7bea98a0795ba853e7bd2cef11363824 Gitweb: https://git.kernel.org/tip/a4973d8f7bea98a0795ba853e7bd2cef11363824 Author: Leo Yan AuthorDate: Thu, 15 Aug 2019 16:28:54 +08:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Tue, 20 Aug 2019 12:20:52 -03:00 perf cs-etm: Support sample flags 'insn' and 'insnlen' The synthetic branch and instruction samples are missed to set instruction related info, thus the perf tool fails to display samples with flags '-F,+insn,+insnlen'. The CoreSight trace decoder provides sufficient information to decide the instruction size based on the ISA type: A64/A32 instructions are 32-bit size, but one exception is the T32 instruction size, which might be 32-bit or 16-bit. This patch handles these cases and it reads the instruction values from DSO file; thus can support the flags '-F,+insn,+insnlen'. Before: # perf script -F,insn,insnlen,ip,sym 0 [unknown] ilen: 0 ffff97174044 _start ilen: 0 ffff97174938 _dl_start ilen: 0 ffff97174938 _dl_start ilen: 0 ffff97174938 _dl_start ilen: 0 ffff97174938 _dl_start ilen: 0 ffff97174938 _dl_start ilen: 0 ffff97174938 _dl_start ilen: 0 ffff97174938 _dl_start ilen: 0 ffff97174938 _dl_start ilen: 0 [...] After: # perf script -F,insn,insnlen,ip,sym 0 [unknown] ilen: 0 ffff97174044 _start ilen: 4 insn: 2f 02 00 94 ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54 ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54 ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54 ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54 ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54 ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54 ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54 ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54 [...] Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier Tested-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Mike Leach Cc: Namhyung Kim Cc: Robert Walker Cc: Suzuki Poulouse Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190815082854.18191-1-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index ed6f7fd..b3a5daa 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1076,6 +1076,35 @@ bool cs_etm__etmq_is_timeless(struct cs_etm_queue *etmq) return !!etmq->etm->timeless_decoding; } +static void cs_etm__copy_insn(struct cs_etm_queue *etmq, + u64 trace_chan_id, + const struct cs_etm_packet *packet, + struct perf_sample *sample) +{ + /* + * It's pointless to read instructions for the CS_ETM_DISCONTINUITY + * packet, so directly bail out with 'insn_len' = 0. + */ + if (packet->sample_type == CS_ETM_DISCONTINUITY) { + sample->insn_len = 0; + return; + } + + /* + * T32 instruction size might be 32-bit or 16-bit, decide by calling + * cs_etm__t32_instr_size(). + */ + if (packet->isa == CS_ETM_ISA_T32) + sample->insn_len = cs_etm__t32_instr_size(etmq, trace_chan_id, + sample->ip); + /* Otherwise, A64 and A32 instruction size are always 32-bit. */ + else + sample->insn_len = 4; + + cs_etm__mem_access(etmq, trace_chan_id, sample->ip, + sample->insn_len, (void *)sample->insn); +} + static int cs_etm__synth_instruction_sample(struct cs_etm_queue *etmq, struct cs_etm_traceid_queue *tidq, u64 addr, u64 period) @@ -1097,9 +1126,10 @@ static int cs_etm__synth_instruction_sample(struct cs_etm_queue *etmq, sample.period = period; sample.cpu = tidq->packet->cpu; sample.flags = tidq->prev_packet->flags; - sample.insn_len = 1; sample.cpumode = event->sample.header.misc; + 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); sample.branch_stack = tidq->last_branch; @@ -1159,6 +1189,9 @@ static int cs_etm__synth_branch_sample(struct cs_etm_queue *etmq, sample.flags = tidq->prev_packet->flags; sample.cpumode = event->sample.header.misc; + cs_etm__copy_insn(etmq, tidq->trace_chan_id, tidq->prev_packet, + &sample); + /* * perf report cannot handle events without a branch stack */