diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-08-28 02:35:35 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-08-28 02:35:35 +0000 |
commit | d6ff382e6294cf1405ed0d0b629ab0494e3c7925 (patch) | |
tree | c76cf9e80c133a7a0f5ed50cf2d45197089e80cd | |
parent | 06a6fac5f981d96fb5320f0d9b604b8d505b9a90 (diff) |
lockmgr() wants to use a different address for the wchan when draining
the lock, but a change in member ordering meant it was using the same
address. Explicitly use different members instead of mixing address
of member and address of the lock itself.
ok miod@
-rw-r--r-- | sys/kern/kern_lock.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index c4588491077..55c3c7bd868 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_lock.c,v 1.37 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: kern_lock.c,v 1.38 2011/08/28 02:35:34 guenther Exp $ */ /* * Copyright (c) 1995 @@ -49,7 +49,9 @@ */ /* - * Acquire a resource. + * Acquire a resource. We sleep on the address of the lk_sharecount + * member normally; if waiting for it to drain we sleep on the address + * of the lk_waitcount member instead. */ #define ACQUIRE(lkp, error, extflags, drain, wanted) \ do { \ @@ -58,9 +60,8 @@ do { \ (lkp)->lk_flags |= LK_WAITDRAIN; \ else \ (lkp)->lk_waitcount++; \ - /* XXX Cast away volatile. */ \ error = tsleep((drain) ? \ - (void *)&(lkp)->lk_flags : (void *)(lkp), \ + &(lkp)->lk_waitcount : &(lkp)->lk_sharecount, \ (lkp)->lk_prio, (lkp)->lk_wmesg, (lkp)->lk_timo); \ if ((drain) == 0) \ (lkp)->lk_waitcount--; \ @@ -197,7 +198,7 @@ lockmgr(__volatile struct lock *lkp, u_int flags, void *notused) lkp->lk_flags &= ~LK_HAVE_EXCL; SETHOLDER(lkp, LK_NOPROC, LK_NOCPU); if (lkp->lk_waitcount) - wakeup((void *)(lkp)); + wakeup(&lkp->lk_sharecount); break; case LK_EXCLUSIVE: @@ -266,7 +267,7 @@ lockmgr(__volatile struct lock *lkp, u_int flags, void *notused) panic("lockmgr: release of unlocked lock!"); #endif if (lkp->lk_waitcount) - wakeup((void *)(lkp)); + wakeup(&lkp->lk_sharecount); break; case LK_DRAIN: @@ -309,7 +310,7 @@ lockmgr(__volatile struct lock *lkp, u_int flags, void *notused) (LK_HAVE_EXCL | LK_WANT_EXCL)) == 0 && lkp->lk_sharecount == 0 && lkp->lk_waitcount == 0)) { lkp->lk_flags &= ~LK_WAITDRAIN; - wakeup((void *)&lkp->lk_flags); + wakeup(&lkp->lk_waitcount); } return (error); } |