On Mon, 21 Sep 2015, Felipe Balbi wrote:

> On Mon, Sep 21, 2015 at 10:50:10AM -0400, Alan Stern wrote:
> > On Mon, 21 Sep 2015, Felipe Balbi wrote:
> > 
> > > On Mon, Sep 21, 2015 at 10:31:15AM -0400, Alan Stern wrote:
> > > > On Mon, 21 Sep 2015, Roger Quadros wrote:
> > > > 
> > > > > Using spin_lock() in hard irq handler is pointless
> > > > > and causes a BUG() in RT (real-time) configuration
> > > > > so get rid of it.
> > > > 
> > > > Wait a minute.  Who says spin_lock is pointless in an IRQ handler?
> > > 
> > > in the top half IRQs are already disabled, how can this race ?
> > 
> > It can race with code running on a different CPU.
> 
> fair point.

In fact, isn't this the main purpose of spinlocks?  There's no point
using a spinlock to protect against races occurring on a single CPU,
because (in non-RT situations) the kernel can't schedule or preempt
while a spinlock is held, so no race can occur.  The whole idea of
spinlocks is to protect against cross-CPU races.

Now, maybe the spinlock usage that Roger is removing really is
unnecessary in this top-half handler.  I don't know; I haven't looked
at the code.  But in general, spinlocks are highly necessary in IRQ
handlers.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to