Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4555964imm; Wed, 30 May 2018 07:46:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLUfCY9N3yGOLMQv5+zRyEMLLOyHjqzmvUSe6u7x8ammSB0N2ZEjDBDZe+GLwd7P6xet54U X-Received: by 2002:a62:4a88:: with SMTP id c8-v6mr3060858pfj.23.1527691604517; Wed, 30 May 2018 07:46:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527691604; cv=none; d=google.com; s=arc-20160816; b=QK1K9LgI6OChCWaUlFB0J3JWFl4qi0SI87wyvJVk7X2pC97w5czQjf1jr/J8lYiA+Q PprXm/JpLWLrXq41eujdDc/TlJISGKfuh+f2KHp3Rl5Y3XHew6mpX/XfQwU2kvjFyBkf fgyp3uGQVV6MHFDYkyRO/s5tRnroCvLwXpZL73+MzVlSFIuOkstjrcHN5/onXUMF6Zv4 dYgCAhYRMNV880CH4Plx0qKi+wLDOchklkeOggZTRLmhJSBhZlgJNdqX/Swr3hko/1zj 76DrUzlzmz4rUzmE2ZKk6QeDNlZMLXn7XBgJrWRtZVf8X2OmIH9PbXFzMUK9LL8ueBhn qm5Q== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=DLMyEvn2brIGrBAlMpQYJRwQGBNc/DVRrryEbE4tHpY=; b=Ja890BFu5VHDVH42BcuN8gT79yOOIk+OyTqi3yYdgxMakOOl0uS+OJgTnVCLvvYVLF Mag4tv11oTEaf4TUTPrXNvjMuHgw6nSY8tIRMe05x4U2qTUCUkFifynNGnpbvxmcwHIk EDGJH5P4N2u8PAwLh64kfr3FuIi38jLvCFeYFiT6AWDU4QlV10gQKoJo9MqRE/bxLiQe 1LPlgYI+Pgq/9xLdFkFiLgTmBhkF+tQgULav2QC6nHgq1LVjVPwjyzfTvVGXnPcYULcX 5B3ZdDvW59KnYVY60hABYPyIF8bp+0ojxl9JGcej7brobvh7eAUhP/LzzgVA83WB0hrP bXaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PPlA9+MB; 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 r4-v6si27687508pgp.103.2018.05.30.07.46.30; Wed, 30 May 2018 07:46:44 -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=PPlA9+MB; 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 S1753081AbeE3Opv (ORCPT + 99 others); Wed, 30 May 2018 10:45:51 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:52730 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751630AbeE3Ops (ORCPT ); Wed, 30 May 2018 10:45:48 -0400 Received: by mail-wm0-f65.google.com with SMTP id 18-v6so42830202wml.2 for ; Wed, 30 May 2018 07:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=DLMyEvn2brIGrBAlMpQYJRwQGBNc/DVRrryEbE4tHpY=; b=PPlA9+MBvFZZSHhcPDZB0hdKtMS3fzKEcQ45goiEImNmfQIrPYhDPv4wxOQuvYu+Gd PUxuexijTSswCjW9g8M1Uxud3tKjDf5b+oaifOiJX8Y2FQJdXygM9dUtI1s8DggyedDn StyAeOFeNDUcmSfZTW7TXtGfVymOI1lrNaxn4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=DLMyEvn2brIGrBAlMpQYJRwQGBNc/DVRrryEbE4tHpY=; b=AdfMSxltrKU5PLAppIAQa2q/2/E64Dl2p5/cgmh44KlI3OSFvnd+OmYAvT7WTAmRAj 9bRquKDchbD3CxqbnAjPyAPC2xXNSEv+t+Z7TJUeWHLG07tGq8iU7xYIAVWV1w/qL+lR FaHptAfKuxYAsPrHq43FcCGXxB95JNkYiHs9J43X+EEW87fW1QrosDUZcjQtQcLJ/soc RM5UiIy5j+0BkYW6RXsd94AAOH3uRigdPgkzLmNb4aOrxXkmPxC5Ij8pYMcukDA662SS k37DNjmhPRfRgfvIU3xSQPDwWX9D+A+AOJOSBW53phg6SAWNGRU4B7Xjg5te3N1Abk2O msJw== X-Gm-Message-State: ALKqPweEbcPE8Jbfp0QqDBFd/1rbWOmNmZwjXnGtWlb+c8FnxHJ5GMmJ JfevsnfflTuIDqJRHbaaKjzUfkYhtlvhvSIZxJe2yg== X-Received: by 2002:a50:b36a:: with SMTP id r39-v6mr3813016edd.145.1527691547144; Wed, 30 May 2018 07:45:47 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a50:a4a1:0:0:0:0:0 with HTTP; Wed, 30 May 2018 07:45:46 -0700 (PDT) In-Reply-To: <20180530002837.GB11923@leoy-ThinkPad-X240s> References: <1527497103-3593-1-git-send-email-leo.yan@linaro.org> <1527497103-3593-2-git-send-email-leo.yan@linaro.org> <20180528221347.GA4109@xps15> <20180529002538.GA11317@leoy-ThinkPad-X240s> <20180530002837.GB11923@leoy-ThinkPad-X240s> From: Mathieu Poirier Date: Wed, 30 May 2018 08:45:46 -0600 Message-ID: Subject: Re: [RFT v3 1/4] perf cs-etm: Generate branch sample for missed packets To: Leo Yan Cc: Arnaldo Carvalho de Melo , Jonathan Corbet , Robert Walker , Mike Leach , Kim Phillips , Tor Jeremiassen , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel , "open list:DOCUMENTATION" , Linux Kernel Mailing List , coresight@lists.linaro.org 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 29 May 2018 at 18:28, Leo Yan wrote: > Hi Mathieu, > > On Tue, May 29, 2018 at 10:04:49AM -0600, Mathieu Poirier wrote: > > [...] > >> > As now this patch is big with more complex logic, so I consider to >> > split it into small patches: >> > >> > - Define CS_ETM_INVAL_ADDR; >> > - Fix for CS_ETM_TRACE_ON packet; >> > - Fix for exception packet; >> > >> > Does this make sense for you? I have concern that this patch is a >> > fixing patch, so not sure after spliting patches will introduce >> > trouble for applying them for other stable kernels ... >> >> Reverse the order: >> >> - Fix for CS_ETM_TRACE_ON packet; >> - Fix for exception packet; >> - Define CS_ETM_INVAL_ADDR; >> >> But you may not need to - see next comment. > > From the discussion context, I think here 'you may not need to' is > referring to my concern for applying patches on stable kernel, so I > should take this patch series as an enhancement and don't need to > consider much for stable kernel. Yes, that is what I meant. > > On the other hand, your suggestion is possible to mean 'not need > to' split into small patches (though I guess this is misunderstanding > for your meaning). > > Could you clarify which is your meaning? > >> >> > + >> >> > + /* >> >> > * The packet records the execution range with an exclusive end address >> >> > * >> >> > * A64 instructions are constant size, so the last executed >> >> > @@ -505,6 +519,18 @@ static inline u64 cs_etm__last_executed_instr(struct cs_etm_packet *packet) >> >> > return packet->end_addr - A64_INSTR_SIZE; >> >> > } >> >> > >> >> > +static inline u64 cs_etm__first_executed_instr(struct cs_etm_packet *packet) >> >> > +{ >> >> > + /* >> >> > + * The packet is the CS_ETM_TRACE_ON packet if the start_addr is >> >> > + * magic number 0xdeadbeefdeadbeefUL, returns 0 for this case. >> >> > + */ >> >> > + if (packet->start_addr == 0xdeadbeefdeadbeefUL) >> >> > + return 0; >> >> >> >> Same comment as above. >> > >> > Will do this. >> > >> >> > + >> >> > + return packet->start_addr; >> >> > +} >> >> > + >> >> > static inline u64 cs_etm__instr_count(const struct cs_etm_packet *packet) >> >> > { >> >> > /* >> >> > @@ -546,7 +572,7 @@ static void cs_etm__update_last_branch_rb(struct cs_etm_queue *etmq) >> >> > >> >> > be = &bs->entries[etmq->last_branch_pos]; >> >> > be->from = cs_etm__last_executed_instr(etmq->prev_packet); >> >> > - be->to = etmq->packet->start_addr; >> >> > + be->to = cs_etm__first_executed_instr(etmq->packet); >> >> > /* No support for mispredict */ >> >> > be->flags.mispred = 0; >> >> > be->flags.predicted = 1; >> >> > @@ -701,7 +727,7 @@ static int cs_etm__synth_branch_sample(struct cs_etm_queue *etmq) >> >> > sample.ip = cs_etm__last_executed_instr(etmq->prev_packet); >> >> > sample.pid = etmq->pid; >> >> > sample.tid = etmq->tid; >> >> > - sample.addr = etmq->packet->start_addr; >> >> > + sample.addr = cs_etm__first_executed_instr(etmq->packet); >> >> > sample.id = etmq->etm->branches_id; >> >> > sample.stream_id = etmq->etm->branches_id; >> >> > sample.period = 1; >> >> > @@ -897,13 +923,28 @@ static int cs_etm__sample(struct cs_etm_queue *etmq) >> >> > etmq->period_instructions = instrs_over; >> >> > } >> >> > >> >> > - if (etm->sample_branches && >> >> > - etmq->prev_packet && >> >> > - etmq->prev_packet->sample_type == CS_ETM_RANGE && >> >> > - etmq->prev_packet->last_instr_taken_branch) { >> >> > - ret = cs_etm__synth_branch_sample(etmq); >> >> > - if (ret) >> >> > - return ret; >> >> > + if (etm->sample_branches && etmq->prev_packet) { >> >> > + bool generate_sample = false; >> >> > + >> >> > + /* Generate sample for start tracing packet */ >> >> > + if (etmq->prev_packet->sample_type == 0 || >> >> >> >> What kind of packet is sample_type == 0 ? >> > >> > Just as explained above, sample_type == 0 is the packet which >> > initialized in the function cs_etm__alloc_queue(). >> > >> >> > + etmq->prev_packet->sample_type == CS_ETM_TRACE_ON) >> >> > + generate_sample = true; >> >> > + >> >> > + /* Generate sample for exception packet */ >> >> > + if (etmq->prev_packet->exc == true) >> >> > + generate_sample = true; >> >> >> >> Please don't do that. Exception packets have a type of their own and can be >> >> added to the decoder packet queue the same way INST_RANGE and TRACE_ON packets >> >> are. Moreover exception packet containt an address that, if I'm reading the >> >> documenation properly, can be used to keep track of instructions that were >> >> executed between the last address of the previous range packet and the address >> >> executed just before the exception occurred. Mike and Rob will have to confirm >> >> this as the decoder may be doing all that hard work for us. >> > >> > Sure, will wait for Rob and Mike to confirm for this. >> > >> > At my side, I dump the packet, the exception packet isn't passed to >> > cs-etm.c layer, the decoder layer only sets the flag >> > 'packet->exc = true' when exception packet is coming [1]. >> >> That's because we didn't need the information. Now that we do a >> function that will insert a packet in the decoder packet queue and >> deal with the new packet type in the main decoder loop [2]. At that >> point your work may not be eligible for stable anymore and I think it >> is fine. Robert's work was an enhancement over mine and yours is an >> enhancement over his. >> >> [2]. https://elixir.bootlin.com/linux/v4.17-rc7/source/tools/perf/util/cs-etm.c#L999 > > Agree, will look into for exception packet and try to add new packet > type for this. > > [...] > > Thanks, > Leo Yan