Skip to content

Commit

Permalink
Lockdep treats down_write_trylock like regular down_write
Browse files Browse the repository at this point in the history
This causes constructions like

down_write(&mm1->mmap_sem);
if (down_write_trylock(&mm2->mmap_sem)) {
       ...
       up_write(&mm2->mmap_sem);
}
up_write(&mm1->mmap_sem);

generate a lockdep warning about circular locking dependence.

Call rwsem_acquire() with trylock set to 1.

Cc: Ingo Molnar <[email protected]>
Cc: Arjan van de Ven <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Pavel Emelianov authored and Linus Torvalds committed May 8, 2007
1 parent 644fd4f commit 428e6ce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/rwsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ 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_);
rwsem_acquire(&sem->dep_map, 0, 1, _RET_IP_);
return ret;
}

Expand Down

0 comments on commit 428e6ce

Please sign in to comment.