From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Isaku Yamahata <isaku.yamahata@intel.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Paolo Bonzini <pbonzini@redhat.com>,
erdemaktas@google.com, Sean Christopherson <seanjc@google.com>,
Vishal Annapurve <vannapurve@google.com>,
Jim Mattson <jmattson@google.com>,
Maxim Levitsky <mlevitsk@redhat.com>
Cc: isaku.yamahata@gmail.com
Subject: Re: [PATCH v3 1/4] KVM: x86/hyperv: Calculate APIC bus frequency for hyper-v
Date: Thu, 21 Dec 2023 13:26:58 +0800 [thread overview]
Message-ID: <09cec4fd-2d79-4925-bb2b-7814032fdda3@intel.com> (raw)
In-Reply-To: <ecd345619fdddfe48f375160c90322754cec9096.1702974319.git.isaku.yamahata@intel.com>
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 <isaku.yamahata@intel.com>
> ---
> 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
next prev parent reply other threads:[~2023-12-21 5:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 8:34 [PATCH v3 0/4] KVM: X86: Make bus clock frequency for vapic timer configurable Isaku Yamahata
2023-12-19 8:34 ` [PATCH v3 1/4] KVM: x86/hyperv: Calculate APIC bus frequency for hyper-v Isaku Yamahata
2023-12-21 5:26 ` Xiaoyao Li [this message]
2023-12-29 4:20 ` Xiaoyao Li
2023-12-21 17:39 ` Maxim Levitsky
2023-12-19 8:34 ` [PATCH v3 2/4] KVM: x86: Make the APIC bus cycles per nsec VM variable Isaku Yamahata
2023-12-21 5:34 ` Xiaoyao Li
2023-12-21 17:39 ` Maxim Levitsky
2023-12-19 8:34 ` [PATCH v3 3/4] KVM: X86: Add a capability to configure bus frequency for APIC timer Isaku Yamahata
2023-12-29 4:41 ` Xiaoyao Li
2024-02-23 19:33 ` Sean Christopherson
2024-03-08 1:36 ` Isaku Yamahata
2023-12-19 8:34 ` [PATCH v3 4/4] KVM: selftests: Add test case for x86 apic_bus_clock_frequency Isaku Yamahata
2023-12-21 17:38 ` Maxim Levitsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=09cec4fd-2d79-4925-bb2b-7814032fdda3@intel.com \
--to=xiaoyao.li@intel.com \
--cc=erdemaktas@google.com \
--cc=isaku.yamahata@gmail.com \
--cc=isaku.yamahata@intel.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vannapurve@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox