From: Pavel Emelianov Date: Tue, 8 May 2007 07:29:10 +0000 (-0700) Subject: Lockdep treats down_write_trylock like regular down_write X-Git-Tag: v2.6.22-rc1~674 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=428e6ce023c5890cfecc8ad10335da3f28dbf893;p=linux-2.6 Lockdep treats down_write_trylock like regular down_write 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 Cc: Arjan van de Ven Cc: Peter Zijlstra Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/rwsem.c b/kernel/rwsem.c index 291ded556a..9a87886b02 100644 --- a/kernel/rwsem.c +++ b/kernel/rwsem.c @@ -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; }