Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1728511rwb; Thu, 29 Sep 2022 01:06:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TjljwL4bmnwuO+5kStHuOF2pnmnQ4Y2Crip8LZLQvpPqdyKl5kmCd1OwarbndSB+S+kGY X-Received: by 2002:aa7:c050:0:b0:453:4427:a947 with SMTP id k16-20020aa7c050000000b004534427a947mr2108210edo.172.1664438801296; Thu, 29 Sep 2022 01:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664438801; cv=none; d=google.com; s=arc-20160816; b=GOC7yhGmGsqWI7zY7YBcy5hgczxJ5P9spsM8SBarRiA/YvFTIl7ZqC1XHKyiPVPgBE vOVgvQiYXkQD0p0UUABroj20KQa0r4aL09RBdaPFJTRrYasgtR/xqKCfK0c3yjqolvvN MguOpMB3jLJXj8MPkf3O9A0PsLtDUwWsxLPSE1xlea+Cwz8wNJnzj5SQEi2DdZZ9pHx+ xUnNsDX3FqkxG+59ydpmTPO5TIPope4RJHUX3IdNpvfnPHbl4/nleXajHcuHyWgR+V2/ YJurhBEAW6Z2Y9aGwUZd2kBwxNvbgU89eyQRosX4mmUyrRFpzXfC/QSl7g2nWCp4paFl afTw== 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=FnBiFhYWAXtkYszgiFVUagLP4i8kYtQfJv4j18WJ008=; b=CQHv+UThteM7gNW2VtFhfA27SK9u5RPH3nIHKr4NyrxTaJbF1XlSkYu0qHmNXtw1e/ P6VT1wMxzqipsopysxVJJ3VPRxznndDI567erjtj3DxxdJQBJW1wqKzmzDN7U3nRJCqA DBTeHd8lJn+mY9j2t2B/qLKMixdRdj/IhMODI8N3Y92TGpiUcpGL6Ij/aztUKeFj64gH GErVYpgsxupVkXM4kSXi5XKxiKdSL88nhJ5tDkEwp8GLthQCvEpfMdL9X+FyjOLHh05+ JBjhhZMWCfE0VKiGcypEFeO27lOfWmwozAToGRad9tfNbd6Xl5/CoRJAEK0zop3QlTVM JeJQ== 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 v15-20020a170906b00f00b0073317d6b047si6346032ejy.569.2022.09.29.01.06.15; Thu, 29 Sep 2022 01:06:41 -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 S235514AbiI2IAa (ORCPT + 99 others); Thu, 29 Sep 2022 04:00:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235185AbiI2H7z (ORCPT ); Thu, 29 Sep 2022 03:59:55 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4A4F99FD5; Thu, 29 Sep 2022 00:59:35 -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 2372622FA; Thu, 29 Sep 2022 00:59:41 -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 D6EEE3F73D; Thu, 29 Sep 2022 00:59:31 -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 Subject: [PATCH V3 7/7] arm64/perf: Enable branch stack sampling Date: Thu, 29 Sep 2022 13:28:57 +0530 Message-Id: <20220929075857.158358-8-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 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 | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 93b36933124f..2a9b988b53c2 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -537,9 +537,35 @@ 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_warn_once("BRBE is disabled, select CONFIG_ARM_BRBE_PMU\n"); + return -EOPNOTSUPP; + } + + if (event->attr.branch_sample_type & PERF_SAMPLE_BRANCH_KERNEL) { + if (!perfmon_capable()) { + pr_warn_once("does not have permission for kernel branch filter\n"); + return -EPERM; + } + } + + /* + * 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_warn_once("BRBE is not supported\n"); + return -EOPNOTSUPP; + } + } if (armpmu->map_event(event) == -ENOENT) return -ENOENT; -- 2.25.1