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=ham 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 692F8C433B4 for ; Thu, 15 Apr 2021 06:59:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39F3861153 for ; Thu, 15 Apr 2021 06:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230118AbhDOG7y (ORCPT ); Thu, 15 Apr 2021 02:59:54 -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: linux-sh@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 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,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 B3C72C433B4 for ; Thu, 15 Apr 2021 06:59:38 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 10EDB6117A for ; Thu, 15 Apr 2021 06:59:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10EDB6117A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 84E2A4B3F5; Thu, 15 Apr 2021 02:59:37 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id o4cL7z1-m02n; Thu, 15 Apr 2021 02:59:36 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 8DE7A4B3B4; Thu, 15 Apr 2021 02:59:36 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 78E0B4B375 for ; Thu, 15 Apr 2021 02:59:34 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Qqes8KVHaGYi for ; Thu, 15 Apr 2021 02:59:32 -0400 (EDT) Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id AC58E4A19F for ; Thu, 15 Apr 2021 02:59:32 -0400 (EDT) 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> 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> X-Originating-IP: [10.174.187.224] X-CFilter-Loop: Reflected Cc: Rich Felker , Yoshinori Sato , Peter Zijlstra , Viresh Kumar , Heiko Carstens , Arnaldo Carvalho de Melo , nathan@kernel.org, Christian Borntraeger , Will Deacon , kernel-team@android.com X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 51B49C433ED for ; Thu, 15 Apr 2021 07:01:45 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E8D9B61155 for ; Thu, 15 Apr 2021 07:01:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8D9B61155 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From:CC: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=iZPcj67ZFMq0fuc85KPpr4WPHTnvXa22KY8RDBweeCY=; b=eezIYWuyZDo5ujzsc4dwtGqv7 zNCeS4+qoRKcbkkmh77fejv1xZ5OOfq4dowvF59yOoGZDoOL9c7b5qVzF17TQ2MdfS9pGnrFWSF90 67QOiHTFUyJ+vWj+VUB/MxlfVA60D54vyt9LEDWdcDCt/JdllGJVEYZ+JxM6rOC5JZMyHpEyiimSN jGkEHtzhtS8aJIfUjFwGzz6ucwFtQjlGrl6gyGvP9jGt1LgssPDptP7zagScXZIJDT+w0wYLRNi/V sDLVd0tYbf2XiujEO2Cy5jYtNK+fUIlrogFKDwZMkZOlMng6wdAXeWdsfQIVyDvyRsrg7m/rxkwnd gU/dT90Rw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lWvyY-00F81O-L2; Thu, 15 Apr 2021 06:59:42 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lWvyV-00F80O-8F for linux-arm-kernel@desiato.infradead.org; Thu, 15 Apr 2021 06:59:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:CC:References:To: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=Sj5VgGYgm1P0vLrFhjnvNQfSuZVvLxom1Zt87S2OLRc=; b=PnKGGgu7iuAUxThL5Ly2FPdoDl CrRdaKiu4JswKM/vIymgU7GijqhiKgXYlx1Cusyjq9CnYxW+Sr/uLJD/tiMA/M+N3HUTNZrHg75Br zElTUpAVKwLtlwE8x3idNpqg8I7zmIhY8RdJ1eQ5pwHM9aMvMT0y4OHOIC+sDTYTrmdv1qk1IUbCS +21KtO+MKJ79NlXBQNZb30Po4EHbD2tua7FcukMX2p8daXt+onZU0BIqfA53U/rX6YVgsvEN7taLx zZNc956Lywke6J+x6ziGIT9XO2njTweyzzjxXoKKN192oo1SdxPSf47DbIoFybx/29LbemN16xw74 aoUOYQMA==; Received: from szxga06-in.huawei.com ([45.249.212.32]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lWvyQ-008KFO-Oh for linux-arm-kernel@lists.infradead.org; Thu, 15 Apr 2021 06:59:36 +0000 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> X-Originating-IP: [10.174.187.224] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210414_235934_986238_0F8542FF X-CRM114-Status: GOOD ( 19.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel