From patchwork Thu Jun 15 13:32:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 108525 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp641671vqr; Thu, 15 Jun 2023 06:37:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6QpPZdASiJfacuHKykWqGaR06NmzgGxg/QKEUpN6HZpqm3mkGKBv2OFVhx9K0yfSyPRW+E X-Received: by 2002:a05:6a00:2d18:b0:64a:7723:fe04 with SMTP id fa24-20020a056a002d1800b0064a7723fe04mr5641250pfb.4.1686836259367; Thu, 15 Jun 2023 06:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686836259; cv=none; d=google.com; s=arc-20160816; b=GzF5PGjS0KST0VYprWd+frShiPtL5QqhNApODolwqlT4B4vm2VJr3TYg6DYB+ILhXx T8KSsfRgI/JEECOBrtmmX7i8lGYCC+PJTZnyxJg2+LHjswcXW71E+x0AxAk7BGeceaj2 Tk+T/nOZTTX0Y3smA5vrm3XEwD7Pkfkzj8UbAMp3TluHtq3QQRDkDz2VNP6S0TdoUKJE bHZq1glsBvxUm1MqZDzmyO5GhkppC+3eQoi+uYtZ6dk8wbG1tP9CfKqj2hJewXFrx4zV fuKMZiMZHaOu6aTs7kwiI312FvzsmSAuZAj5tFSNCojpzAttQupL8T9wHYbMOEuccV/7 2/jg== 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=SJGG4M697ULPxZqfC84rWVs3WTfyNXf1AgTbURgMJg4=; b=XIBZ2DuHv8NyKZUioKnQH/EGTf8yXQdyu3mGeHtXzHkOeCEchW+HsdZL1ISnoZY64b VkB1IjGDNQZFSZ0ZcVT9CQGEZ1xoxczGcnjrRcmlsqlY8a9C37GxpXXRox5j30J6dpfR bdW7qJ8XLRBATj+PWag9o27U/1XrV3eleAT2I9EzUvy3kQnUCihzocZYcizg1E1RwLn2 m+90kzD38koMZ9alePzXHw+BUcOo9UfUqp7HvYgX75mTened+b0sBHhxqbo5yj0Ig6aG HLTd/J4jbaxp/sGK1+4SZ2Ind1FEOFI6kroVZ5y3QB9LiUVs7Gpi287h59bMYRseyug9 wAZg== 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 24-20020a631258000000b0050726756edesi9518230pgs.76.2023.06.15.06.37.26; Thu, 15 Jun 2023 06:37:39 -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 S1344135AbjFONd0 (ORCPT + 99 others); Thu, 15 Jun 2023 09:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344090AbjFONdO (ORCPT ); Thu, 15 Jun 2023 09:33:14 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 03354272D; Thu, 15 Jun 2023 06:33:10 -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 009F12F4; Thu, 15 Jun 2023 06:33:54 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.46.86]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A74463F64C; Thu, 15 Jun 2023 06:33:04 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com Cc: Anshuman Khandual , 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: [PATCH V12 03/10] arm64/perf: Add branch stack support in struct arm_pmu Date: Thu, 15 Jun 2023 19:02:32 +0530 Message-Id: <20230615133239.442736-4-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230615133239.442736-1-anshuman.khandual@arm.com> References: <20230615133239.442736-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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?1768776017265028143?= X-GMAIL-MSGID: =?utf-8?q?1768776017265028143?= This updates 'struct arm_pmu' for branch stack sampling support being added later. This adds an element 'reg_trbidr' to capture BRBE attribute details. These updates here will help in tracking any branch stack sampling support. This also enables perf branch stack sampling event on all 'struct arm pmu', supporting the feature but after removing the current gate that blocks such events unconditionally in armpmu_event_init(). Instead a quick probe can be initiated via arm_pmu->has_branch_stack to ascertain the support. Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Tested-by: James Clark Signed-off-by: Anshuman Khandual --- drivers/perf/arm_pmu.c | 3 +-- include/linux/perf/arm_pmu.h | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index aada47e3b126..d9ffe9e56e74 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -510,8 +510,7 @@ static int armpmu_event_init(struct perf_event *event) !cpumask_test_cpu(event->cpu, &armpmu->supported_cpus)) return -ENOENT; - /* does not support taken branch sampling */ - if (has_branch_stack(event)) + if (has_branch_stack(event) && !armpmu->has_branch_stack) return -EOPNOTSUPP; return __hw_perf_event_init(event); diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index f7fbd162ca4c..ba4204bdcebf 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -102,7 +102,9 @@ struct arm_pmu { int (*map_event)(struct perf_event *event); void (*sched_task)(struct perf_event_pmu_context *pmu_ctx, bool sched_in); int num_events; - bool secure_access; /* 32-bit ARM only */ + unsigned int secure_access : 1, /* 32-bit ARM only */ + has_branch_stack: 1, /* 64-bit ARM only */ + reserved : 30; #define ARMV8_PMUV3_MAX_COMMON_EVENTS 0x40 DECLARE_BITMAP(pmceid_bitmap, ARMV8_PMUV3_MAX_COMMON_EVENTS); #define ARMV8_PMUV3_EXT_COMMON_EVENT_BASE 0x4000 @@ -118,6 +120,11 @@ struct arm_pmu { /* Only to be used by ACPI probing code */ unsigned long acpi_cpuid; + + /* Implementation specific attributes */ +#ifdef CONFIG_ARM64_BRBE + u64 reg_brbidr; +#endif }; #define to_arm_pmu(p) (container_of(p, struct arm_pmu, pmu))