From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerone Young Subject: [PATCH] cpu barriers moved and x86-64 barriers add Date: Tue, 01 Mar 2005 16:24:37 -0600 Message-ID: <1109715878.13010.34.camel@thinkpad> References: <1109707006.13010.15.camel@thinkpad> <1b8fe72b3f68af920c3ff9bba691daff@cl.cam.ac.uk> <4224DD54.3000501@us.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-VfAmQ16bc2UyqrSMGOQQ" In-Reply-To: <4224DD54.3000501@us.ibm.com> Sender: xen-devel-admin@lists.sourceforge.net Errors-To: xen-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: xen-devel Cc: Keir Fraser , Anthony Liguori List-Id: xen-devel@lists.xenproject.org --=-VfAmQ16bc2UyqrSMGOQQ Content-Type: text/plain Content-Transfer-Encoding: 7bit We actually should have wmb() be defined as "asm volatile("":::"memory") since we are not using out of order io. The patch attached removes all the instances and places the definitions in libxc/xc.h as per the discussion last week between Anthony & Keir. Signed-off-by: Jerone Young On Tue, 2005-03-01 at 15:23 -0600, Anthony Liguori wrote: > Keir Fraser wrote: > > > > > On 1 Mar 2005, at 19:56, Jerone Young wrote: > > > >> I would like to discuss is this correct, dead wrong, or even > >> needed at > >> all? > > > > > > x86/64 has proper barrier instructions -- see > > include/asm-x86_64/system.h in Linux. It is from there that we should > > pull our definitions. Barrier macros are defined in a few places in > > the tools -- we ought to pull them all into one single header > > incorporated by all tools that need it. > > I was just about to send this out myself :-) I think the consensus was > to put them all in xc.h. I posted a patch recently that made everything > include asm/system.h. All it should take is replacing asm/system.h with > xc.h in the patch and then making the necessary changes to xc.h. > > For reference, the proper x86-64 barriers are: > > #define mb() asm volatile("mfence":::"memory") > #define rmb() asm volatile("lfence":::"memory") > #define wmb() asm volatile("sfence":::"memory") > > Regards, > Anthony Liguori > -- Jerone Young Open Virtualization IBM Linux Technology Center jyoung5@us.ibm.com 512-838-1157 (T/L: 678-1157) --=-VfAmQ16bc2UyqrSMGOQQ Content-Disposition: attachment; filename=cpu_barrier_patch.diff Content-Type: text/x-patch; name=cpu_barrier_patch.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit diff -Nur xen-unstable-0301.orig/tools/blktap/blktaplib.h xen-unstable-0301-test/tools/blktap/blktaplib.h --- xen-unstable-0301.orig/tools/blktap/blktaplib.h 2005-03-01 06:54:49.000000000 -0600 +++ xen-unstable-0301-test/tools/blktap/blktaplib.h 2005-03-01 16:24:25.780124280 -0600 @@ -10,22 +10,6 @@ #include -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; -typedef int8_t s8; -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 #include #include diff -Nur xen-unstable-0301.orig/tools/libxc/xc.h xen-unstable-0301-test/tools/libxc/xc.h --- xen-unstable-0301.orig/tools/libxc/xc.h 2005-03-01 06:54:49.000000000 -0600 +++ xen-unstable-0301-test/tools/libxc/xc.h 2005-03-01 16:05:53.248254832 -0600 @@ -25,6 +25,21 @@ #include #include + +/*\ + * DEFINITIONS FOR CPU BARRIERS +\*/ +#if defined(__i386__) +#define rmb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory") +#define wmb() __asm__ __volatile__ ("" : : : "memory") +#elif defined(__x86_64__) +#define mb() asm volatile("mfence":::"memory") +#define rmb() asm volatile("lfence":::"memory") +#define wmb() asm volatile( "" :::"memory") +#else +#error "Define barriers" +#endif + /*\ * INITIALIZATION FUNCTIONS \*/ diff -Nur xen-unstable-0301.orig/tools/python/xen/lowlevel/xu/xu.c xen-unstable-0301-test/tools/python/xen/lowlevel/xu/xu.c --- xen-unstable-0301.orig/tools/python/xen/lowlevel/xu/xu.c 2005-03-01 06:54:49.000000000 -0600 +++ xen-unstable-0301-test/tools/python/xen/lowlevel/xu/xu.c 2005-03-01 16:01:13.083846296 -0600 @@ -49,14 +49,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 -Nur xen-unstable-0301.orig/tools/xcs/xcs.h xen-unstable-0301-test/tools/xcs/xcs.h --- xen-unstable-0301.orig/tools/xcs/xcs.h 2005-03-01 06:54:49.000000000 -0600 +++ xen-unstable-0301-test/tools/xcs/xcs.h 2005-03-01 16:02:22.707261928 -0600 @@ -39,13 +39,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 { \ --=-VfAmQ16bc2UyqrSMGOQQ-- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click