[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 1/3] xen/evtchn: avoid a deadlock when unbinding an event channel



On 29/07/13 15:07, Konrad Rzeszutek Wilk wrote:
> On Fri, Jul 19, 2013 at 03:51:58PM +0100, David Vrabel wrote:
>> From: David Vrabel <david.vrabel@xxxxxxxxxx>
>>
>> Unbinding an event channel (either with the ioctl or when the evtchn
>> device is closed) may deadlock because disable_irq() is called with
>> port_user_lock held which is also locked by the interrupt handler.
> 
> So what you are saying is that if the ioctl IOCTL_EVTCHN_UNBIND
> is called (and takes an spinlock) and the evtchn_interrupt triggers
> it would deadlock?
> 
> But isn't this the IRQ variant of spinlock? Which disables interrupts?
> Could you perhaps write this out a bit with CPU1 and CPU2 in seperate
> columns? I think I must missing something.

Disabling local interrupts doesn't help.

Remember that disable_irq() waits for the interrupt handler on all CPUs
to stop running.  If the irq occurs on another VCPU, it tries to take
port_user_lock and can't because the unbind ioctl is holding it.

>> Using get_port_user() to check if a port's user is safe without the
>> spin lock (as it's protected by u->bind_mutex in the ioctl) so just
>> remove the unnesssary locking.
> 
> What about in the interrupt handler? It does not use the mutex?
> How will it protect the get_port_user() from being stale?

The unbind disables the irq before making the port user stale, so when
you clear it you are guaranteed that the interrupt handler that might
use that port cannot be running.

David


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.