From: "Jan Beulich" Subject: [PATCH] i386: simplify pte_read_atomic() Date: Fri, 29 Oct 2010 16:44:09 +0100 Message-ID: <4CCB07E90200007800020086@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartDCF157D9.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" 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. --=__PartDCF157D9.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline There's no need for a loop here: if the value to be compared against and the value to be stored are equal, cmpxchg{,8b} act just like a load anyway. Signed-off-by: Jan Beulich --- a/xen/include/asm-x86/x86_32/page.h +++ b/xen/include/asm-x86/x86_32/page.h @@ -84,11 +84,7 @@ extern unsigned int PAGE_HYPERVISOR_NOCA =20 #endif =20 -#define pte_read_atomic(ptep) ({ \ - intpte_t __pte =3D *(ptep), __npte; \ - while ( (__npte =3D cmpxchg(ptep, __pte, __pte)) !=3D __pte ) \ - __pte =3D __npte; \ - __pte; }) +#define pte_read_atomic(ptep) cmpxchg(ptep, 0, 0) #define pte_write_atomic(ptep, pte) do { \ intpte_t __pte =3D *(ptep), __npte; \ while ( (__npte =3D cmpxchg(ptep, __pte, (pte))) !=3D __pte ) \ --=__PartDCF157D9.0__= Content-Type: text/plain; name="i386-pte-read-atomic.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="i386-pte-read-atomic.patch" There's no need for a loop here: if the value to be compared against=0Aand = the value to be stored are equal, cmpxchg{,8b} act just like a=0Aload = anyway.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/include/asm-x86/x86_32/page.h=0A+++ b/xen/include/asm-x86/x86_32/page= .h=0A@@ -84,11 +84,7 @@ extern unsigned int PAGE_HYPERVISOR_NOCA=0A =0A = #endif=0A =0A-#define pte_read_atomic(ptep) ({ = \=0A- intpte_t __pte =3D *(ptep), __npte; = \=0A- while ( (__npte =3D cmpxchg(ptep, __pte, __pte)) !=3D __pte ) = \=0A- __pte =3D __npte; \=0A- = __pte; })=0A+#define pte_read_atomic(ptep) cmpxchg(ptep, 0, 0)=0A = #define pte_write_atomic(ptep, pte) do { \=0A = intpte_t __pte =3D *(ptep), __npte; \=0A while = ( (__npte =3D cmpxchg(ptep, __pte, (pte))) !=3D __pte ) \=0A --=__PartDCF157D9.0__= 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.xensource.com http://lists.xensource.com/xen-devel --=__PartDCF157D9.0__=--