diff options
author | attilio <attilio@FreeBSD.org> | 2009-10-03 15:02:55 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2009-10-03 15:02:55 +0000 |
commit | df8d61d24636b811b17db39866aff115918aecb4 (patch) | |
tree | fda5744d5b3575ef66ea7e1e9b2f4218487ea24c /sys/kern/kern_lock.c | |
parent | dd6f0c84fe0d2aeb4f6e6e7858214704f68e747f (diff) | |
download | FreeBSD-src-df8d61d24636b811b17db39866aff115918aecb4.zip FreeBSD-src-df8d61d24636b811b17db39866aff115918aecb4.tar.gz |
When releasing a lockmgr held in shared way we need to use a write memory
barrier in order to avoid, on architectures which doesn't have strong
ordered writes, CPU instructions reordering.
Diagnosed by: fabio
Diffstat (limited to 'sys/kern/kern_lock.c')
-rw-r--r-- | sys/kern/kern_lock.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index e6f2f53..60b51f7 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -241,7 +241,7 @@ wakeupshlk(struct lock *lk, const char *file, int line) * and return. */ if (LK_SHARERS(x) > 1) { - if (atomic_cmpset_ptr(&lk->lk_lock, x, + if (atomic_cmpset_rel_ptr(&lk->lk_lock, x, x - LK_ONE_SHARER)) break; continue; @@ -254,7 +254,7 @@ wakeupshlk(struct lock *lk, const char *file, int line) if ((x & LK_ALL_WAITERS) == 0) { MPASS((x & ~LK_EXCLUSIVE_SPINNERS) == LK_SHARERS_LOCK(1)); - if (atomic_cmpset_ptr(&lk->lk_lock, x, LK_UNLOCKED)) + if (atomic_cmpset_rel_ptr(&lk->lk_lock, x, LK_UNLOCKED)) break; continue; } @@ -280,7 +280,7 @@ wakeupshlk(struct lock *lk, const char *file, int line) queue = SQ_SHARED_QUEUE; } - if (!atomic_cmpset_ptr(&lk->lk_lock, LK_SHARERS_LOCK(1) | x, + if (!atomic_cmpset_rel_ptr(&lk->lk_lock, LK_SHARERS_LOCK(1) | x, v)) { sleepq_release(&lk->lock_object); continue; |