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

Linus Torvalds
2002-11-08T17:51:03Z

In article <1036777105.13021.13.camel@ixodes.goop.org>,
Jeremy Fitzhardinge <jeremy@goop.org> wrote:
>
>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.

.. but I don't think we have any real users who use them for recursion,
so the only "recursion" right now is through interrupts that use this
feature.

(At least that was true a long time time ago, maybe we've added truly
recursive users since)

>> Actually, giving this som emore thought, I really suspect that the
>> simplest solution is to alloc a separate "fair_read_lock()", and paths
>> that need to care about fairness (and know they don't have the irq
>> issue)
>> can use that, slowly porting users over one by one...
>
>Do you mean have a separate lock type, or have two different read_lock
>operations on the current type?

That depends on whether it is even sanely implementable to share the
same lock. It may not be.

>From a migration standpoint it would be easiest (by far) to be able to
share the lock type and to mix operations (ie an interrupt - or
recursive user - could just use the non-fair version, while others could
use the fair version on the same lock). However, I have this nagging
suspicion that it might be a total nightmare to implement efficiently in
practice.

I've not looked at it. Any ideas?

Linus