Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1772166rwb; Thu, 29 Sep 2022 01:55:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6n9yo0amAOprv4zb3uFiW8uD6jYxdpeX+9d0mtd9c3Brt/D8LRRGxSnWcAZ5waUcCygOFQ X-Received: by 2002:a17:907:9812:b0:781:bbff:1d20 with SMTP id ji18-20020a170907981200b00781bbff1d20mr1815103ejc.33.1664441750265; Thu, 29 Sep 2022 01:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664441750; cv=none; d=google.com; s=arc-20160816; b=P/x7xVeWuzGOdzLlJwnDBrUXrMDQTiTRNELWTi6EyYWVgJKxwMr3yLXXADfqAYsvpq JgSRXVna/Q7UdbnCQ98JF73DC7AL8wUUxEBH0Jb9NqrpuCdd0WrCfVbzp8Sr/JFxQEHz BaipyzH3gBjGjsSMAxy5Q2smM0AqY/KC8NyTcjlalq62/I6dkmi0U5+LT+ZjtUrVuSMP /78vMH/VW7jF+AXqb83Q0Z59Dd3E3rvYdPtif4JlJdGcp0BGFlkMXtPrNPQYQrJSSQN+ Q0W9DHnMqWhqNuCXR5LdNhzM56Wb833NsXXBk36G6Cvo/X6P+/FSzuRKk9Az2AP+T5Jn ZWXg== 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=/MS1gAzhe9nDc1qu/ZT5Ysp4H/l+J+VvuNiRAGkckik=; b=BTHRUMxn6fLxZtga21P0vY5/yz9XUjlGnd7WKUvTM2bd67oXtYJRirKFfJsIwhmpfP 1+JJ7i7z1d/20kh0+LP+XIq8rJUPNc2O8o4vSaQThlwKBwRN7ZS4tbf7bjccsMrakD65 b5+6Icd0x8tuKLpSFGbeipEcB9TWqfUaqbFGgmUJDCjNDDpXVQauke53jLSvFdOOgqGu Jby3roI/q9XusStmgll/5hO2hgBNGE+ZQbRjwib9b4e1pwvlgemkWFITHKGWWK+nrA9F nvrDSYs9GQz3zw9Z2qZfgW4hpI5Jmz5DhjOeRj5qvjEwfb2JOpCDe1FThK/XO2NQ7QT6 6v0g== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds1-20020a0564021cc100b0045809b309fdsi3069449edb.474.2022.09.29.01.55.24; Thu, 29 Sep 2022 01:55:50 -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 S235259AbiI2H70 (ORCPT + 99 others); Thu, 29 Sep 2022 03:59:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235130AbiI2H7R (ORCPT ); Thu, 29 Sep 2022 03:59:17 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E6B5913AF2F; Thu, 29 Sep 2022 00:59:16 -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 5722C22FA; Thu, 29 Sep 2022 00:59:23 -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 6DFBD3F73D; Thu, 29 Sep 2022 00:59:13 -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 , Ingo Molnar Subject: [PATCH V3 2/7] arm64/perf: Update struct arm_pmu for BRBE Date: Thu, 29 Sep 2022 13:28:52 +0530 Message-Id: <20220929075857.158358-3-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929075857.158358-1-anshuman.khandual@arm.com> References: <20220929075857.158358-1-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 Although BRBE is an armv8 speciifc HW feature, abstracting out its various function callbacks at the struct arm_pmu level is preferred, as it cleaner , easier to follow and maintain. Besides some helpers i.e brbe_supported(), brbe_probe() and brbe_reset() might not fit seamlessly, when tried to be embedded via existing arm_pmu helpers in the armv8 implementation. Updates the struct arm_pmu to include all required helpers that will drive BRBE functionality for a given PMU implementation. These are the following. - brbe_filter : Convert perf event filters into BRBE HW filters - brbe_probe : Probe BRBE HW and capture its attributes - brbe_enable : Enable BRBE HW with a given config - brbe_disable : Disable BRBE HW - brbe_read : Read BRBE buffer for captured branch records - brbe_reset : Reset BRBE buffer - brbe_supported: Whether BRBE is supported or not A BRBE driver implementation needs to provide these functionalities. Cc: Will Deacon Cc: Mark Rutland Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Catalin Marinas Cc: linux-arm-kernel@lists.infradead.org Cc: linux-perf-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/kernel/perf_event.c | 36 ++++++++++++++++++++++++++++++++++ include/linux/perf/arm_pmu.h | 21 ++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index cb69ff1e6138..e7013699171f 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -1025,6 +1025,35 @@ static int armv8pmu_filter_match(struct perf_event *event) return evtype != ARMV8_PMUV3_PERFCTR_CHAIN; } +static void armv8pmu_brbe_filter(struct pmu_hw_events *hw_event, struct perf_event *event) +{ +} + +static void armv8pmu_brbe_enable(struct pmu_hw_events *hw_event) +{ +} + +static void armv8pmu_brbe_disable(struct pmu_hw_events *hw_event) +{ +} + +static void armv8pmu_brbe_read(struct pmu_hw_events *hw_event, struct perf_event *event) +{ +} + +static void armv8pmu_brbe_probe(struct pmu_hw_events *hw_event) +{ +} + +static void armv8pmu_brbe_reset(struct pmu_hw_events *hw_event) +{ +} + +static bool armv8pmu_brbe_supported(struct perf_event *event) +{ + return false; +} + static void armv8pmu_reset(void *info) { struct arm_pmu *cpu_pmu = (struct arm_pmu *)info; @@ -1257,6 +1286,13 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, cpu_pmu->pmu.event_idx = armv8pmu_user_event_idx; + cpu_pmu->brbe_filter = armv8pmu_brbe_filter; + cpu_pmu->brbe_enable = armv8pmu_brbe_enable; + cpu_pmu->brbe_disable = armv8pmu_brbe_disable; + cpu_pmu->brbe_read = armv8pmu_brbe_read; + cpu_pmu->brbe_probe = armv8pmu_brbe_probe; + cpu_pmu->brbe_reset = armv8pmu_brbe_reset; + cpu_pmu->brbe_supported = armv8pmu_brbe_supported; cpu_pmu->name = name; cpu_pmu->map_event = map_event; cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = events ? diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index 0407a38b470a..3d427ac0ca45 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -100,6 +100,27 @@ struct arm_pmu { void (*reset)(void *); int (*map_event)(struct perf_event *event); int (*filter_match)(struct perf_event *event); + + /* Convert perf event filters into BRBE HW filters */ + void (*brbe_filter)(struct pmu_hw_events *hw_events, struct perf_event *event); + + /* Probe BRBE HW and capture its attributes */ + void (*brbe_probe)(struct pmu_hw_events *hw_events); + + /* Enable BRBE HW with a given config */ + void (*brbe_enable)(struct pmu_hw_events *hw_events); + + /* Disable BRBE HW */ + void (*brbe_disable)(struct pmu_hw_events *hw_events); + + /* Process BRBE buffer for captured branch records */ + void (*brbe_read)(struct pmu_hw_events *hw_events, struct perf_event *event); + + /* Reset BRBE buffer */ + void (*brbe_reset)(struct pmu_hw_events *hw_events); + + /* Check whether BRBE is supported */ + bool (*brbe_supported)(struct perf_event *event); int num_events; bool secure_access; /* 32-bit ARM only */ #define ARMV8_PMUV3_MAX_COMMON_EVENTS 0x40 -- 2.25.1