diff mbox

irqfd issue

Message ID 20130507130706.21663153@gondolin (mailing list archive)
State New, archived
Headers show

Commit Message

Cornelia Huck May 7, 2013, 11:07 a.m. UTC
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?


--
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

Comments

Gleb Natapov May 7, 2013, 2:29 p.m. UTC | #1
On Tue, May 07, 2013 at 01:07:06PM +0200, Cornelia Huck wrote:
> 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.
> 
For am quick look is seems that after the patch irqfd_cleanup_wq is
initialized as part of kvm-intel/kvm-amd module, but before the patch is
was initialized as part of kvm module. The later is how it should be,
but I do not see why would it cause the problem.

> 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

--
			Gleb.
--
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
Asias He May 7, 2013, 2:38 p.m. UTC | #2
On Tue, May 07, 2013 at 05:29:09PM +0300, Gleb Natapov wrote:
> On Tue, May 07, 2013 at 01:07:06PM +0200, Cornelia Huck wrote:
> > 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.
> > 
> For am quick look is seems that after the patch irqfd_cleanup_wq is
> initialized as part of kvm-intel/kvm-amd module, but before the patch is
> was initialized as part of kvm module. The later is how it should be,
> but I do not see why would it cause the problem.

I have a fix for this now. Will send out patch shortly.

> > 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
> 
> --
> 			Gleb.
diff mbox

Patch

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