From patchwork Tue Jul 11 08:24:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 118329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp334121vqm; Tue, 11 Jul 2023 01:53:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlEsB3brCh3CCPHEEQ7CiJlwuL+4uqODnLrtrWvwho0vjqOzifO9u2EULfDKVdDJVrgJDxTB X-Received: by 2002:a17:907:124d:b0:991:d2a8:6588 with SMTP id wc13-20020a170907124d00b00991d2a86588mr15296722ejb.51.1689065611610; Tue, 11 Jul 2023 01:53:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689065611; cv=none; d=google.com; s=arc-20160816; b=BNy5XBZT8FKhuRSDZrm/Q59cJ91KrAxsLIDTGQaOmBd2S/lkysKZs3RTIBybUSVhIl lu3UhVdUMOjF3oVpvqYvFh5p1Y/SnghkdVvLitUwd/zj5mPZnw9JMYwRlxl+1amRhOEb wpf3Ebpaa0sh8mU6stPD2W2AqPO54XfQvOjpcYB+1aym9v2vAWb4MVuIg4HpzoAEwc95 piAOaccKXnSrIMek6pPE2qMrQZC4KadXB0vgrR7kojcV1qIV0TEJOV3yuFD+QxpBlQzS R20/RNlVQDr6ffEhn93YN5rotZ7mcjBq4hnR6Wq2lUl93cXGZhs6fLE47A0qISQVI9w0 78ew== 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=Vnec7PfAkzLIgHqW4qMSPsKvzNHCL6SNCocFFc9CnCk=; fh=uKDf5R1eKBEpFB2sP5rwFdsisg1sKNqEQFf4Rrsmuig=; b=Av/RA2H2AMMIq2Kqbzm4zCF4GVwHNZbWPoHwbepth6lkF9jkcRbt7TXJs8GAMSjJL0 tklJIHe6rZdpMLgjCZqt/j/6aXou/DJ7UExuwv5Nm2mJFe0aBxOAgtu1CneYgYK+/Xm6 cbFPDp2WN5fL5bN4swGG8D5NU7d9lKXhgyYAy7EAQpnbfUm8aepMMwIjm/OFOGcbWT0r hr9eZyKF2cUXLUY93gf/lvMuFDVIlsQIPFeHUA6qv0gF7ZfWFkloJbkvU6oI7BTT+O/n geAnPuT34xJ2t1fxJVJYAPIoZIQhD2FEisnAXheQFiFjYkRrSd2cR6P2wREqrtzD5Fs5 t66g== 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 n25-20020a1709065e1900b009888aa1da13si1478035eju.752.2023.07.11.01.53.07; Tue, 11 Jul 2023 01:53:31 -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 S231403AbjGKIZm (ORCPT + 99 others); Tue, 11 Jul 2023 04:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231490AbjGKIZd (ORCPT ); Tue, 11 Jul 2023 04:25:33 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 125D610F0; Tue, 11 Jul 2023 01:25:27 -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 D984F2B; Tue, 11 Jul 2023 01:26:08 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.47.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AB0F63F740; Tue, 11 Jul 2023 01:25:21 -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 V13 - RESEND 03/10] arm64/perf: Add branch stack support in struct arm_pmu Date: Tue, 11 Jul 2023 13:54:48 +0530 Message-Id: <20230711082455.215983-4-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230711082455.215983-1-anshuman.khandual@arm.com> References: <20230711082455.215983-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: INBOX X-GMAIL-THRID: 1771113662746376864 X-GMAIL-MSGID: 1771113662746376864 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 c0475a96c2a0..fe456a46fe8d 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -512,8 +512,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 3d3bd944d630..5ecd3d0e7645 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -104,7 +104,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 @@ -120,6 +122,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))