Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp831535rwi; Mon, 10 Oct 2022 07:46:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4VHYhVISp8DOquHBZ+nZ3peAcFxoqOPoxN8qHzz7Wn+V6/MsuNOki7115O8d9PguXB7Q9m X-Received: by 2002:a05:6402:50d4:b0:459:6f54:40df with SMTP id h20-20020a05640250d400b004596f5440dfmr18337048edb.255.1665413183954; Mon, 10 Oct 2022 07:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665413183; cv=none; d=google.com; s=arc-20160816; b=cLs/FSGNSJDc2w26Vn+wTXmoWNGMbjb+BPwKB0CV9uQDB0H0SV/Fe43lZiFA0m41Px c7QT3Zi8t9FYKm3BHaHqmq0PTeIHyRSJvA6ycLdU1weaUbxiDlwSP8gXDO8m+kSIT0mk /Bb9B8ZRC/NEPiMq4ev89EYDpp5+KJx+ijysNzAgY4tcNaGX7A+1rkYrN5+JYb/fjKK1 XuKwzTDQK8QVThd/hgJqnXsxlfbOgUD884O9VdcZ9Xnd0fFec6gGSLrC9gUHFWUX4cWc nl5FaLGrjKgO0Zq0kgtwrxf9QbryT/FVeJ30IOCmO9aamt9fxwJrCoqQtg3PELj8TBSd ZsJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:cc:from :references:to:content-language:subject:user-agent:mime-version:date :message-id; bh=xWEiUBXLw/LLEdPaFgnrUYYLIV9tX5xeJCMxgU8yUHw=; b=E7yYRLJaSCCdi58lxL/5AfMOeJd9ChMheU3U2fAi1QKibVsuSpS/gzCFSrvkS4RnAe WAnzmMdY/a9+Cru7Hw1V56nD0rUm+UZeSgCS8y+7CxXTEzJqhan3iA1NDNMpkng4T96i PhPXHLUayWRfh6olfI+V3gpstJUKmshxwYJWl1MbEb4A4l/xAUJQP6cuL0pfd/19eUC1 PGSxa5h5/2OaJpDuGF+4fHHGrbjVtxHN4h2KHDGzOUm1WKH5aAWgoJuZVmLq2ttoeBlN Fqldarn5TT8GwxYAgfxe+VleYcOJ3lwNLjfr85xpKxmVu4brsXt3Fb6CulwVAKzCGMe7 68GA== 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 b4-20020aa7d484000000b00456cc6e1017si9188801edr.109.2022.10.10.07.45.50; Mon, 10 Oct 2022 07:46:23 -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 S229641AbiJJNzY (ORCPT + 99 others); Mon, 10 Oct 2022 09:55:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229646AbiJJNzV (ORCPT ); Mon, 10 Oct 2022 09:55:21 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2ACCC5C956; Mon, 10 Oct 2022 06:55:21 -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 2BEBE12FC; Mon, 10 Oct 2022 06:55:27 -0700 (PDT) Received: from [10.57.3.59] (unknown [10.57.3.59]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 855193F766; Mon, 10 Oct 2022 06:55:19 -0700 (PDT) Message-ID: <0adcc3f7-bf60-516f-c8d7-4250d1f901cb@arm.com> Date: Mon, 10 Oct 2022 14:55:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH V3 7/7] arm64/perf: Enable branch stack sampling Content-Language: en-US To: Anshuman Khandual References: <20220929075857.158358-1-anshuman.khandual@arm.com> <20220929075857.158358-8-anshuman.khandual@arm.com> From: James Clark Cc: 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, Suzuki K Poulose In-Reply-To: <20220929075857.158358-8-anshuman.khandual@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 On 29/09/2022 08:58, Anshuman Khandual wrote: > 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()) { I'm still getting different behaviour compared to x86 when using perf_event_paranoid because of this perfmon_capable() call here. > + pr_warn_once("does not have permission for kernel branch filter\n"); Also I was under the impression that this should be more like a KERN_INFO loglevel rather than a KERN_WARNING. It's more like expected behavior rather than unexpected behavior and as far as I know anyone who sees something in dmesg might think something has gone wrong and try to follow it up. It is quite a useful message but I remember getting a review like this before and it made sense to me. > + 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;