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 and

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 (later)

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 to

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

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, 2012 at

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, 2012 at

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, 2012 at

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 test and set/test and clear

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 spinlock simply to

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 scalability

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

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 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:10PM

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:48:44PM

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. Still the specific use can just use

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 scalability than calling

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 scalability than calling it not

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() under spinlock is

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

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

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:

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-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); +

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-eventfd); +

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 the

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

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:33:47PM