From patchwork Mon Oct 17 05:57:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 3212 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1289225wrs; Sun, 16 Oct 2022 22:59:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5O9o/ISInRcw5UxtBiMEIP6wor/0XJ+07e0qXYaBcQfIT4MYUHynirkfsXAVY4bOLye3gi X-Received: by 2002:a17:90b:17c4:b0:20d:4d79:55b1 with SMTP id me4-20020a17090b17c400b0020d4d7955b1mr11810889pjb.125.1665986349116; Sun, 16 Oct 2022 22:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665986349; cv=none; d=google.com; s=arc-20160816; b=ssNtNtv8kDqOjVQnQDMRxL6rBCFthtJUAlL/TWQmHzm42DM7sQ4d9IeWykS8MyXCka rNz00dggt3Wripr3hfFNQLGuVeCjrvImKb2/V6NxC+7zpWjCY5U+mjU026EqRMHbtovU sbo69BP3OoU2B8cfcOrE/HrbO5srGQbgLyog9lWYey4dyPbd45o+LBC/PLAkWfylpmoO lxCi6joCoGAAvagS6cCQ5GKKUHUq0Aael1Z2IK2jtO1bIx8KFyKLE11a+QJs7MOfMKjO HR5SLSkeuJrqn5iVQpJ51h1U0NzaaqCdIwRqa1uAdD6oF3qMDM+7eg2n3e37bfcoZXzx 3lKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ycoW0TX9QInRAorq7XvL5+W6CjYoCDTKU7c8pN8N0j4=; b=RVhjZdOp0FepHYWEror+gjNhHtYTHaqBJYdf2AocxrMIhuCyVueSlgGemTgccKs/5V 1u0G0Wlgjlwe6Hzvw8VzVoin2Z2N5flmRysJ3hFEpLURvIy9NIfaime2TH0mW5lKkL29 QSzHIl8iP1x+y2P/nzUbBlFBz0CEdFncRKDJRZChY+8BuX3Plu5YiNuH8utk3UkgXBXz NCQkuYxt2hjnUpkemYlvzkwoQl94Uw4GVBBkY9zAGDAH+Xw1EGNS2lLhmak905JrYDUf /+6AlsinrYkzquXaz1W5qlVIdRTlrB6NqUsDPsVkZ2ncF9zWj9OliG+squrgxtbfbgfJ GSCA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s3-20020a170902ea0300b001853a1fddecsi12032136plg.403.2022.10.16.22.58.56; Sun, 16 Oct 2022 22:59:09 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbiJQF6Q (ORCPT + 99 others); Mon, 17 Oct 2022 01:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230116AbiJQF6J (ORCPT ); Mon, 17 Oct 2022 01:58:09 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A9F9E56031; Sun, 16 Oct 2022 22:58:02 -0700 (PDT) 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 44ED71042; Sun, 16 Oct 2022 22:58:08 -0700 (PDT) Received: from a077893.blr.arm.com (unknown [10.162.42.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 27FC73F7D8; Sun, 16 Oct 2022 22:57:56 -0700 (PDT) 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 V4 3/7] arm64/perf: Update struct pmu_hw_events for BRBE Date: Mon, 17 Oct 2022 11:27:09 +0530 Message-Id: <20221017055713.451092-4-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221017055713.451092-1-anshuman.khandual@arm.com> References: <20221017055713.451092-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746913302081629399?= X-GMAIL-MSGID: =?utf-8?q?1746913302081629399?= 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 {