[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1309372a-0dcf-cba6-9d65-e50139bbe46b@redhat.com>
Date: Thu, 23 Apr 2020 11:37:00 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Wanpeng Li <kernellwp@...il.com>, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org
Cc: Sean Christopherson <sean.j.christopherson@...el.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
Haiwei Li <lihaiwei@...cent.com>
Subject: Re: [PATCH v2 4/5] KVM: X86: TSCDEADLINE MSR emulation fastpath
On 23/04/20 11:01, Wanpeng Li wrote:
> +
> +void kvm_set_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu, u64 data)
> +{
> + if (__kvm_set_lapic_tscdeadline_msr(vcpu, data))
> + start_apic_timer(vcpu->arch.apic);
> +}
> +
> +int kvm_set_lapic_tscdeadline_msr_fast(struct kvm_vcpu *vcpu, u64 data)
> +{
> + struct kvm_lapic *apic = vcpu->arch.apic;
> +
> + if (__kvm_set_lapic_tscdeadline_msr(vcpu, data)) {
> + atomic_set(&apic->lapic_timer.pending, 0);
> + if (start_hv_timer(apic))
> + return tscdeadline_expired_timer_fast(vcpu);
> + }
> +
> + return 1;
> }
>
> +static int tscdeadline_expired_timer_fast(struct kvm_vcpu *vcpu)
> +{
> + if (kvm_check_request(KVM_REQ_PENDING_TIMER, vcpu)) {
> + kvm_clear_request(KVM_REQ_PENDING_TIMER, vcpu);
> + kvm_inject_apic_timer_irqs_fast(vcpu);
> + atomic_set(&vcpu->arch.apic->lapic_timer.pending, 0);
> + }
> +
> + return 0;
> +}
This could also be handled in apic_timer_expired. For example you can
add an argument from_timer_fn and do
if (!from_timer_fn) {
WARN_ON(kvm_get_running_vcpu() != vcpu);
kvm_inject_apic_timer_irqs_fast(vcpu);
return;
}
if (kvm_use_posted_timer_interrupt(apic->vcpu)) {
...
}
atomic_inc(&apic->lapic_timer.pending);
kvm_set_pending_timer(vcpu);
and then you don't need kvm_set_lapic_tscdeadline_msr_fast and
everything else. Anyway thanks, this is already much better.
Paoo
Powered by blists - more mailing lists