Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp697104pxb; Thu, 15 Apr 2021 04:36:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy76JlZpsh6hD2Z7HF+D9MqMQRFh1JUmmfVM9WSMFVrbAC5Se/38xl1ugx69r2NCFJgAKeZ X-Received: by 2002:a17:906:7806:: with SMTP id u6mr2788228ejm.130.1618486571648; Thu, 15 Apr 2021 04:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618486571; cv=none; d=google.com; s=arc-20160816; b=s9xzIxeynN+r19vahagHKTxT/vFfqp8cjuMzHCPK61Q8F8HsOFlEzFgopxpbFfB/xk A8TtNM/EPxDxi3klC29dLrK0nFZqfpWBv7Ww2E8X0rzAHpiYi9LFLffaL/VZz6pMESrS ilQwTt/VRVO8W2ukgPEYgxjd1thxI8Q/IrDN0vw1Kz4wQBN2vEoGhKqS/+1ggtJx5NpK 7RdDzb8Z61rbaYOlMY1lIgQQxdVLPX5724vP7BYhi8UUVFA5ITCGxDkWduSrTZlTkw5s kJ2fNJWBMF16b/7ick3eqOvOTCO2CeLMCH7JOYe8rKHDLcE/xp7zGZfhV2fnfubT6j18 d1rA== 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 :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=m7TJwp/aToUPhhr8EYtvRwIX55iBqLEN1odimdZLKAw=; b=svaqCKyKViACPL9DsZLt288kqFnDoYS9RjS9HKpNTM/we3xZ6i8ZiHKdgoIsEnq+93 XCTdOhwYN53z7JHJGpAjNYUqDo/d+CQ/K+nDnBw7eA7xy9Y7cmrn2XRO6MCyr9ydALin Rzrza+FbFUHWAW7bsth8dbYiVqJEI57o9tuQSxkm4EsnGtoDk9mZcqgxHlzlqTHl0eB4 i4dlMswClMC02rECXw9X9iNsTJ58ZhT/HXWEX0doc9KmJYQegDo+3dNaFI21x973l+nM UeG6EbYKJn8TAufM4ZF9T38JoF+qAJ7sXK0vuKXIGh6x15OYqpx055zEKKPiE8OI6/aT +Ksw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds10si2368228ejc.719.2021.04.15.04.35.47; Thu, 15 Apr 2021 04:36:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232453AbhDOLfP (ORCPT + 99 others); Thu, 15 Apr 2021 07:35:15 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:17001 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbhDOLfL (ORCPT ); Thu, 15 Apr 2021 07:35:11 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FLcck3HcWzPpxD; Thu, 15 Apr 2021 19:31:50 +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 19:34:40 +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> <87h7k7n81z.wl-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 19:34:40 +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: <87h7k7n81z.wl-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-kernel@vger.kernel.org Hi Marc, On 2021/4/15 18:42, Marc Zyngier wrote: > On Thu, 15 Apr 2021 07:59:26 +0100, > Keqian Zhu wrote: >> >> 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? > > No, because that wouldn't help with crappy big-little implementations > that could have PMUs with different versions. We want to find the > version at the point where the virtual PMU is created, which is why we > call the probe function once per vcpu. I see. But AFAICS the pmuver is placed in kvm->arch, and the probe function is called once per VM. Maybe I miss something. > > This of course is broken in other ways (BL+KVM is a total disaster > when it comes to PMU), but making this static would just make it > worse. OK. Thanks, Keqian