From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A4649CEBF78 for ; Fri, 27 Sep 2024 06:16:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NxohBDjhEG7fpEpxa1XN13Rpwpi0QMvbpQDA8viZCHg=; b=L5+ALCwmOafP9vS2A5XnBHlgIH 9idrK9+7bePT8n1oy6QMjf3aUpL9eQkSt/AiGw5YXOtDRBw2mwRyA6iCpkFv58s+gFpMfNYssNRht pL3gxFY05iYkQ7qAammn6WWALfr47SWkqVaWFTNjwxgO+Vpiapj4QXnDJL8+WY/KY30oOf+bnizeR t3/ayXo9vbfggY8jKk1bw1MsF3Wem4UbCQw0OaZeAKxfkBfnEBQNjqmPrT8EXFXl5cnjNx2fyDLIi VIwJjkJGRW+JyVcUK0UV38vjkQ465MGsUOxMXIgNVNKs0BEVZHS2pDADnd4TQf/7s25JF6uFCZ0mp OJAplg/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1su4Ge-0000000AADL-1Z3O; Fri, 27 Sep 2024 06:15:52 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1su4FR-0000000AA53-41nz for linux-arm-kernel@lists.infradead.org; Fri, 27 Sep 2024 06:14:39 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E4C2C5C54A7; Fri, 27 Sep 2024 06:14:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20846C4CEC4; Fri, 27 Sep 2024 06:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727417676; bh=dFnWqptwa4g51o3f5qA3cLBhc9QW7+s/c66VdIOj98s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A/Fjykn3UAi3C2DfhaZB4g8EJs4SH6mChYov00It07qrs0zaQn+5KggFJpw0b5YTk gMyAbCT3fCR+5LvM2QrL/k6Oz75sB40QBsDuAz8lpbA8/V55Se1+Kgd/NWA8WJDDk1 usbsDMp+Bh0DaritjtVoAt5vepO9Zmd7iPAacQum2YFre74hH/7P61Tu5xgfG2ygG1 GqGVWY2TzZ0HThoO9awfBHcgZQ57mbuXTCzELcqYZaW559JRjQFEhhdQMsWDy/3dX2 2q1xZ1aBkmBXaP/TRSMj/pY4JWJkZgfxThZf55yy4KtAg2bA8xRQSW+XVR3msLc/rg l1SYyfC/yqnnw== Date: Thu, 26 Sep 2024 23:14:34 -0700 From: Namhyung Kim To: Leo Yan Cc: Arnaldo Carvalho de Melo , James Clark , Mike Leach , Will Deacon , Mark Rutland , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/5] perf arm-spe: Calculate meta data size Message-ID: References: <20240914215458.751802-1-leo.yan@arm.com> <20240914215458.751802-3-leo.yan@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240914215458.751802-3-leo.yan@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240926_231438_113609_B9426EE3 X-CRM114-Status: GOOD ( 24.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Sep 14, 2024 at 10:54:55PM +0100, Leo Yan wrote: > The metadata is designed to contain a header and per CPU information. > > The arm_spe_find_cpus() function is introduced to identify how many CPUs > support ARM SPE. Based on the CPU number, calculates the metadata size. > > Signed-off-by: Leo Yan > --- > tools/perf/arch/arm64/util/arm-spe.c | 35 +++++++++++++++++++++++++--- > 1 file changed, 32 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c > index c2d5c8ca4900..15478989ef30 100644 > --- a/tools/perf/arch/arm64/util/arm-spe.c > +++ b/tools/perf/arch/arm64/util/arm-spe.c > @@ -37,11 +37,40 @@ struct arm_spe_recording { > bool *wrapped; > }; > > +static struct perf_cpu_map *arm_spe_find_cpus(struct evlist *evlist) Please add a comment that it returns a new cpu map, and caller should release the reference after use. > +{ > + struct perf_cpu_map *event_cpus = evlist->core.user_requested_cpus; > + struct perf_cpu_map *online_cpus = perf_cpu_map__new_online_cpus(); > + struct perf_cpu_map *intersect_cpus; > + > + /* cpu map is not "any" CPU , we have specific CPUs to work with */ > + if (!perf_cpu_map__has_any_cpu(event_cpus)) { > + intersect_cpus = perf_cpu_map__intersect(event_cpus, online_cpus); > + perf_cpu_map__put(online_cpus); > + /* Event can be "any" CPU so count all CPUs. */ > + } else { > + intersect_cpus = online_cpus; > + } > + > + return intersect_cpus; > +} > + > static size_t > arm_spe_info_priv_size(struct auxtrace_record *itr __maybe_unused, > - struct evlist *evlist __maybe_unused) > + struct evlist *evlist) > { > - return ARM_SPE_AUXTRACE_V1_PRIV_SIZE; > + struct perf_cpu_map *cpu_map = arm_spe_find_cpus(evlist); > + size_t size; > + > + if (!cpu_map) > + return 0; > + > + size = ARM_SPE_AUXTRACE_PRIV_MAX + > + ARM_SPE_CPU_PRIV_MAX * perf_cpu_map__nr(cpu_map); > + size *= sizeof(u64); > + > + perf_cpu_map__put(cpu_map); > + return size; > } > > static int arm_spe_info_fill(struct auxtrace_record *itr, > @@ -53,7 +82,7 @@ static int arm_spe_info_fill(struct auxtrace_record *itr, > container_of(itr, struct arm_spe_recording, itr); > struct perf_pmu *arm_spe_pmu = sper->arm_spe_pmu; > > - if (priv_size != ARM_SPE_AUXTRACE_V1_PRIV_SIZE) > + if (priv_size != arm_spe_info_priv_size(itr, session->evlist)) > return -EINVAL; > > if (!session->evlist->core.nr_mmaps) > -- > 2.34.1 >