From: Paolo Bonzini <pbonzini@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: linux-kernel@vger.kernel.org, yang.z.zhang@intel.com,
mtosatti@redhat.com, stable@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: lapic: sync highest ISR to hardware apic on EOI
Date: Mon, 26 May 2014 16:56:54 +0200 [thread overview]
Message-ID: <53835636.5050801@redhat.com> (raw)
In-Reply-To: <20140526142848.GA27553@redhat.com>
Il 26/05/2014 16:28, Michael S. Tsirkin ha scritto:
>> static inline void apic_clear_isr(int vec, struct kvm_lapic *apic)
>> {
>> - if (__apic_test_and_clear_vector(vec, apic->regs + APIC_ISR))
>> + struct kvm_vcpu *vcpu;
>> + if (!__apic_test_and_clear_vector(vec, apic->regs + APIC_ISR))
>> + return;
>> +
>> + vcpu = apic->vcpu;
>> +
>> + /*
>> + * We do get here for APIC virtualization enabled if the guest
>> + * uses the Hyper-V APIC enlightenment. In this case we may need
>> + * to trigger a new interrupt delivery by writing the SVI field;
>> + * on the other hand isr_count and highest_isr_cache are unused
>> + * and must be left alone.
>> + */
>> + if (unlikely(kvm_apic_vid_enabled(vcpu->kvm)))
>> + kvm_x86_ops->hwapic_isr_update(vcpu->kvm,
>> + apic_find_highest_isr(apic));
>
> I note that an indirect call on data path is mostly unnecessary here:
> static int vmx_vm_has_apicv(struct kvm *kvm)
> {
> return enable_apicv && irqchip_in_kernel(kvm);
> }
> is all it does, and irqchip_in_kernel also has an rmb within it, which
> is somewhat expensive on x86: and there's no way to reach this code
> with irqchip disabled, correct?
smp_rmb is just a compiler barrier, it's not expensive. The indirect
call is probably more expensive.
That said, other places in the paths (kvm_cpu_has_injectable_intr,
kvm_cpu_get_interrupt) already call kvm_apic_vid_enabled, so this patch
doesn't introduce something new.
> How about adding a bool flag in kvm_vcpu_arch, and testing that?
Yes, that's possible. It's also possible to test
kvm_x86_ops->hwapic_isr_update != NULL and zero the field in vmx.c's
hardware_setup. Can you make a patch?
Paolo
next prev parent reply other threads:[~2014-05-26 14:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-23 14:51 [PATCH] KVM: lapic: sync highest ISR to hardware apic on EOI Paolo Bonzini
2014-05-26 3:44 ` Zhang, Yang Z
2014-05-26 13:07 ` Paolo Bonzini
2014-05-27 0:26 ` Zhang, Yang Z
2014-05-26 14:28 ` Michael S. Tsirkin
2014-05-26 14:56 ` Paolo Bonzini [this message]
2014-05-26 15:39 ` Michael S. Tsirkin
2014-05-28 16:57 ` Marcelo Tosatti
2014-05-28 17:11 ` Paolo Bonzini
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=53835636.5050801@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=stable@vger.kernel.org \
--cc=yang.z.zhang@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.