Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Michael S. Tsirkin
On Wed, Jul 18, 2012 at 06:23:34PM -0300, Marcelo Tosatti wrote: > On Wed, Jul 18, 2012 at 02:28:34PM -0600, Alex Williamson wrote: > > > turn on lockdep to remember why I couldn't sleep there. > > > > switching to a mutex results in: > > > > BUG: sleeping function called from invalid context at

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Marcelo Tosatti
On Wed, Jul 18, 2012 at 02:28:34PM -0600, Alex Williamson wrote: > > turn on lockdep to remember why I couldn't sleep there. > > switching to a mutex results in: > > BUG: sleeping function called from invalid context at kernel/mutex.c:269 > in_atomic(): 1, irqs_disabled(): 0, pid: 30025, name: qe

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Alex Williamson
On Wed, 2012-07-18 at 13:13 -0600, Alex Williamson wrote: > On Wed, 2012-07-18 at 13:07 -0600, Alex Williamson wrote: > > On Wed, 2012-07-18 at 15:42 -0300, Marcelo Tosatti wrote: > > > On Wed, Jul 18, 2012 at 06:58:24PM +0300, Michael S. Tsirkin wrote: > > > > > > > > > Back to original point thou

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Michael S. Tsirkin
On Wed, Jul 18, 2012 at 01:13:06PM -0600, Alex Williamson wrote: > On Wed, 2012-07-18 at 13:07 -0600, Alex Williamson wrote: > > On Wed, 2012-07-18 at 15:42 -0300, Marcelo Tosatti wrote: > > > On Wed, Jul 18, 2012 at 06:58:24PM +0300, Michael S. Tsirkin wrote: > > > > > > > > > Back to original poi

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Alex Williamson
On Wed, 2012-07-18 at 13:07 -0600, Alex Williamson wrote: > On Wed, 2012-07-18 at 15:42 -0300, Marcelo Tosatti wrote: > > On Wed, Jul 18, 2012 at 06:58:24PM +0300, Michael S. Tsirkin wrote: > > > > > > > > Back to original point though current > > > > > > > > situation is that calling kvm_set_irq()

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Alex Williamson
On Wed, 2012-07-18 at 15:42 -0300, Marcelo Tosatti wrote: > On Wed, Jul 18, 2012 at 06:58:24PM +0300, Michael S. Tsirkin wrote: > > > > > > > Back to original point though current > > > > > > > situation is that calling kvm_set_irq() under spinlock is not > > > > > > > worse for > > > > > > > scal

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Gleb Natapov
On Wed, Jul 18, 2012 at 03:42:09PM -0300, Marcelo Tosatti wrote: > On Wed, Jul 18, 2012 at 06:58:24PM +0300, Michael S. Tsirkin wrote: > > > > > > > Back to original point though current > > > > > > > situation is that calling kvm_set_irq() under spinlock is not > > > > > > > worse for > > > > > >

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Marcelo Tosatti
On Wed, Jul 18, 2012 at 06:58:24PM +0300, Michael S. Tsirkin wrote: > > > > > > Back to original point though current > > > > > > situation is that calling kvm_set_irq() under spinlock is not worse > > > > > > for > > > > > > scalability than calling it not under one. > > > > > > > > > > Yes. Sti

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Michael S. Tsirkin
On Wed, Jul 18, 2012 at 09:48:01AM -0600, Alex Williamson wrote: > On Wed, 2012-07-18 at 18:38 +0300, Michael S. Tsirkin wrote: > > On Wed, Jul 18, 2012 at 08:47:23AM -0600, Alex Williamson wrote: > > > On Wed, 2012-07-18 at 15:07 +0300, Michael S. Tsirkin wrote: > > > > On Wed, Jul 18, 2012 at 02:

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Alex Williamson
On Wed, 2012-07-18 at 18:38 +0300, Michael S. Tsirkin wrote: > On Wed, Jul 18, 2012 at 08:47:23AM -0600, Alex Williamson wrote: > > On Wed, 2012-07-18 at 15:07 +0300, Michael S. Tsirkin wrote: > > > On Wed, Jul 18, 2012 at 02:48:44PM +0300, Gleb Natapov wrote: > > > > On Wed, Jul 18, 2012 at 02:39:

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Michael S. Tsirkin
On Wed, Jul 18, 2012 at 08:47:23AM -0600, Alex Williamson wrote: > On Wed, 2012-07-18 at 15:07 +0300, Michael S. Tsirkin wrote: > > On Wed, Jul 18, 2012 at 02:48:44PM +0300, Gleb Natapov wrote: > > > On Wed, Jul 18, 2012 at 02:39:10PM +0300, Michael S. Tsirkin wrote: > > > > On Wed, Jul 18, 2012 at

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Alex Williamson
On Wed, 2012-07-18 at 15:07 +0300, Michael S. Tsirkin wrote: > On Wed, Jul 18, 2012 at 02:48:44PM +0300, Gleb Natapov wrote: > > On Wed, Jul 18, 2012 at 02:39:10PM +0300, Michael S. Tsirkin wrote: > > > On Wed, Jul 18, 2012 at 02:22:19PM +0300, Michael S. Tsirkin wrote: > > > > > > > > > > So as wa

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Michael S. Tsirkin
On Wed, Jul 18, 2012 at 02:48:44PM +0300, Gleb Natapov wrote: > On Wed, Jul 18, 2012 at 02:39:10PM +0300, Michael S. Tsirkin wrote: > > On Wed, Jul 18, 2012 at 02:22:19PM +0300, Michael S. Tsirkin wrote: > > > > > > > > > So as was discussed kvm_set_irq under spinlock is bad for > > > > > > > > >

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Gleb Natapov
On Wed, Jul 18, 2012 at 02:39:10PM +0300, Michael S. Tsirkin wrote: > On Wed, Jul 18, 2012 at 02:22:19PM +0300, Michael S. Tsirkin wrote: > > > > > > > > So as was discussed kvm_set_irq under spinlock is bad for > > > > > > > > scalability > > > > > > > > with multiple VCPUs. Why do we need a spi

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Michael S. Tsirkin
On Wed, Jul 18, 2012 at 02:22:19PM +0300, Michael S. Tsirkin wrote: > > > > > > > So as was discussed kvm_set_irq under spinlock is bad for > > > > > > > scalability > > > > > > > with multiple VCPUs. Why do we need a spinlock simply to protect > > > > > > > level_asserted? Let's use an atomic t

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Michael S. Tsirkin
On Wed, Jul 18, 2012 at 01:55:30PM +0300, Gleb Natapov wrote: > On Wed, Jul 18, 2012 at 01:53:11PM +0300, Michael S. Tsirkin wrote: > > On Wed, Jul 18, 2012 at 01:49:06PM +0300, Gleb Natapov wrote: > > > On Wed, Jul 18, 2012 at 01:48:44PM +0300, Michael S. Tsirkin wrote: > > > > On Wed, Jul 18, 201

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Gleb Natapov
On Wed, Jul 18, 2012 at 01:53:11PM +0300, Michael S. Tsirkin wrote: > On Wed, Jul 18, 2012 at 01:49:06PM +0300, Gleb Natapov wrote: > > On Wed, Jul 18, 2012 at 01:48:44PM +0300, Michael S. Tsirkin wrote: > > > On Wed, Jul 18, 2012 at 01:44:29PM +0300, Gleb Natapov wrote: > > > > On Wed, Jul 18, 201

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Michael S. Tsirkin
On Wed, Jul 18, 2012 at 01:49:06PM +0300, Gleb Natapov wrote: > On Wed, Jul 18, 2012 at 01:48:44PM +0300, Michael S. Tsirkin wrote: > > On Wed, Jul 18, 2012 at 01:44:29PM +0300, Gleb Natapov wrote: > > > On Wed, Jul 18, 2012 at 01:41:14PM +0300, Michael S. Tsirkin wrote: > > > > On Mon, Jul 16, 201

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Gleb Natapov
On Wed, Jul 18, 2012 at 01:48:44PM +0300, Michael S. Tsirkin wrote: > On Wed, Jul 18, 2012 at 01:44:29PM +0300, Gleb Natapov wrote: > > On Wed, Jul 18, 2012 at 01:41:14PM +0300, Michael S. Tsirkin wrote: > > > On Mon, Jul 16, 2012 at 02:33:47PM -0600, Alex Williamson wrote: > > > > In order to inje

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Michael S. Tsirkin
On Wed, Jul 18, 2012 at 01:44:29PM +0300, Gleb Natapov wrote: > On Wed, Jul 18, 2012 at 01:41:14PM +0300, Michael S. Tsirkin wrote: > > On Mon, Jul 16, 2012 at 02:33:47PM -0600, Alex Williamson wrote: > > > In order to inject a level interrupt from an external source using an > > > irqfd, we need t

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Gleb Natapov
On Wed, Jul 18, 2012 at 01:41:14PM +0300, Michael S. Tsirkin wrote: > On Mon, Jul 16, 2012 at 02:33:47PM -0600, Alex Williamson wrote: > > In order to inject a level interrupt from an external source using an > > irqfd, we need to allocate a new irq_source_id. This allows us to > > assert and (lat

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-18 Thread Michael S. Tsirkin
On Mon, Jul 16, 2012 at 02:33:47PM -0600, Alex Williamson wrote: > In order to inject a level interrupt from an external source using an > irqfd, we need to allocate a new irq_source_id. This allows us to > assert and (later) de-assert an interrupt line independently from > users of KVM_IRQ_LINE a

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-17 Thread Michael S. Tsirkin
On Tue, Jul 17, 2012 at 04:16:04PM -0600, Alex Williamson wrote: > On Wed, 2012-07-18 at 01:00 +0300, Michael S. Tsirkin wrote: > > On Tue, Jul 17, 2012 at 03:57:41PM -0600, Alex Williamson wrote: > > > On Wed, 2012-07-18 at 00:26 +0300, Michael S. Tsirkin wrote: > > > > On Mon, Jul 16, 2012 at 02:

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-17 Thread Alex Williamson
On Wed, 2012-07-18 at 01:00 +0300, Michael S. Tsirkin wrote: > On Tue, Jul 17, 2012 at 03:57:41PM -0600, Alex Williamson wrote: > > On Wed, 2012-07-18 at 00:26 +0300, Michael S. Tsirkin wrote: > > > On Mon, Jul 16, 2012 at 02:33:47PM -0600, Alex Williamson wrote: > > > > @@ -96,6 +183,9 @@ irqfd_sh

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-17 Thread Michael S. Tsirkin
On Tue, Jul 17, 2012 at 03:57:41PM -0600, Alex Williamson wrote: > On Wed, 2012-07-18 at 00:26 +0300, Michael S. Tsirkin wrote: > > On Mon, Jul 16, 2012 at 02:33:47PM -0600, Alex Williamson wrote: > > > @@ -96,6 +183,9 @@ irqfd_shutdown(struct work_struct *work) > > >* It is now safe to release

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-17 Thread Alex Williamson
On Wed, 2012-07-18 at 00:26 +0300, Michael S. Tsirkin wrote: > On Mon, Jul 16, 2012 at 02:33:47PM -0600, Alex Williamson wrote: > > @@ -96,6 +183,9 @@ irqfd_shutdown(struct work_struct *work) > > * It is now safe to release the object's resources > > */ > > eventfd_ctx_put(irqfd->even

Re: [PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-17 Thread Michael S. Tsirkin
On Mon, Jul 16, 2012 at 02:33:47PM -0600, Alex Williamson wrote: > @@ -96,6 +183,9 @@ irqfd_shutdown(struct work_struct *work) >* It is now safe to release the object's resources >*/ > eventfd_ctx_put(irqfd->eventfd); > + > + _irq_source_put(irqfd->source); > + > kfr

[PATCH v5 1/4] kvm: Extend irqfd to support level interrupts

2012-07-16 Thread Alex Williamson
In order to inject a level interrupt from an external source using an irqfd, we need to allocate a new irq_source_id. This allows us to assert and (later) de-assert an interrupt line independently from users of KVM_IRQ_LINE and avoid lost interrupts. We also add what may appear like a bit of exce