From patchwork Mon Nov 7 06:25:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 13033827 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 05A98C4332F for ; Mon, 7 Nov 2022 06:27:22 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FZDyUNDv+W/bT+PaP+lYLsXaVUb+28XUWa/uOWU2jvE=; b=VyMYo8PryMYNK0 9tDLu/pimlW+QT09/Y3is3RtATRApQacJICQs0YG/NVkTA1fJXHB+yvwU3BoItsyGZEXuKNTSCC2H 7O/dZD8Dbo3pLU6gJWKxegUT+ZQILZjYMRE0lUIrBT+JNJwWwu3IM2sBRzQpEzWwU1EI9Ri2CnhkN 6KKaPMVgESQq3fyYTPpp38VCwC5BnmwA6jEFFnYNjvmAOGmneUvTx8dO8uDL8pWY+ZfJxEszsRohg N9cyDVtXqXa4xJAgwUNZjfgZFIJwg+6Yan6mEpWuoIJ212wWhXJ5NLa5RyHgmZ2bumk0l+2DGi/uU n/h8jUGUu/o7N4yudZqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1orvaI-00C7Lt-4T; Mon, 07 Nov 2022 06:26:14 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1orvZz-00C7Ei-Rg for linux-arm-kernel@lists.infradead.org; Mon, 07 Nov 2022 06:25:57 +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 9001C1FB; Sun, 6 Nov 2022 22:25:58 -0800 (PST) Received: from a077893.blr.arm.com (unknown [10.162.42.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EEB0A3F534; Sun, 6 Nov 2022 22:25:47 -0800 (PST) From: Anshuman Khandual To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, peterz@infradead.org, acme@kernel.org, mark.rutland@arm.com, will@kernel.org, catalin.marinas@arm.com Cc: Anshuman Khandual , Mark Brown , James Clark , Rob Herring , Marc Zyngier , Suzuki Poulose , Ingo Molnar Subject: [PATCH V5 3/7] arm64/perf: Update struct pmu_hw_events for BRBE Date: Mon, 7 Nov 2022 11:55:10 +0530 Message-Id: <20221107062514.2851047-4-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221107062514.2851047-1-anshuman.khandual@arm.com> References: <20221107062514.2851047-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221106_222555_987997_D2CF511E X-CRM114-Status: GOOD ( 11.60 ) 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 A single perf event instance BRBE related contexts and data will be tracked in struct pmu_hw_events. Hence update the structure to accommodate required details related to BRBE. Cc: Will Deacon Cc: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- drivers/perf/arm_pmu.c | 1 + include/linux/perf/arm_pmu.h | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 3f07df5a7e95..5048a500441e 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -905,6 +905,7 @@ static struct arm_pmu *__armpmu_alloc(gfp_t flags) events = per_cpu_ptr(pmu->hw_events, cpu); raw_spin_lock_init(&events->pmu_lock); + events->branches = kmalloc(sizeof(struct brbe_records), flags); events->percpu_pmu = pmu; } diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index 67a6d59786f2..bda0d9984a98 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -44,6 +44,16 @@ static_assert((PERF_EVENT_FLAG_ARCH & ARMPMU_EVT_47BIT) == ARMPMU_EVT_47BIT); }, \ } +/* + * Maximum branch records in BRBE + */ +#define BRBE_MAX_ENTRIES 64 + +struct brbe_records { + struct perf_branch_stack brbe_stack; + struct perf_branch_entry brbe_entries[BRBE_MAX_ENTRIES]; +}; + /* The events for a given PMU register set. */ struct pmu_hw_events { /* @@ -70,6 +80,23 @@ struct pmu_hw_events { struct arm_pmu *percpu_pmu; int irq; + + /* Detected BRBE attributes */ + bool brbe_v1p1; + int brbe_cc; + int brbe_nr; + int brbe_format; + + /* Evaluated BRBE configuration */ + u64 brbfcr; + u64 brbcr; + + /* Tracked BRBE context */ + unsigned int brbe_users; + void *brbe_context; + + /* Captured BRBE buffer - copied as is into perf_sample_data */ + struct brbe_records *branches; }; enum armpmu_attr_groups {