Received: by 2002:a05:7412:a9a3:b0:f9:93eb:408e with SMTP id o35csp27410rdh; Wed, 20 Dec 2023 21:27:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHFRFcAUdHykarrH8ZOr8kXnlO2TbX2bQCNv0CjDIjH7CC0zttbWh7Q/KkR26FrI1VgQX5T X-Received: by 2002:a05:6a20:6a0a:b0:18c:1248:bb17 with SMTP id p10-20020a056a206a0a00b0018c1248bb17mr873556pzk.21.1703136439106; Wed, 20 Dec 2023 21:27:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703136439; cv=none; d=google.com; s=arc-20160816; b=cf7ht9uaz9higkmNoE5NIEJE3sEzIp+zU3EqRv5ixjCD+XtXrkQGBu/NAcZa3WETw7 earswfrPOxZUZfdzqkwWLVypnGDoT8WnT7C2E7nP5ymPF5qBh3G6ClUwrvCI5IJoiYYu D8m/+IBXjD5f/vnb0ZGlhH8HXXRhpdJJ2cBspoPibexALg2Z+z5KJYz2FXFBuRwFaH0B K7VqhFakWQW/m39NpsvNBdYXQkrUOUTtzdFooAwsw9vKgQeVjuGFlugK1Ruvt0aoGBie DTLpugdEvGFq0qRdHRtKomjlvsdBQiKnYxrv8Bf7VpbyVOYGkQlv/nUCTfCuZ4HE4qEY qyKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=//C179a10Cxh3OvWpOoWfECzZmCXiT5SZrYsDaNQD9Q=; fh=wu6/LcA7ViOsSr5vOXhdZdHUUl/lXWM89r/mcoWJXEA=; b=g8F+g5cBKz9/4t3+f2YjZ7dNI8qvzVbbzyD+7/SPYU5uaQeugghcZ42XxCTn1gNZcF sNJKZA5CZJfPoT3DErEulUufFvYSM/zVOkeKcEzg78LVfScDZPaUPQgFJ0xtgq5xNJtj PnHJzLY4OSeZSVcLBX2HQTc9Jm/TlPM11Ot5DeIW5C1/p+ScmUGQzhY4tIP+gB6MZcOW i44QElBEsPJe1NPmvrf+WmWD5zRNt6ScyPSour2UPLW/EpJGk7ZKiAE6uAF4tDKHmwy5 JqXcya0zd8oYS6lri/Mfxt9O64d30mm/Bl7sLx0GeuA7qOBWO7thkHU2tVi2+/kgjxrc Ef4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="hI/Hx8t/"; spf=pass (google.com: domain of linux-kernel+bounces-7860-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i17-20020a17090aee9100b0028bf21b4ca9si329351pjz.131.2023.12.20.21.27.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 21:27:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7860-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="hI/Hx8t/"; spf=pass (google.com: domain of linux-kernel+bounces-7860-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0CB97B2439E for ; Thu, 21 Dec 2023 05:27:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33548BE4B; Thu, 21 Dec 2023 05:27:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hI/Hx8t/" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B78B0B677; Thu, 21 Dec 2023 05:27:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703136424; x=1734672424; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=08FXaP4Fhap6FLPVQHsaCAwDjmKBD3tn8cYhXkjFEuQ=; b=hI/Hx8t/qYuT4KSfkE8yCkLNj2pi2/OXw1vKIRC3wrv6kN1JYUPd3dJ1 Sd05yrLotB+sRGqm7Bzc+1OYKzVuW6Ht8uEGckXShEkwDtBVjwE9WfiWV TO5morpEix571527ey9Wg4Q1OBifZ5acHv1Gttto4bSs8347IWKIgPejm y0yzgDZYjj3Sh8ujRI5PE8hWJkqetab7hrSJmomTwvnYTkWQE9sJ7ltIK KNQGaRXE0YfsgBEK9mYEZM/+b1w3yyPwcRIgiN2fNNF84ccF65UY/w46n 5Fso5hH5gFDt7wL0Oli8kzGnw7Pw1rbEN3TGS8/0BzSGknQhWeFc9rP5A g==; X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="376073075" X-IronPort-AV: E=Sophos;i="6.04,293,1695711600"; d="scan'208";a="376073075" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 21:27:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="867198838" X-IronPort-AV: E=Sophos;i="6.04,293,1695711600"; d="scan'208";a="867198838" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.93.12.199]) ([10.93.12.199]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 21:27:01 -0800 Message-ID: <09cec4fd-2d79-4925-bb2b-7814032fdda3@intel.com> Date: Thu, 21 Dec 2023 13:26:58 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/4] KVM: x86/hyperv: Calculate APIC bus frequency for hyper-v Content-Language: en-US To: Isaku Yamahata , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Vishal Annapurve , Jim Mattson , Maxim Levitsky Cc: isaku.yamahata@gmail.com References: From: Xiaoyao Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/19/2023 4:34 PM, Isaku Yamahata wrote: > Remove APIC_BUS_FREUQNCY and calculate it based on APIC bus cycles per NS. > APIC_BUS_FREUQNCY is used only for HV_X64_MSR_APIC_FREQUENCY. The MSR is > not frequently read, calculate it every time. > > In order to make APIC bus frequency configurable, we need to make make two two 'make', please drop one. > related constants into variables. APIC_BUS_FREUQNCY and APIC_BUS_CYCLE_NS. > One can be calculated from the other. > APIC_BUS_CYCLES_NS = 1000 * 1000 * 1000 / APIC_BUS_FREQUENCY. > By removing APIC_BUS_FREQUENCY, we need to track only single variable > instead of two. > > Signed-off-by: Isaku Yamahata > --- > Changes v3: > - Newly added according to Maxim Levistsky suggestion. > --- > arch/x86/kvm/hyperv.c | 2 +- > arch/x86/kvm/lapic.h | 1 - > 2 files changed, 1 insertion(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c > index 238afd7335e4..a40ca2fef58c 100644 > --- a/arch/x86/kvm/hyperv.c > +++ b/arch/x86/kvm/hyperv.c > @@ -1687,7 +1687,7 @@ static int kvm_hv_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata, > data = (u64)vcpu->arch.virtual_tsc_khz * 1000; > break; > case HV_X64_MSR_APIC_FREQUENCY: > - data = APIC_BUS_FREQUENCY; > + data = div64_u64(1000000000ULL, APIC_BUS_CYCLE_NS); > break; > default: > kvm_pr_unimpl_rdmsr(vcpu, msr); > diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h > index 0a0ea4b5dd8c..a20cb006b6c8 100644 > --- a/arch/x86/kvm/lapic.h > +++ b/arch/x86/kvm/lapic.h > @@ -17,7 +17,6 @@ > #define APIC_DEST_MASK 0x800 > > #define APIC_BUS_CYCLE_NS 1 > -#define APIC_BUS_FREQUENCY (1000000000ULL / APIC_BUS_CYCLE_NS) > > #define APIC_BROADCAST 0xFF > #define X2APIC_BROADCAST 0xFFFFFFFFul