Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3965574pxb; Fri, 11 Feb 2022 11:45:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYf35FTbwcsN9AXuj+hrzfYS61EY1KYcumQ44M/gb5LZcYf6CHbaLEDjAc5Zx207cDab5C X-Received: by 2002:a63:4903:: with SMTP id w3mr2621780pga.5.1644608708408; Fri, 11 Feb 2022 11:45:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644608708; cv=none; d=google.com; s=arc-20160816; b=jhA6qL6BhNS+wWaAOJ3rUvBofEAWI8nT0FsUSraFnILRCuW0JLq3JMXmHNDPr25iLW 9k2M9nckhtDNYvQJe28ZhhrhIQNiYuyN/e/NuY8oCu/lre/wqMtPXqtEqTWatFzUqwqq xpBYmAuNp7/Zi50+iAZrpRdj1NpjXZaAYKeGvy0HLcxF4pNHFPpRfAIROJdl4HNVOx4I BqQdQbSF26bKKdlzp1X46UuvqhkVszcCXhJnUlWucQLm+f2jNMpCLWUnq0MclQIWcLIi u4qpZ8B4JC4UuwWcD6UW7Mj0FJIZsnTnLtZXqYMsvIDgXyNFWroZBQ6WAEd2s3n0qq2+ vCSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=csB5DuqtfIDJ9EKSK8fiwWzQpRbB0qD6Vp/GW/qS/YQ=; b=uvml2Ze0SqSz7+RSOwfxH32ifqhokZM7L+UC3zoAIcZ6esyro+sc66g8zQxbLP6rkg +qubxn/ZVXtWUZnKNFvHYuuaCVB1+7y/OJjZ/SPxEv5OCm7nEmbwxAVZ0kCWGaHpdtSs ka+qZSvW2d2em+aEXrrt6PbNCd7Q28xYIU/K5p66E8bb9EnklFZ1sWZkOsb7x8MUE4iq BvfJQdEvIYV15Qfi9SkHQiTr0tAnaQH0F0aqbZkvOKbjca3Viyi3Ixwbrc+QeRhrh9TA hubwjkm65KFJaF8aq/SIz78MEPQPYJ49sIeYZq8K99vHyYQvDrqyZVYurB/tPFJVKOF1 lfIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=grEYtNAo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g22si22931273pfv.115.2022.02.11.11.44.52; Fri, 11 Feb 2022 11:45:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=grEYtNAo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1350165AbiBKQF3 (ORCPT + 99 others); Fri, 11 Feb 2022 11:05:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350145AbiBKQF0 (ORCPT ); Fri, 11 Feb 2022 11:05:26 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD429D82 for ; Fri, 11 Feb 2022 08:05:24 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id h22so5812728ejl.12 for ; Fri, 11 Feb 2022 08:05:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=csB5DuqtfIDJ9EKSK8fiwWzQpRbB0qD6Vp/GW/qS/YQ=; b=grEYtNAoCYLkvBJEJgtJxnsTjxHc/cgpoV/QsJ19fyD5CPUsYizKM6gFegxVCO//Mm D8jAgZaBtnMbVMY7/IWuYayVDI/OH/cpqxeyW2R8ibZpnkkkzEY+zsBlgU1tLjRd8EDb hZlL83Q1UxrbIZHykr0xKJbiqE0qz38TTXFw6xoFzInhDy8Qe3vMx+4nSBQXPhE4oBgl I1hbu0VXWqMnD4IqElhASijRmdRvHCB/ZuhESFpEUu7EYyW6F+cdnY2Axi4+ElKljMSt zEWM6e9mBfNF/9Om96x819gasq0kLF7VNBubi3YnqQI8X+tqzsT9skc1OTJn8lYhWjTR gRgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=csB5DuqtfIDJ9EKSK8fiwWzQpRbB0qD6Vp/GW/qS/YQ=; b=zMMvHIstGbIYcZpbIOGCns3ZRCXluCtgU06zg8S1P4EAKuav8nP945YP2/uFvd2EEP Y61tgP+U6Uvx54ji60D4HunRd9embUncXY6+tCt/re/goKBew5M6QoJaElMjme4AqB8j xvF3YLKyUm4a4P7FrPIs/yzPgtmAS1RNNXjJK65U9U07P3DpwHc5ilJcWXgZZGzCFMFW 2Rj2+C7GsJD/rWLBhphIeERJ2CA0loeWqcHwqm5P4lxO/sFkChap3A9vTnNEYDXcHzaH bCHh+EQuxTqQOM/uqJmSO53eu7Wfff263IqotIKNeCtimOk8yG1PaHC/M6NzKPU5n9Lb cSxQ== X-Gm-Message-State: AOAM532hN8RZcFuVOwn9mJzDahBzgInGJhjcbdRZqj37ud+4Aw0svOcA 3pSyfpWWVsgvRUmdrJ9p8glPtQ== X-Received: by 2002:a17:906:58cc:: with SMTP id e12mr2008984ejs.162.1644595523236; Fri, 11 Feb 2022 08:05:23 -0800 (PST) Received: from leoy-ThinkPad-X240s ([104.245.96.223]) by smtp.gmail.com with ESMTPSA id p19sm8062729ejc.42.2022.02.11.08.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 08:05:22 -0800 (PST) Date: Sat, 12 Feb 2022 00:05:16 +0800 From: Leo Yan To: James Clark Cc: acme@kernel.org, linux-perf-users@vger.kernel.org, mathieu.poirier@linaro.org, coresight@lists.linaro.org, Mike Leach , John Garry , Will Deacon , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] perf: cs-etm: Fix corrupt inject files when only last branch option is enabled Message-ID: <20220211160516.GD475776@leoy-ThinkPad-X240s> References: <20220210200620.1227232-1-james.clark@arm.com> <20220210200620.1227232-2-james.clark@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220210200620.1227232-2-james.clark@arm.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 10, 2022 at 08:06:20PM +0000, James Clark wrote: > Perf inject with Coresight data generates files that cannot be opened > when only the last branch option is specified: > > perf inject -i perf.data --itrace=l -o inject.data > perf script -i inject.data > 0x33faa8 [0x8]: failed to process type: 9 [Bad address] > > This is because cs_etm__synth_instruction_sample() is called even when > the sample type for instructions hasn't been setup. Last branch records > are attached to instruction samples so it doesn't make sense to generate > them when --itrace=i isn't specified anyway. > > This change disables all calls of cs_etm__synth_instruction_sample() > unless --itrace=i is specified, resulting in a file with no samples if > only --itrace=l is provided, rather than a bad file. > > Signed-off-by: James Clark Reviewed-by: Leo Yan > --- > tools/perf/util/cs-etm.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > index 796a065a500e..8b95fb3c4d7b 100644 > --- a/tools/perf/util/cs-etm.c > +++ b/tools/perf/util/cs-etm.c > @@ -1553,6 +1553,7 @@ static int cs_etm__flush(struct cs_etm_queue *etmq, > goto swap_packet; > > if (etmq->etm->synth_opts.last_branch && > + etmq->etm->synth_opts.instructions && > tidq->prev_packet->sample_type == CS_ETM_RANGE) { > u64 addr; > > @@ -1610,6 +1611,7 @@ static int cs_etm__end_block(struct cs_etm_queue *etmq, > * the trace. > */ > if (etmq->etm->synth_opts.last_branch && > + etmq->etm->synth_opts.instructions && > tidq->prev_packet->sample_type == CS_ETM_RANGE) { > u64 addr; > > -- > 2.28.0 >