Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1289372rwb; Sun, 6 Nov 2022 23:04:16 -0800 (PST) X-Google-Smtp-Source: AMsMyM63p6bJ9NHyFE6/DJUuGmQh1tkQVedmAFXQ1pl78CHKsFTS26Hd1K+9Mr4q8wDd0E2GJm44 X-Received: by 2002:a17:907:701:b0:780:2c44:e4dd with SMTP id xb1-20020a170907070100b007802c44e4ddmr13661560ejb.589.1667804656602; Sun, 06 Nov 2022 23:04:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667804656; cv=none; d=google.com; s=arc-20160816; b=PgxxVVKhcwwIOAcLbvsMoRwR1m6Aqdp9KECuHGMqIpcub8+kBYgLAs58vUWNGOscId 4QjBsY7AnHLl5TW/5JZBhA3ODMZo9qODjDbomImWYbNn89hlsgVrvjBo2NvAZCVsD2q5 +hngAAdXTROQwIqaAExViChBFe/myGrJOZI0csHcWeUYNYqoKhN18ZpOdT/3W7GM9ROa 3zMugRGFPbqWKHWGyojf+kTXsaoymyrFCW4U1VQMN/Mu4b1OMXHsrZggnb1uFWkyc61X T1hHAOblPZrSixOtHMRTR4WexuANP77ZdLKgQLyUPFAzcVnZZa6e/7XYMXhXZtM1CRD6 00nw== 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=JlxglQSigNsfFBKJJrHbDgi/uRlefNIvX9ViPCXwRaNW7KUdgdXY1SuD61jFsqS9on JrfpQwR3OcfatkwPhNXpK7JqYrH7hZ6kXcjiiaW0GYlA7eeS18/BbhF+qseCz5+HATs+ lvnzf6bmlz3zkU9xPEh0xjpmS9yO5qqoorkkaqow/x9tc1sQKO9KPAPAmlvhy/kqZ+9i c5WZWRNNJhBwPnPfRpRCCp3Z1e0f1x9BPWESANTXeA4cXskds7ltHcbdTrzU/qiIGg7X UAn6/a2MTOhafvhey7gxxspKhMP8hz4l0fKlYij0ybjIhj3dMm9AMKrddezYCLbCD2Dd xLxg== 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 go37-20020a1709070da500b0078e1246e7d6si9362325ejc.748.2022.11.06.23.03.53; Sun, 06 Nov 2022 23:04:16 -0800 (PST) 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 S231328AbiKGG0g (ORCPT + 95 others); Mon, 7 Nov 2022 01:26:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbiKGG0T (ORCPT ); Mon, 7 Nov 2022 01:26:19 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2809612AC9; Sun, 6 Nov 2022 22:26:14 -0800 (PST) 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 1752C113E; Sun, 6 Nov 2022 22:26:20 -0800 (PST) Received: from a077893.blr.arm.com (unknown [10.162.42.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E30903F534; Sun, 6 Nov 2022 22:26:08 -0800 (PST) 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 V5 7/7] arm64/perf: Enable branch stack sampling Date: Mon, 7 Nov 2022 11:55:14 +0530 Message-Id: <20221107062514.2851047-8-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221107062514.2851047-1-anshuman.khandual@arm.com> References: <20221107062514.2851047-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 | 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; -- 2.25.1