Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2794622ybl; Mon, 19 Aug 2019 07:38:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvXYV9O13ChWk0TiBHlqkaRrIooEgDWiTsvkHaG0wA15ATpTq6KrAZlucsfFbXBiEF6Y/L X-Received: by 2002:a62:e401:: with SMTP id r1mr25206840pfh.193.1566225485308; Mon, 19 Aug 2019 07:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566225485; cv=none; d=google.com; s=arc-20160816; b=wtIW5nlM4OPzGYgSVBEvp3qqheZ7Oc5YIgZSEAt4e8gYG2IcxB6EpQo6YGKlhltE+V OS4mqmWczJjutgP0zuL25SMMN5OLhi5ppTs13lrHRN59ZIHGfACqBTfg/16qKNgHqi9i Yg7QaM4MReajblDE7L6ks9kVfCLSIJn9j5DFhOoCrIEGiba0s61npHFa95/2a+ueWnou m3ueUUzCRkpLqJmZUQEUAB1Vq8LQCCjzDIRc431XNm8DMw/fQKZ6iDXfabnByBEgOmlf nRnJ7So0+tVbpH2e+904scDvX6wy1mnQo9oNAm2jTfgu1+8lDudL5PTW8f/aITaLBVU0 8JZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=iFql09aYcbuPzPRNNxnVYR/hsgoCVkgeaLnrJBlkInE=; b=rehzUGhYYIsX4PIYcraQe/IZd/Ru+zm3wUNbf6MLpBkqXSphxNko6Qq2W6Z598k4UG kKJZnn26dl2VPIRAbtf5w+8w2MmbVKjEaDQWipgPmUbFgkdOfhDXaaBUuYCpsrIrsirA 4igocrCeA2UchsX3Fqdv9JpTQSunGS8pfYOKqbbfrzcYpG4kQoe89haKeq6Slx+XzIGf lCu+4Hu2xo6xBLsJ6bSIkRanSOdmGHDf0owN82vHnZK7NV+r6UUJnAFc/D6SyLfVt9FF TESmncbOhknNZp19vtO6m84UHzPnPeDw+fFJ3olx/PG2TUxFuUId+CrPBxReH415wL1h YEpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hZ0/K+8m"; 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 t1si8881007pjy.39.2019.08.19.07.37.50; Mon, 19 Aug 2019 07:38:05 -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="hZ0/K+8m"; 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 S1727268AbfHSOgq (ORCPT + 99 others); Mon, 19 Aug 2019 10:36:46 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:41663 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726654AbfHSOgq (ORCPT ); Mon, 19 Aug 2019 10:36:46 -0400 Received: by mail-io1-f66.google.com with SMTP id j5so4729752ioj.8 for ; Mon, 19 Aug 2019 07:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iFql09aYcbuPzPRNNxnVYR/hsgoCVkgeaLnrJBlkInE=; b=hZ0/K+8mp3EUZ2oVc6YBrrwM+NY5lrxsoN/bHpXw9ccgPD0KXXZoiHJt2JSw+AA1UH RDw7F+gixHjtULxlpNnjMJ9cOwEYrN68BTFX4MbTNKrjpbr2Dvc+zLmPz075TrejNJPs 8V86xo6hVlIeTK402ASR8wrBOlTk8W8MzI3+lagfQDzYWKjJcwqubdgGEmBSd06Q37B0 h3G7WAn4oKLCR7Ij4+epGx+eirKb+ON4L+S6moIhGxSxEIeN/Y5SIriF/eSCL4bu5D9M az7QG2ELlpdcHvqRRl8MRbg31faL8wFJBGeMdBhhuIoxOiquxv6+6zwY/74E0nzCO6t/ qtXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iFql09aYcbuPzPRNNxnVYR/hsgoCVkgeaLnrJBlkInE=; b=Kx9dKd/+z+oSNOSmvqpqtajRdnnpikUG4cIWAsIMh7OWLR/9KXRG8jq1Axeel4zCbC SJ9wsKelLWFqcCdzZn3VZ+4UsBfOclLoK6AcnQhoPPbt7ibk5+LnrwV7AzAeO2rg7IWH ZcOC4hecS05smMvzS0ZEu9wnyXDGJHcE2HUtdJo6JejWkFaZx8tSPrRDt3yue4tH8BHG m5DzVSDoYg6gSSuzMyQVs8F85K/IO9z/4rzZM02b0UrscG4ZQ04DSfmAVOQSwPqBqDAk Fs4XlnqMTp/BV7pVOvgPzflsFhfWA1SFM0ff4XRggKYDKA9cr3qQfbEC57BsPxk0COp4 MvjQ== X-Gm-Message-State: APjAAAWb5vCBM31X5i50K1h713sYf8gy/JxNnvBN1W56zy1TXiZ98W9s AQryMlO2h1BJW76DbQT/nT3nlDKsGEyM4+oDWhZPpA== X-Received: by 2002:a5d:8854:: with SMTP id t20mr250833ios.50.1566225405381; Mon, 19 Aug 2019 07:36:45 -0700 (PDT) MIME-Version: 1.0 References: <20190815082854.18191-1-leo.yan@linaro.org> <20190819142321.GB29674@kernel.org> In-Reply-To: <20190819142321.GB29674@kernel.org> From: Mathieu Poirier Date: Mon, 19 Aug 2019 08:36:34 -0600 Message-ID: Subject: Re: [PATCH 1/2] perf cs-etm: Support sample flags 'insn' and 'insnlen' To: Arnaldo Carvalho de Melo Cc: Leo Yan , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Suzuki K Poulose , linux-arm-kernel , Linux Kernel Mailing List , Mike Leach , Robert Walker , Coresight ML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 19 Aug 2019 at 08:23, Arnaldo Carvalho de Melo wrote: > > Em Thu, Aug 15, 2019 at 04:28:54PM +0800, Leo Yan escreveu: > > The synthetic branch and instruction samples are missed to set > > instruction related info, thus perf tool fails to display samples with > > flags '-F,+insn,+insnlen'. > > > > CoreSight trace decoder has provided sufficient information to decide > > the instruction size based on the isa type: A64/A32 instruction are > > 32-bit size, but one exception is the T32 instruction size, which might > > be 32-bit or 16-bit. > > > > This patch handles for these cases and it reads the instruction values > > from DSO file; thus can support flags '-F,+insn,+insnlen'. > > Mathieu, can I have your Acked-by/Reviewed-by? Yes, as soon as I have the opportunity to test it. > > - Arnaldo > > > 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 > > > > [...] > > > > Cc: Mathieu Poirier > > Cc: Suzuki Poulouse > > Cc: Mike Leach > > Cc: Robert Walker > > Cc: coresight@lists.linaro.org > > Cc: linux-arm-kernel@lists.infradead.org > > Signed-off-by: Leo Yan > > --- > > 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 ed6f7fd5b90b..b3a5daaf1a8f 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 > > */ > > -- > > 2.17.1 > > -- > > - Arnaldo