Re: [Linux-ia64] reader-writer livelock problem

Rusty Russell
2002-11-09T04:09:22Z

In message <1036777105.13021.13.camel@ixodes.goop.org> you write:
> On Fri, 2002-11-08 at 09:25, Linus Torvalds wrote:
> > There's another reason for not doing it that way: allowing readers to keep
> > interrupts on even in the presense of interrupt uses of readers.
> >
> > If you do the "pending writes stop readers" approach, you get
> >
> > cpu1 cpu2
> >
> > read_lock() - get
> >
> > write_lock_irq() - pending
> >
> > irq happens
> > - read_lock() - deadlock
> >
> > and that means that you need to make readers protect against interrupts
> > even if the interrupts only read themselves.
>
> Even without interrupts that would be a bug. It isn't ever safe to
> attempt to retake a read lock if you already hold it, because you may
> deadlock with a pending writer. Fair multi-reader locks aren't
> recursive locks.

That's the point. This is explicitly guaranteed with the current
locks, and you are allowed to recurse on them. The netfilter code
explicitly uses this to retake the net brlock, since it gets called
from different paths.

Implement "read_lock_yield" or "wrlock_t" but don't break existing
semantics until 2.7 *please*!

Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.