Re: irqfd issue

Cornelia Huck
2013-05-07T11:07:13Z

On Tue, 7 May 2013 11:21:09 +0200
Cornelia Huck <cornelia.huck@de.ibm.com> wrote:

> On Tue, 7 May 2013 12:12:09 +0300
> Gleb Natapov <gleb@redhat.com> wrote:
>
> > On Tue, May 07, 2013 at 05:10:41PM +0800, Asias He wrote:
> > > On Tue, May 07, 2013 at 11:42:07AM +0300, Gleb Natapov wrote:
> > > > On Tue, May 07, 2013 at 04:36:50PM +0800, Asias He wrote:
> > > > > On Tue, May 07, 2013 at 11:18:38AM +0300, Gleb Natapov wrote:
> > > > > > On Tue, May 07, 2013 at 04:14:50PM +0800, Asias He wrote:
> > > > > > > On Tue, May 07, 2013 at 10:55:36AM +0300, Gleb Natapov wrote:
> > > > > > > > On Tue, May 07, 2013 at 09:37:30AM +0800, Asias He wrote:
> > > > > > > > > Hi,
> > > > > > > > >
> > > > > > > > > I am seeing this with linus/master. Any ideas?
> > > > > > > > >
> > > > > > > > How reproducible it this? What HEAD are you seeing this with?
> > > > > > >
> > > > > > > Almost always. Start a guest with vhost-net on.
> > > > > > >
> > > > > > It happens during start or on VM exit? The trace shows do_exit()
> > > > > >
> > > > > > > QEMU : e3351000cd682200835763caca87adf708ed1c65
> > > > > > > KERNEL: 51a26ae7a14b85c99c9be470c2d28eeeba0f26a3
> > > > > > >
> > > > > > Can you try with kvm.git next branch?
> > > > >
> > > > > With next branch db6ae6158186a17165ef990bda2895ae7594b039,
> > > > >
> > > > Can you revert a0f155e9646d5f1c263f6f9aae880151100243bb and try again?
> > >
> > > The issue is gone with a0f155e9646d5f1c263f6f9aae880151100243bb
> > > reverted.
> > >
> > Cornelia, any ideas?
>
> irqfd_deactivate before kvm_init or after kvm_exit? Let me look...
>

Hm, no idea.

Asias, could you try whether the patch below yields any interesting
backtraces?

diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 64ee720..59c3810 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -92,6 +92,8 @@ struct _irqfd {
};

static struct workqueue_struct *irqfd_cleanup_wq;
+static int irqfd_ready;
+static unsigned long irqfd_cnt;

static void
irqfd_inject(struct work_struct *work)
@@ -410,6 +412,8 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
*/
fput(file);

+ irqfd_cnt++;
+
return 0;

fail:
@@ -483,12 +487,16 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd *args)
*/
flush_workqueue(irqfd_cleanup_wq);

+ irqfd_cnt--;
+
return 0;
}

int
kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args)
{
+ WARN_ON(!irqfd_ready);
+
if (args->flags & ~(KVM_IRQFD_FLAG_DEASSIGN | KVM_IRQFD_FLAG_RESAMPLE))
return -EINVAL;

@@ -548,15 +556,22 @@ void kvm_irq_routing_update(struct kvm *kvm,
*/
int kvm_irqfd_init(void)
{
+ WARN_ON(irqfd_cnt);
+
irqfd_cleanup_wq = create_singlethread_workqueue("kvm-irqfd-cleanup");
if (!irqfd_cleanup_wq)
return -ENOMEM;

+ irqfd_ready = 1;
+
return 0;
}

void kvm_irqfd_exit(void)
{
+ WARN_ON(irqfd_cnt);
+ irqfd_ready = 0;
+
destroy_workqueue(irqfd_cleanup_wq);
}
#endif