* [RFC] Lockdep VS rw-semaphores strangeness
@ 2007-04-06 10:14 Pavel Emelianov
2007-04-06 14:04 ` Arjan van de Ven
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Emelianov @ 2007-04-06 10:14 UTC (permalink / raw)
To: Ingo Molnar, Arjan van de Ven, Linux Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 837 bytes --]
Hello Ingo, Arjan.
I'm playing with lockdep and have a question about rw-sems.
down_read_trylock() looks like
int down_read_trylock(struct rw_semaphore *sem)
{
int ret = __down_read_trylock(sem);
if (ret == 1)
rwsem_acquire_read(&sem->dep_map, 0, 1, _RET_IP_);
return ret;
}
i.e. it calls rwsem_acquire_read() with trylock == 1.
But down_write_trylock() -
int down_write_trylock(struct rw_semaphore *sem)
{
int ret = __down_write_trylock(sem);
if (ret == 1)
rwsem_acquire(&sem->dep_map, 0, 0, _RET_IP_);
return ret;
}
- calls lockdep with trylock set to 0. Why?
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.
Did I miss something?
[-- Attachment #2: diff-lockdep-rwsem-trylock --]
[-- Type: text/plain, Size: 356 bytes --]
--- ./kernel/rwsem.c.pbonrem 2007-03-06 19:09:50.000000000 +0300
+++ ./kernel/rwsem.c 2007-04-06 14:02:18.000000000 +0400
@@ -60,7 +60,7 @@ int down_write_trylock(struct rw_semapho
int ret = __down_write_trylock(sem);
if (ret == 1)
- rwsem_acquire(&sem->dep_map, 0, 0, _RET_IP_);
+ rwsem_acquire(&sem->dep_map, 0, 1, _RET_IP_);
return ret;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] Lockdep VS rw-semaphores strangeness
2007-04-06 10:14 [RFC] Lockdep VS rw-semaphores strangeness Pavel Emelianov
@ 2007-04-06 14:04 ` Arjan van de Ven
2007-04-06 14:19 ` Pavel Emelianov
0 siblings, 1 reply; 3+ messages in thread
From: Arjan van de Ven @ 2007-04-06 14:04 UTC (permalink / raw)
To: Pavel Emelianov; +Cc: Ingo Molnar, Linux Kernel Mailing List
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?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] Lockdep VS rw-semaphores strangeness
2007-04-06 14:04 ` Arjan van de Ven
@ 2007-04-06 14:19 ` Pavel Emelianov
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Emelianov @ 2007-04-06 14:19 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: Ingo Molnar, Linux Kernel Mailing List
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-06 14:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-06 10:14 [RFC] Lockdep VS rw-semaphores strangeness Pavel Emelianov
2007-04-06 14:04 ` Arjan van de Ven
2007-04-06 14:19 ` Pavel Emelianov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox