Date: Sat, 3 Oct 2009 15:02:55 +0000 (UTC) From: Attilio Rao <attilio@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r197735 - head/sys/kern Message-ID: <200910031502.n93F2tOp043967@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: attilio Date: Sat Oct 3 15:02:55 2009 New Revision: 197735 URL: http://svn.freebsd.org/changeset/base/197735 Log: 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 Modified: head/sys/kern/kern_lock.c Modified: head/sys/kern/kern_lock.c ============================================================================== --- head/sys/kern/kern_lock.c Sat Oct 3 14:38:22 2009 (r197734) +++ head/sys/kern/kern_lock.c Sat Oct 3 15:02:55 2009 (r197735) @@ -241,7 +241,7 @@ wakeupshlk(struct lock *lk, const char * * 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 * 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 * 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910031502.n93F2tOp043967>