From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5796BC43460 for ; Thu, 15 Apr 2021 06:59:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2288A611CD for ; Thu, 15 Apr 2021 06:59:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231164AbhDOG7z (ORCPT ); Thu, 15 Apr 2021 02:59:55 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:16921 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbhDOG7y (ORCPT ); Thu, 15 Apr 2021 02:59:54 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4FLVXK11HGzjYhv; Thu, 15 Apr 2021 14:57:37 +0800 (CST) Received: from [10.174.187.224] (10.174.187.224) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Thu, 15 Apr 2021 14:59:26 +0800 Subject: Re: [PATCH 1/5] KVM: arm64: Divorce the perf code from oprofile helpers To: Marc Zyngier , , , , , , References: <20210414134409.1266357-1-maz@kernel.org> <20210414134409.1266357-2-maz@kernel.org> CC: Rich Felker , Yoshinori Sato , Peter Zijlstra , "Viresh Kumar" , Heiko Carstens , "Arnaldo Carvalho de Melo" , , "Christian Borntraeger" , , Will Deacon From: Keqian Zhu Message-ID: Date: Thu, 15 Apr 2021 14:59:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20210414134409.1266357-2-maz@kernel.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.187.224] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Marc, On 2021/4/14 21:44, Marc Zyngier wrote: > KVM/arm64 is the sole user of perf_num_counters(), and really > could do without it. Stop using the obsolete API by relying on > the existing probing code. > > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/perf.c | 7 +------ > arch/arm64/kvm/pmu-emul.c | 2 +- > include/kvm/arm_pmu.h | 4 ++++ > 3 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/arch/arm64/kvm/perf.c b/arch/arm64/kvm/perf.c > index 739164324afe..b8b398670ef2 100644 > --- a/arch/arm64/kvm/perf.c > +++ b/arch/arm64/kvm/perf.c > @@ -50,12 +50,7 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = { > > int kvm_perf_init(void) > { > - /* > - * Check if HW_PERF_EVENTS are supported by checking the number of > - * hardware performance counters. This could ensure the presence of > - * a physical PMU and CONFIG_PERF_EVENT is selected. > - */ > - if (IS_ENABLED(CONFIG_ARM_PMU) && perf_num_counters() > 0) > + if (kvm_pmu_probe_pmuver() != 0xf) The probe() function may be called many times (kvm_arm_pmu_v3_set_attr also calls it). I don't know whether the first calling is enough. If so, can we use a static variable in it, so the following calling can return the result right away? Thanks, Keqian