Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2894816rwr; Fri, 28 Apr 2023 19:00:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7FjAA0c1cUGsCYgvsoB5cOvgLNc25xdr0BPe88LvM6riRdFtOClQouZ66s3JUCqZYBOlXP X-Received: by 2002:a17:902:ec81:b0:1a6:6edd:d143 with SMTP id x1-20020a170902ec8100b001a66eddd143mr5325632plg.6.1682733607542; Fri, 28 Apr 2023 19:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682733607; cv=none; d=google.com; s=arc-20160816; b=iNNmEbu34F9p0SeF48S8x0Nz31eMA17FJQaCibCeFtEpsjDikDxV/bg2tP/XQPS2or iMrwU4Ev2xnChNHtB351cJFGqA9qKXaptcXLaGUvAGMqzoIz7220PvXGZLIXUYQ99gEh 3EeasfRWg8/eZiX/xc98APNQ48MqZrpZvE5QQWkPDTtjCl+GYiYR4EvErhq4qQY2Nwjs mdeFSGaCa+X8QHtA3v6rb+wjGK685s2D3xzHZOiOhR3r8VmRvndxXbC8icjgxnfsam7V kuBH8vDiTethwixhEnosNeIM7sfck8PHDUfsrOvpspFE9tHQcbXlLDWCPvNSEyEOrsvG BwEQ== 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=ayr7VbWMIwUcp6wwxuHnmNGUXgkPNo9SsjRh8F3lqDQ=; b=y+Dwwdt631HgPmTAQ44DAjQoC55jZziYr4aHGQKXw8SEQViKRZ6tAOMJgeP/y/3scJ of8im1aALep31IWbQgaboaEpKpxXfRG85/xTex5Xt+C0hvYfH33UcuOOY1PZM2Q3Cx4a JVgXH9wuPFawaa5e6OZ9108HX0NKEzc36xsiuHNd58I7EpoTv3KCH+FI0jj/D1nmnvmK h49lNrFjEqMmiWeGh1bYQ0BgHLc6GQZ8XC5sh2yaU255ynC4mPZ25o5+rY6KGa1Zq8nY aDxW+RGxJ73vkgiss/kqoyzHuq3m0hng/lD3jZyuN+3XZ+uNNnjtOsbb+GpCVU/knM7Y JtZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lH1LV7hO; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb5-20020a17090b4a4500b00246fe4e326dsi27487835pjb.81.2023.04.28.18.59.53; Fri, 28 Apr 2023 19:00:07 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=lH1LV7hO; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347312AbjD2B57 (ORCPT + 99 others); Fri, 28 Apr 2023 21:57:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347136AbjD2B56 (ORCPT ); Fri, 28 Apr 2023 21:57:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1BE430D2 for ; Fri, 28 Apr 2023 18:57:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 51B5B615E0 for ; Sat, 29 Apr 2023 01:57:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B93CC433D2; Sat, 29 Apr 2023 01:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682733473; bh=NAp4+2v3eip+oibXwCdkhIwyzFLv+Dzh8609RU3cAMw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lH1LV7hOINe+s4Nc6Vh7izu/VeGciWZ6/+7yFxrQ61VvXmkd1YnQ2BJbWJ4Rhf1uR pF+lEHLru31piB42pnenrgh/TyNjlUA8WWfzbOrja39p0adzvqLD5K0lgvcsSBBohA /G2Kt9fT9YqHMM1D08U+plAlvJLGhwiXej4k5fJwBPsJVwWam0BB5oF+aFAGn9bMRs kbkTUBswaH1KPUASvliMQ79PNwQL5lmEUPSuWolarMHu480kzCSPu5cqb/Vx/TYRko x6mvOFx/I/9JqFiaVpxxX26HY/L6YFQvyVsvsIKHVwpKRmiB7KPSvZozRFjwoYay/j ZL3BM6WJ9v50Q== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 2BB89403B5; Fri, 28 Apr 2023 22:57:51 -0300 (-03) Date: Fri, 28 Apr 2023 22:57:51 -0300 From: Arnaldo Carvalho de Melo To: Ganapatrao Kulkarni Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org, suzuki.poulose@arm.com, mathieu.poirier@linaro.org, darren@os.amperecomputing.com, scott@os.amperecomputing.com, scclevenger@os.amperecomputing.com Subject: Re: [PATCH V2] perf cs-etm: Add fix for coresight trace for any range of CPUs Message-ID: References: <20230421055253.83912-1-gankulkarni@os.amperecomputing.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230421055253.83912-1-gankulkarni@os.amperecomputing.com> X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Em Thu, Apr 20, 2023 at 10:52:53PM -0700, Ganapatrao Kulkarni escreveu: > The current implementation supports coresight trace decode for a range > of CPUs, if the first CPU is CPU0. > > Perf report segfaults, if tried for sparse CPUs list and also for > any range of CPUs(non zero first CPU). > > Adding a fix to perf report for any range of CPUs and for sparse list. Can some ARM people please review this? - Arnaldo > Signed-off-by: Ganapatrao Kulkarni > --- > > V2: > Updated with review comments. > Fixed for sparse list of CPUs also. > > V1: > [1] https://lore.kernel.org/lkml/20230419172101.78638-1-gankulkarni@os.amperecomputing.com/ > > tools/perf/util/cs-etm.c | 24 +++++++++++++++++++++++- > 1 file changed, 23 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > index 8dd81ddd9e4e..2003717f5779 100644 > --- a/tools/perf/util/cs-etm.c > +++ b/tools/perf/util/cs-etm.c > @@ -275,6 +275,25 @@ static int cs_etm__metadata_set_trace_id(u8 trace_chan_id, u64 *cpu_metadata) > (typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask)); \ > }) > > +/* > + * Get a metadata for a specific cpu from an array. > + * > + */ > +static u64 *get_cpu_data(struct cs_etm_auxtrace *etm, int cpu) > +{ > + int i; > + u64 *metadata = NULL; > + > + for (i = 0; i < etm->num_cpu; i++) { > + if (etm->metadata[i][CS_ETM_CPU] == (u64)cpu) { > + metadata = etm->metadata[i]; > + break; > + } > + } > + > + return metadata; > +} > + > /* > * Handle the PERF_RECORD_AUX_OUTPUT_HW_ID event. > * > @@ -344,8 +363,11 @@ static int cs_etm__process_aux_output_hw_id(struct perf_session *session, > return 0; > } > > + cpu_data = get_cpu_data(etm, cpu); > + if (cpu_data == NULL) > + return err; > + > /* not one we've seen before - lets map it */ > - cpu_data = etm->metadata[cpu]; > err = cs_etm__map_trace_id(trace_chan_id, cpu_data); > if (err) > return err; > -- > 2.39.2 > -- - Arnaldo