Re: [RFC] Lockdep VS rw-semaphores strangeness

From: Pavel Emelianov
Date: Fri Apr 06 2007 - 10:15:03 EST


Arjan van de Ven wrote:
> Pavel Emelianov wrote:
>> I've already caught a fake warning when trying to write-lock
>> an mm->mmap_sem with another mm's mmap_sem write-locked. With the
>> patch attached everything works, fine.
>>
> btw why is that a fake warning? what is your guarantee that you never
> ever do it in the opposite direction from the other thread as well?
>

down_write(&mm->mmap_sem);
if (down_write_trylock(&another_mm->mmap_sem)) {
...
up_write(...);
}
up_write(&mm->mmap_sem);

will never deadlock as if I have another thread is doing

down_write(&another_mm->mmap_sem);
if (down_write_trylock(&mm->mmap_sem)) {
...
up_write(...);
}
up_write(&another_mm->mmap_sem);

booth will fail to trylock and go on.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/