From: "Jan Beulich" Subject: [PATCH 3/3] rwlock: allow arch to override write_unlock() atomic Date: Thu, 08 Jan 2015 16:14:50 +0000 Message-ID: <54AEBB0A0200007800052CCC@mail.emea.novell.com> References: <54AEB7C70200007800052C4D@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartD4E123EA.1__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Y9FjZ-0007KE-DD for xen-devel@lists.xenproject.org; Thu, 08 Jan 2015 16:14:53 +0000 In-Reply-To: <54AEB7C70200007800052C4D@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Ian Campbell , Keir Fraser , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartD4E123EA.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline ... (for consistency with read_unlock()), and default it to xchg(), being generally cheaper than cmpxchg(). Signed-off-by: Jan Beulich --- a/xen/common/spinlock.c +++ b/xen/common/spinlock.c @@ -438,10 +438,14 @@ int _write_trylock(rwlock_t *lock) return 1; } =20 -void _write_unlock(rwlock_t *lock) +#ifndef _raw_write_unlock +# define _raw_write_unlock(l) xchg(&(l)->lock, 0) +#endif + +inline void _write_unlock(rwlock_t *lock) { preempt_enable(); - if ( cmpxchg(&lock->lock, RW_WRITE_FLAG, 0) !=3D RW_WRITE_FLAG ) + if ( _raw_write_unlock(lock) !=3D RW_WRITE_FLAG ) BUG(); } =20 --=__PartD4E123EA.1__= Content-Type: text/plain; name="arch-write-unlock.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="arch-write-unlock.patch" rwlock: allow arch to override write_unlock() atomic=0A=0A... (for = consistency with read_unlock()), and default it to xchg(),=0Abeing = generally cheaper than cmpxchg().=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/common/spinlock.c=0A+++ b/xen/common/spi= nlock.c=0A@@ -438,10 +438,14 @@ int _write_trylock(rwlock_t *lock)=0A = return 1;=0A }=0A =0A-void _write_unlock(rwlock_t *lock)=0A+#ifndef = _raw_write_unlock=0A+# define _raw_write_unlock(l) xchg(&(l)->lock, = 0)=0A+#endif=0A+=0A+inline void _write_unlock(rwlock_t *lock)=0A {=0A = preempt_enable();=0A- if ( cmpxchg(&lock->lock, RW_WRITE_FLAG, 0) !=3D = RW_WRITE_FLAG )=0A+ if ( _raw_write_unlock(lock) !=3D RW_WRITE_FLAG = )=0A BUG();=0A }=0A =0A --=__PartD4E123EA.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartD4E123EA.1__=--