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 ABC81C7EE29 for ; Fri, 9 Jun 2023 13:15:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gKlSiW06sRfciG07SNeodhz8C/yifEIH+kJiURtadRk=; b=kWWkAdZeQrJWHY yIsrLCc/XEywfBdWfEOjvSxsxYWMycXpP8bbbW4MuQyee2OJYNMDEpyl6HetSIyxGJOhJjXDJ3zyN p4UIP2kybdbf9OBt2P+Ulq88lvjvmvIlbWm2y9Jrj3c40Sz56adlcstWyIjfD3eKFuS7Azbxqd3Hx pH/l2XETJ+orrQjCkWhTBZ6Qkz/ql2k3EIdPRng9cMD0kYstX7oXT9TeL2vIiAgWEN1UbyOBwUqvw BKuPy93oznwilTNjG8q2WfYZ9wukhyvHoqnCM99KCQ1y1EjOuvQ83S7usPS9RQPr59GPJCAEiwa3o CXJyP20pP6tNPCWCQLkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7bxR-00D6I4-1M; Fri, 09 Jun 2023 13:15:13 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7bxO-00D6H2-0T for linux-arm-kernel@lists.infradead.org; Fri, 09 Jun 2023 13:15:11 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 36C7BAB6; Fri, 9 Jun 2023 06:15:53 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.38.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE0123F71E; Fri, 9 Jun 2023 06:15:05 -0700 (PDT) Date: Fri, 9 Jun 2023 14:15:03 +0100 From: Mark Rutland To: Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, Mark Brown , James Clark , Rob Herring , Marc Zyngier , Suzuki Poulose , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , linux-perf-users@vger.kernel.org Subject: Re: [PATCH V11 06/10] arm64/perf: Enable branch stack events via FEAT_BRBE Message-ID: References: <20230531040428.501523-1-anshuman.khandual@arm.com> <20230531040428.501523-7-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230609_061510_272933_B25EC956 X-CRM114-Status: GOOD ( 23.31 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jun 09, 2023 at 01:47:18PM +0100, Mark Rutland wrote: > On Fri, Jun 09, 2023 at 10:52:37AM +0530, Anshuman Khandual wrote: > > On 6/5/23 19:13, Mark Rutland wrote: > > > Looking at I see: > > > > > > | /* > > > | * branch stack layout: > > > | * nr: number of taken branches stored in entries[] > > > | * hw_idx: The low level index of raw branch records > > > | * for the most recent branch. > > > | * -1ULL means invalid/unknown. > > > | * > > > | * Note that nr can vary from sample to sample > > > | * branches (to, from) are stored from most recent > > > | * to least recent, i.e., entries[0] contains the most > > > | * recent branch. > > > | * The entries[] is an abstraction of raw branch records, > > > | * which may not be stored in age order in HW, e.g. Intel LBR. > > > | * The hw_idx is to expose the low level index of raw > > > | * branch record for the most recent branch aka entries[0]. > > > | * The hw_idx index is between -1 (unknown) and max depth, > > > | * which can be retrieved in /sys/devices/cpu/caps/branches. > > > | * For the architectures whose raw branch records are > > > | * already stored in age order, the hw_idx should be 0. > > > | */ > > > | struct perf_branch_stack { > > > | __u64 nr; > > > | __u64 hw_idx; > > > | struct perf_branch_entry entries[]; > > > | }; > > > > > > ... which seems to indicate we should be setting hw_idx to 0, since IIUC our > > > records are in age order. > > Branch records are indeed in age order, sure will change hw_idx as 0. Earlier > > figured that there was no need for hw_idx and hence marked it as -1UL similar > > to other platforms like powerpc. > > That's fair enough; looking at power_pmu_bhrb_read() in > arch/powerpc/perf/core-book3s.c, I see a comment: > > Branches are read most recent first (ie. mfbhrb 0 is > the most recent branch). > > ... which suggests that should be 0 also, or that the documentation is wrong. > > Do you know how the perf tool consumes this? Thinking about this some more, if what this is saying is that if entries[0] must be strictly the last branch, and we've lost branches due to interrupt latency, then we clearly don't meet that requirement and must report -1ULL here. So while it'd be nice to figure this out, I'm happy using -1ULL, and would be a bit concerned using 0. Sorry for flip-flopping on this. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel