From patchwork Mon Oct 17 05:57:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 3216 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1297063wrs; Sun, 16 Oct 2022 23:26:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TJyqQB7g/aIlgrW/cPqFuqByByIMtx1tBlq6Nz8tGVrP8dvclBx8PRUUEuJQO8wEHlzSW X-Received: by 2002:a17:90b:224c:b0:20d:8828:3056 with SMTP id hk12-20020a17090b224c00b0020d88283056mr31428447pjb.136.1665987991021; Sun, 16 Oct 2022 23:26:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665987991; cv=none; d=google.com; s=arc-20160816; b=aMALFgoiVlSdxv57K4/JJB/wOZNorm2VxWZ449qg9abVMEf30j/d1RCP+DMZ7B66Em 0ZqiZMnwX63W70d7uKvn7/sCUvNRjo3+Smby5JN1T8C9c/Wrpc4WCNaGAKfJHrXq9/FI aNIng7gk/6xo6jOgnmidwtokVKZro7PjOpCOJFH3bY0l/nISYnB50EtrzVWwMD3vFrKH Fnrl+tg4sK6+ySeq43LhSrJEaqIjU727m8yzewjxpJCNDETCf6np77/EG+pTPrql5yZS NWFqXo4WU1yL5krZzHZtRm1XL73ZAmzfozwiIuA5u3F/61OWXPkA3mA7R+vd6WnBLnlU Ty3g== 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=agDJp7zatiBR+mLOzJfKT3bAIHTIAxFyHnThaZDAjBc=; b=Madl7Uq+T2bB1Ccycy787ffI4WzkQcwSUgq7fk95G4FR0C2w16vIoSlRzi0Ex5BUhg L6sN7or+pRFPVYt27/AojUg1J7wk/fny6x8Ew0kSDy7SmURx5tqVWvrS2lBDh70JCBpG aiYiqrMgbkraMnl9ZsKvHUX4DpwG69M7cnhpUnAEWEb9hmErtj39STUWerAAglHVCFad geO7UJtMyh5TMuzq8WgUS4dn9hWXHQhoupk52ClHsRehp6WMYx0RuSWZqz1CH6848+sp rQQAORlXLmM7EBuPBTuDh9IOQr//QVwPzwQT8rIyTk1YQJ+kQJ04FveTOgFUe5630iok 9RrQ== 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 f13-20020a056a00228d00b0056349604a6bsi12378066pfe.334.2022.10.16.23.26.12; Sun, 16 Oct 2022 23:26: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 S230198AbiJQF6z (ORCPT + 99 others); Mon, 17 Oct 2022 01:58:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbiJQF6b (ORCPT ); Mon, 17 Oct 2022 01:58:31 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AFCFB564F0; Sun, 16 Oct 2022 22:58:25 -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 11F2111FB; Sun, 16 Oct 2022 22:58:31 -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 DACDB3F7D8; Sun, 16 Oct 2022 22:58:19 -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 7/7] arm64/perf: Enable branch stack sampling Date: Mon, 17 Oct 2022 11:27:13 +0530 Message-Id: <20221017055713.451092-8-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?1746913271716269435?= X-GMAIL-MSGID: =?utf-8?q?1746915023459110274?= Now that all the required pieces are already in place, just enable the perf branch stack sampling support on arm64 platform, by removing the gate which blocks it in armpmu_event_init(). Cc: Mark Rutland Cc: Will Deacon Cc: Catalin Marinas Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Anshuman Khandual --- drivers/perf/arm_pmu.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 1a8dca4e513e..dc5e4f9aca22 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -537,9 +537,28 @@ 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)) - return -EOPNOTSUPP; + if (has_branch_stack(event)) { + /* + * BRBE support is absent. Select CONFIG_ARM_BRBE_PMU + * in the config, before branch stack sampling events + * can be requested. + */ + if (!IS_ENABLED(CONFIG_ARM_BRBE_PMU)) { + pr_info("BRBE is disabled, select CONFIG_ARM_BRBE_PMU\n"); + return -EOPNOTSUPP; + } + + /* + * Branch stack sampling event can not be supported in + * case either the required driver itself is absent or + * BRBE buffer, is not supported. Besides checking for + * the callback prevents a crash in case it's absent. + */ + if (!armpmu->brbe_supported || !armpmu->brbe_supported(event)) { + pr_info("BRBE is not supported\n"); + return -EOPNOTSUPP; + } + } if (armpmu->map_event(event) == -ENOENT) return -ENOENT;