Message ID | 55B9DEA2.1070304@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Jul 30, 2015 at 10:21:54AM +0200, Paolo Bonzini wrote: > Please review this diff: > > diff --git b/arch/x86/kvm/irq.h a/arch/x86/kvm/irq.h > index 72af5a989a2e..975cf33ef306 100644 > --- b/arch/x86/kvm/irq.h > +++ a/arch/x86/kvm/irq.h > @@ -93,11 +90,11 @@ static inline int irqchip_split(struct kvm *kvm) > bool ret; > struct kvm_pic *vpic = pic_irqchip(kvm); > > - /* Read vpic before kvm->irq_routing. */ > - smp_rmb(); > ret = (vpic != NULL); > ret |= irqchip_split(kvm); > > + /* Read vpic before kvm->irq_routing. */ > + smp_rmb(); > return ret; > } > > diff --git b/arch/x86/kvm/lapic.c a/arch/x86/kvm/lapic.c > index 2f486d8ecdae..a86324ca9cc3 100644 > --- b/arch/x86/kvm/lapic.c > +++ a/arch/x86/kvm/lapic.c > @@ -209,7 +209,7 @@ out: > if (old) > kfree_rcu(old, rcu); > > - if (!irqchip_split(kvm)) > + if (ioapic_in_kernel(kvm)) > kvm_vcpu_request_scan_ioapic(kvm); > } > > @@ -1846,7 +1846,7 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu, > kvm_x86_ops->hwapic_isr_update(vcpu->kvm, > apic_find_highest_isr(apic)); > kvm_make_request(KVM_REQ_EVENT, vcpu); > - if (!ioapic_in_kernel(vcpu->kvm)) > + if (ioapic_in_kernel(vcpu->kvm)) > kvm_rtc_eoi_tracking_restore_one(vcpu); > } > > diff --git b/arch/x86/kvm/x86.c a/arch/x86/kvm/x86.c > index 49a98608e3f6..5d2b8695732c 100644 > --- b/arch/x86/kvm/x86.c > +++ a/arch/x86/kvm/x86.c > @@ -3573,16 +3573,14 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm, > r = -EEXIST; > if (irqchip_in_kernel(kvm)) > goto split_irqchip_unlock; > - if (!irqchip_split(kvm)) { > - if (atomic_read(&kvm->online_vcpus)) > - goto split_irqchip_unlock; > - r = kvm_setup_empty_irq_routing(kvm); > - if (r) > - goto split_irqchip_unlock; > - /* Pairs with irqchip_in_kernel. */ > - smp_wmb(); > - kvm->arch.irqchip_split = true; > - } > + if (atomic_read(&kvm->online_vcpus)) > + goto split_irqchip_unlock; > + r = kvm_setup_empty_irq_routing(kvm); > + if (r) > + goto split_irqchip_unlock; > + /* Pairs with irqchip_in_kernel. */ > + smp_wmb(); > + kvm->arch.irqchip_split = true; This looks a bit non-sensical, but is overprepared for the introduction IOAPIC hotplug, which two patches down the line. Changing it is fine, you'll just need to merge the very same change back. > r = 0; > split_irqchip_unlock: > mutex_unlock(&kvm->lock); > @@ -3701,7 +3699,7 @@ long kvm_arch_vm_ioctl(struct file *filp, > } > > r = -ENXIO; > - if (!irqchip_in_kernel(kvm) || !ioapic_in_kernel(kvm)) > + if (!irqchip_in_kernel(kvm) || irqchip_split(kvm)) > goto get_irqchip_out; > r = kvm_vm_ioctl_get_irqchip(kvm, chip); > if (r) > @@ -3725,7 +3723,7 @@ long kvm_arch_vm_ioctl(struct file *filp, > } > > r = -ENXIO; > - if (!irqchip_in_kernel(kvm) || !ioapic_in_kernel(kvm)) > + if (!irqchip_in_kernel(kvm) || irqchip_split(kvm)) > goto set_irqchip_out; > r = kvm_vm_ioctl_set_irqchip(kvm, chip); > if (r) > > No need to resend. > > Paolo Looks good. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 30/07/2015 10:37, Steve Rutherford wrote: > This looks a bit non-sensical, but is overprepared for the introduction > IOAPIC hotplug, which two patches down the line. Changing it is fine, > you'll just need to merge the very same change back. By "IOAPIC hotplug" you mean changing the number of reserved routes? Is it necessary? You could just reserve a bunch of routes depending on the maximum number of IOAPICs. And especially, is it documented? :) The docs say "Fails [...] if the irqchip is already in the kernel (i.e. KVM_CREATE_IRQCHIP has already been called)". As before, no need to resend patches for now. Let's finish discussing all pending points, then I'll push what I have to kvm.git and you can test it with your VMM. There should be time between this week and the next. Paolo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Jul 30, 2015 at 11:38:20AM +0200, Paolo Bonzini wrote: > > > On 30/07/2015 10:37, Steve Rutherford wrote: > > This looks a bit non-sensical, but is overprepared for the introduction > > IOAPIC hotplug, which two patches down the line. Changing it is fine, > > you'll just need to merge the very same change back. > > By "IOAPIC hotplug" you mean changing the number of reserved routes? Is > it necessary? You could just reserve a bunch of routes depending on the > maximum number of IOAPICs. Hmm. Yeah, I think that might be cleaner. Thinking about it, I'm a bit nervous about the idea of the number of reserved routes shrinking. We would have needed to trigger an IOAPIC scan if the number of reserved routes changed. Jan might have an opinion here. > > And especially, is it documented? :) The docs say "Fails [...] if the > irqchip is already in the kernel (i.e. KVM_CREATE_IRQCHIP has already > been called)". The documentation was out of date D: > > As before, no need to resend patches for now. Let's finish discussing > all pending points, then I'll push what I have to kvm.git and you can > test it with your VMM. There should be time between this week and the next. > > Paolo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 2015-07-30 23:19, Steve Rutherford wrote: > On Thu, Jul 30, 2015 at 11:38:20AM +0200, Paolo Bonzini wrote: >> >> >> On 30/07/2015 10:37, Steve Rutherford wrote: >>> This looks a bit non-sensical, but is overprepared for the introduction >>> IOAPIC hotplug, which two patches down the line. Changing it is fine, >>> you'll just need to merge the very same change back. >> >> By "IOAPIC hotplug" you mean changing the number of reserved routes? Is >> it necessary? You could just reserve a bunch of routes depending on the >> maximum number of IOAPICs. > Hmm. Yeah, I think that might be cleaner. Thinking about it, I'm a bit nervous > about the idea of the number of reserved routes shrinking. We would have needed > to trigger an IOAPIC scan if the number of reserved routes changed. > > Jan might have an opinion here. A static preallocation is likely fine, given reasonable room. I have no idea about a good limit, though. To be safe, we could pull in someone from Intel, maybe the guy who worked on the IOAPIC refactorings in the kernel to enable hotplugging. Jan
diff --git b/arch/x86/kvm/irq.h a/arch/x86/kvm/irq.h index 72af5a989a2e..975cf33ef306 100644 --- b/arch/x86/kvm/irq.h +++ a/arch/x86/kvm/irq.h @@ -93,11 +90,11 @@ static inline int irqchip_split(struct kvm *kvm) bool ret; struct kvm_pic *vpic = pic_irqchip(kvm); - /* Read vpic before kvm->irq_routing. */ - smp_rmb(); ret = (vpic != NULL); ret |= irqchip_split(kvm); + /* Read vpic before kvm->irq_routing. */ + smp_rmb(); return ret; } diff --git b/arch/x86/kvm/lapic.c a/arch/x86/kvm/lapic.c index 2f486d8ecdae..a86324ca9cc3 100644 --- b/arch/x86/kvm/lapic.c +++ a/arch/x86/kvm/lapic.c @@ -209,7 +209,7 @@ out: if (old) kfree_rcu(old, rcu); - if (!irqchip_split(kvm)) + if (ioapic_in_kernel(kvm)) kvm_vcpu_request_scan_ioapic(kvm); } @@ -1846,7 +1846,7 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu, kvm_x86_ops->hwapic_isr_update(vcpu->kvm, apic_find_highest_isr(apic)); kvm_make_request(KVM_REQ_EVENT, vcpu); - if (!ioapic_in_kernel(vcpu->kvm)) + if (ioapic_in_kernel(vcpu->kvm)) kvm_rtc_eoi_tracking_restore_one(vcpu); } diff --git b/arch/x86/kvm/x86.c a/arch/x86/kvm/x86.c index 49a98608e3f6..5d2b8695732c 100644 --- b/arch/x86/kvm/x86.c +++ a/arch/x86/kvm/x86.c @@ -3573,16 +3573,14 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm, r = -EEXIST; if (irqchip_in_kernel(kvm)) goto split_irqchip_unlock; - if (!irqchip_split(kvm)) { - if (atomic_read(&kvm->online_vcpus)) - goto split_irqchip_unlock; - r = kvm_setup_empty_irq_routing(kvm); - if (r) - goto split_irqchip_unlock; - /* Pairs with irqchip_in_kernel. */ - smp_wmb(); - kvm->arch.irqchip_split = true; - } + if (atomic_read(&kvm->online_vcpus)) + goto split_irqchip_unlock; + r = kvm_setup_empty_irq_routing(kvm); + if (r) + goto split_irqchip_unlock; + /* Pairs with irqchip_in_kernel. */ + smp_wmb(); + kvm->arch.irqchip_split = true; r = 0; split_irqchip_unlock: mutex_unlock(&kvm->lock); @@ -3701,7 +3699,7 @@ long kvm_arch_vm_ioctl(struct file *filp, } r = -ENXIO; - if (!irqchip_in_kernel(kvm) || !ioapic_in_kernel(kvm)) + if (!irqchip_in_kernel(kvm) || irqchip_split(kvm)) goto get_irqchip_out; r = kvm_vm_ioctl_get_irqchip(kvm, chip); if (r) @@ -3725,7 +3723,7 @@ long kvm_arch_vm_ioctl(struct file *filp, } r = -ENXIO; - if (!irqchip_in_kernel(kvm) || !ioapic_in_kernel(kvm)) + if (!irqchip_in_kernel(kvm) || irqchip_split(kvm)) goto set_irqchip_out; r = kvm_vm_ioctl_set_irqchip(kvm, chip); if (r)