WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Cleanup rmb()/wmb() usage

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Cleanup rmb()/wmb() usage
From: Anthony Liguori <aliguori@xxxxxxxxxx>
Date: Tue, 22 Feb 2005 21:38:53 -0600
Delivery-date: Wed, 23 Feb 2005 03:40:27 +0000
Envelope-to: xen+James.Bulpin@xxxxxxxxxxxx
List-archive: <http://sourceforge.net/mailarchive/forum.php?forum=xen-devel>
List-help: <mailto:xen-devel-request@lists.sourceforge.net?subject=help>
List-id: List for Xen developers <xen-devel.lists.sourceforge.net>
List-post: <mailto:xen-devel@lists.sourceforge.net>
List-subscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=subscribe>
List-unsubscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=unsubscribe>
Organization: IBM
Sender: xen-devel-admin@xxxxxxxxxxxxxxxxxxxxx
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)
This is a pretty simple patch to use the read/write barriers defined in asm/system.h instead of using hardcoded versions in various places throughout Xen.

I've checked and using asm/system.h generates the same code on my system. I also tested xcs and it seems to work fine. I haven't tested blktap but again, it's generating the same code.

Right now, wmb() is defined as a NOP on any 386 architecture. Some Intel clones require a non-NOP wmb(). Using asm/system.h ensures we do the right thing.

It's against xen-unstable as of today.

Regards,
Anthony Liguori

Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx>

diff -ur xen-unstable-orig/tools/blktap/blktaplib.h 
xen-unstable/tools/blktap/blktaplib.h
--- xen-unstable-orig/tools/blktap/blktaplib.h  2005-02-21 22:19:26.000000000 
-0600
+++ xen-unstable/tools/blktap/blktaplib.h       2005-02-22 21:26:06.000000000 
-0600
@@ -18,14 +18,9 @@
 typedef int16_t            s16;
 typedef int32_t            s32;
 typedef int64_t            s64;
-                                                                               
 
-#if defined(__i386__)
-#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define wmb() __asm__ __volatile__ ( "" : : : "memory" )
-#else
-#error "Define barriers"
-#endif
-    
+
+#include <asm/system.h>
+
 #include <sys/user.h>
 #include <xen/xen.h>
 #include <xen/io/blkif.h>
diff -ur xen-unstable-orig/tools/python/xen/lowlevel/xu/xu.c 
xen-unstable/tools/python/xen/lowlevel/xu/xu.c
--- xen-unstable-orig/tools/python/xen/lowlevel/xu/xu.c 2005-02-21 
22:19:25.000000000 -0600
+++ xen-unstable/tools/python/xen/lowlevel/xu/xu.c      2005-02-22 
21:23:50.000000000 -0600
@@ -27,6 +27,8 @@
 #include <xen/io/domain_controller.h>
 #include <xen/linux/privcmd.h>
 
+#include <asm/system.h>
+
 #define XENPKG "xen.lowlevel.xu"
 
 /* Needed for Python versions earlier than 2.3. */
@@ -49,14 +51,6 @@
 /* Size of a machine page frame. */
 #define PAGE_SIZE 4096
 
-#if defined(__i386__)
-#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define wmb() __asm__ __volatile__ ( "" : : : "memory" )
-#else
-#error "Define barriers"
-#endif
-
-
 /* Set the close-on-exec flag on a file descriptor.  Doesn't currently bother
  * to check for errors. */
 /*
diff -ur xen-unstable-orig/tools/xcs/xcs.h xen-unstable/tools/xcs/xcs.h
--- xen-unstable-orig/tools/xcs/xcs.h   2005-02-21 22:19:31.000000000 -0600
+++ xen-unstable/tools/xcs/xcs.h        2005-02-22 21:24:12.000000000 -0600
@@ -16,6 +16,7 @@
 #include <xen/io/domain_controller.h>
 #include <xen/linux/privcmd.h>
 #include <sys/time.h>
+#include <asm/system.h>
 #include "xcs_proto.h"
 
 /* ------[ Debug macros ]--------------------------------------------------*/
@@ -39,13 +40,6 @@
 /* Size of a machine page frame. */
 #define PAGE_SIZE 4096
 
-#if defined(__i386__)
-#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define wmb() __asm__ __volatile__ ( "" : : : "memory" )
-#else
-#error "Define barriers"
-#endif
-
 #ifndef timersub /* XOPEN and __BSD don't cooperate well... */
 #define timersub(a, b, result)                                                \
   do {                                                                        \
<Prev in Thread] Current Thread [Next in Thread>