Arjan van de Ven <[email protected]> wrote:
> > Please, please, please don't. R/W semaphores are _not_ permitted to nest.
>
> yet they do in places, there where there is a natural hierarchy..
Where? I believe the mm used to but no longer does.
They still aren't allowed to. Consider:
CPU 1 CPU 2
======================= =======================
-->down_read(&A);
<--down_read(&A);
-->down_write(&A);
--- SLEEPING ---
-->down_read(&A);
--- DEADLOCKED ---
> > | # define down_read_nested(sem, subclass) down_read(sem)
> > | # define down_write_nested(sem, subclass) down_write(sem)
> >
> > This is _not_ okay.
>
> why not?
See above.
R/W semaphores are as completely fair as I can make them, and they do not keep
track of who's currently been granted what sort of lock. This means they are
liable to fall foul of the above deadlock sequence.
Any viable down_read()/down_write() nesting must be handled outside of rwsems
themselves.
Also, assume down_write() nesting is permitted, what do you do in the
following situation:
CPU 1 CPU 2
======================= =======================
-->down_write(&A);
<--down_write(&A);
-->down_read(&A);
--- SLEEPING ---
-->foo();
-->down_write(&A);
<--down_write(&A);
...
-->downgrade_write(&A);
<--downgrade_write(&A);
--- ??? ---
-->up_read(&A);
--- ??? ---
<--up_read(&A);
<--foo();
-->up_write(&A);
--- ??? ---
<--up_write(&A);
David
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]