From: "Jan Beulich" Subject: [PATCH] linux-2.6.18/x86: make xor block handling uniform Date: Fri, 29 Jun 2012 15:29:47 +0100 Message-ID: <4FEDD7FB020000780008CDF5@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartBA9415CB.0__=" Return-path: 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 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. --=__PartBA9415CB.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Irrespective of the elimination of raw CR0 reads and writes, any of the methods requiring access to the floating point/XMM state still perform worse than the integer register based ones (at least as long as the virtual CR0.TS is set upon entry). Thus un-define XOR_SELECT_TEMPLATE in both 32- and 64-bit. On 64-bit additionally make the integer register based routines available for selection in the first place, and remove the duplicate code in the Xen specific header in favor of a small adjustment to the native one (using read_cr0()/clts()/write_cr0() instead of open coded accesses in the inline assembly). Signed-off-by: Jan Beulich --- /dev/null +++ b/include/asm-i386/mach-xen/asm/xor.h @@ -0,0 +1,3 @@ +#include_next + +#undef XOR_SELECT_TEMPLATE --- a/include/asm-x86_64/mach-xen/asm/xor.h +++ b/include/asm-x86_64/mach-xen/asm/xor.h @@ -1,328 +1,17 @@ -/* - * x86-64 changes / gcc fixes from Andi Kleen.=20 - * Copyright 2002 Andi Kleen, SuSE Labs. - * - * This hasn't been optimized for the hammer yet, but there are likely - * no advantages to be gotten from x86-64 here anyways. - */ +#include_next =20 -typedef struct { unsigned long a,b; } __attribute__((aligned(16))) = xmm_store_t; +#undef XOR_SELECT_TEMPLATE =20 -/* Doesn't use gcc to save the XMM registers, because there is no easy = way to=20 - tell it to do a clts before the register saving. */ -#define XMMS_SAVE do { \ - preempt_disable(); \ - if (!(current_thread_info()->status & TS_USEDFPU)) \ - clts(); \ - __asm__ __volatile__ ( \ - "movups %%xmm0,(%1) ;\n\t" \ - "movups %%xmm1,0x10(%1) ;\n\t" \ - "movups %%xmm2,0x20(%1) ;\n\t" \ - "movups %%xmm3,0x30(%1) ;\n\t" \ - : "=3D&r" (cr0) \ - : "r" (xmm_save) \ - : "memory"); \ -} while(0) - -#define XMMS_RESTORE do { \ - asm volatile ( \ - "sfence ;\n\t" \ - "movups (%1),%%xmm0 ;\n\t" \ - "movups 0x10(%1),%%xmm1 ;\n\t" \ - "movups 0x20(%1),%%xmm2 ;\n\t" \ - "movups 0x30(%1),%%xmm3 ;\n\t" \ - : \ - : "r" (cr0), "r" (xmm_save) \ - : "memory"); \ - if (!(current_thread_info()->status & TS_USEDFPU)) \ - stts(); \ - preempt_enable(); \ -} while(0) - -#define OFFS(x) "16*("#x")" -#define PF_OFFS(x) "256+16*("#x")" -#define PF0(x) " prefetchnta "PF_OFFS(x)"(%[p1]) = ;\n" -#define LD(x,y) " movaps "OFFS(x)"(%[p1]), = %%xmm"#y" ;\n" -#define ST(x,y) " movaps %%xmm"#y", "OFFS(x)"(%[p1]= ) ;\n" -#define PF1(x) " prefetchnta "PF_OFFS(x)"(%[p2]) = ;\n" -#define PF2(x) " prefetchnta "PF_OFFS(x)"(%[p3]) = ;\n" -#define PF3(x) " prefetchnta "PF_OFFS(x)"(%[p4]) = ;\n" -#define PF4(x) " prefetchnta "PF_OFFS(x)"(%[p5]) = ;\n" -#define PF5(x) " prefetchnta "PF_OFFS(x)"(%[p6]) = ;\n" -#define XO1(x,y) " xorps "OFFS(x)"(%[p2]), %%xmm"#y" = ;\n" -#define XO2(x,y) " xorps "OFFS(x)"(%[p3]), %%xmm"#y" = ;\n" -#define XO3(x,y) " xorps "OFFS(x)"(%[p4]), %%xmm"#y" = ;\n" -#define XO4(x,y) " xorps "OFFS(x)"(%[p5]), %%xmm"#y" = ;\n" -#define XO5(x,y) " xorps "OFFS(x)"(%[p6]), %%xmm"#y" = ;\n" - - -static void -xor_sse_2(unsigned long bytes, unsigned long *p1, unsigned long *p2) -{ - unsigned int lines =3D bytes >> 8; - unsigned long cr0; - xmm_store_t xmm_save[4]; - - XMMS_SAVE; - - asm volatile ( -#undef BLOCK -#define BLOCK(i) \ - LD(i,0) \ - LD(i+1,1) \ - PF1(i) \ - PF1(i+2) \ - LD(i+2,2) \ - LD(i+3,3) \ - PF0(i+4) \ - PF0(i+6) \ - XO1(i,0) \ - XO1(i+1,1) \ - XO1(i+2,2) \ - XO1(i+3,3) \ - ST(i,0) \ - ST(i+1,1) \ - ST(i+2,2) \ - ST(i+3,3) \ - - - PF0(0) - PF0(2) - - " .align 32 ;\n" - " 1: ;\n" - - BLOCK(0) - BLOCK(4) - BLOCK(8) - BLOCK(12) - - " addq %[inc], %[p1] ;\n" - " addq %[inc], %[p2] ;\n" - " decl %[cnt] ; jnz 1b" - : [p1] "+r" (p1), [p2] "+r" (p2), [cnt] "+r" (lines) - : [inc] "r" (256UL)=20 - : "memory"); - - XMMS_RESTORE; -} - -static void -xor_sse_3(unsigned long bytes, unsigned long *p1, unsigned long *p2, - unsigned long *p3) -{ - unsigned int lines =3D bytes >> 8; - xmm_store_t xmm_save[4]; - unsigned long cr0; - - XMMS_SAVE; - - __asm__ __volatile__ ( -#undef BLOCK -#define BLOCK(i) \ - PF1(i) \ - PF1(i+2) \ - LD(i,0) \ - LD(i+1,1) \ - LD(i+2,2) \ - LD(i+3,3) \ - PF2(i) \ - PF2(i+2) \ - PF0(i+4) \ - PF0(i+6) \ - XO1(i,0) \ - XO1(i+1,1) \ - XO1(i+2,2) \ - XO1(i+3,3) \ - XO2(i,0) \ - XO2(i+1,1) \ - XO2(i+2,2) \ - XO2(i+3,3) \ - ST(i,0) \ - ST(i+1,1) \ - ST(i+2,2) \ - ST(i+3,3) \ - - - PF0(0) - PF0(2) - - " .align 32 ;\n" - " 1: ;\n" - - BLOCK(0) - BLOCK(4) - BLOCK(8) - BLOCK(12) - - " addq %[inc], %[p1] ;\n" - " addq %[inc], %[p2] ;\n" - " addq %[inc], %[p3] ;\n" - " decl %[cnt] ; jnz 1b" - : [cnt] "+r" (lines), - [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3) - : [inc] "r" (256UL) - : "memory");=20 - XMMS_RESTORE; -} - -static void -xor_sse_4(unsigned long bytes, unsigned long *p1, unsigned long *p2, - unsigned long *p3, unsigned long *p4) -{ - unsigned int lines =3D bytes >> 8; - xmm_store_t xmm_save[4];=20 - unsigned long cr0; - - XMMS_SAVE; - - __asm__ __volatile__ ( -#undef BLOCK -#define BLOCK(i) \ - PF1(i) \ - PF1(i+2) \ - LD(i,0) \ - LD(i+1,1) \ - LD(i+2,2) \ - LD(i+3,3) \ - PF2(i) \ - PF2(i+2) \ - XO1(i,0) \ - XO1(i+1,1) \ - XO1(i+2,2) \ - XO1(i+3,3) \ - PF3(i) \ - PF3(i+2) \ - PF0(i+4) \ - PF0(i+6) \ - XO2(i,0) \ - XO2(i+1,1) \ - XO2(i+2,2) \ - XO2(i+3,3) \ - XO3(i,0) \ - XO3(i+1,1) \ - XO3(i+2,2) \ - XO3(i+3,3) \ - ST(i,0) \ - ST(i+1,1) \ - ST(i+2,2) \ - ST(i+3,3) \ - - - PF0(0) - PF0(2) - - " .align 32 ;\n" - " 1: ;\n" - - BLOCK(0) - BLOCK(4) - BLOCK(8) - BLOCK(12) - - " addq %[inc], %[p1] ;\n" - " addq %[inc], %[p2] ;\n" - " addq %[inc], %[p3] ;\n" - " addq %[inc], %[p4] ;\n" - " decl %[cnt] ; jnz 1b" - : [cnt] "+c" (lines), - [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" (p4) - : [inc] "r" (256UL) - : "memory" ); - - XMMS_RESTORE; -} - -static void -xor_sse_5(unsigned long bytes, unsigned long *p1, unsigned long *p2, - unsigned long *p3, unsigned long *p4, unsigned long *p5) -{ - unsigned int lines =3D bytes >> 8; - xmm_store_t xmm_save[4]; - unsigned long cr0; - - XMMS_SAVE; - - __asm__ __volatile__ ( -#undef BLOCK -#define BLOCK(i) \ - PF1(i) \ - PF1(i+2) \ - LD(i,0) \ - LD(i+1,1) \ - LD(i+2,2) \ - LD(i+3,3) \ - PF2(i) \ - PF2(i+2) \ - XO1(i,0) \ - XO1(i+1,1) \ - XO1(i+2,2) \ - XO1(i+3,3) \ - PF3(i) \ - PF3(i+2) \ - XO2(i,0) \ - XO2(i+1,1) \ - XO2(i+2,2) \ - XO2(i+3,3) \ - PF4(i) \ - PF4(i+2) \ - PF0(i+4) \ - PF0(i+6) \ - XO3(i,0) \ - XO3(i+1,1) \ - XO3(i+2,2) \ - XO3(i+3,3) \ - XO4(i,0) \ - XO4(i+1,1) \ - XO4(i+2,2) \ - XO4(i+3,3) \ - ST(i,0) \ - ST(i+1,1) \ - ST(i+2,2) \ - ST(i+3,3) \ - - - PF0(0) - PF0(2) - - " .align 32 ;\n" - " 1: ;\n" - - BLOCK(0) - BLOCK(4) - BLOCK(8) - BLOCK(12) - - " addq %[inc], %[p1] ;\n" - " addq %[inc], %[p2] ;\n" - " addq %[inc], %[p3] ;\n" - " addq %[inc], %[p4] ;\n" - " addq %[inc], %[p5] ;\n" - " decl %[cnt] ; jnz 1b" - : [cnt] "+c" (lines), - [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" = (p4),=20 - [p5] "+r" (p5) - : [inc] "r" (256UL) - : "memory"); - - XMMS_RESTORE; -} - -static struct xor_block_template xor_block_sse =3D { - .name =3D "generic_sse", - .do_2 =3D xor_sse_2, - .do_3 =3D xor_sse_3, - .do_4 =3D xor_sse_4, - .do_5 =3D xor_sse_5, -}; +/* Also try the generic routines. */ +#undef XOR_TRY_TEMPLATES +#include =20 #undef XOR_TRY_TEMPLATES -#define XOR_TRY_TEMPLATES \ - do { \ +#define XOR_TRY_TEMPLATES \ + do { \ + xor_speed(&xor_block_8regs); \ + xor_speed(&xor_block_8regs_p); \ + xor_speed(&xor_block_32regs); \ + xor_speed(&xor_block_32regs_p); \ xor_speed(&xor_block_sse); \ } while (0) - -/* We force the use of the SSE xor block because it can write around L2. - We may also be able to load into the L1 only depending on how the cpu - deals with a load to a line that is being prefetched. */ -#define XOR_SELECT_TEMPLATE(FASTEST) (&xor_block_sse) --- a/include/asm-x86_64/xor.h +++ b/include/asm-x86_64/xor.h @@ -39,14 +39,14 @@ typedef struct { unsigned long a,b; } __ tell it to do a clts before the register saving. */ #define XMMS_SAVE do { \ preempt_disable(); \ + cr0 =3D read_cr0(); \ + clts(); \ asm volatile ( \ - "movq %%cr0,%0 ;\n\t" \ - "clts ;\n\t" \ "movups %%xmm0,(%1) ;\n\t" \ "movups %%xmm1,0x10(%1) ;\n\t" \ "movups %%xmm2,0x20(%1) ;\n\t" \ "movups %%xmm3,0x30(%1) ;\n\t" \ - : "=3D&r" (cr0) \ + : "+r" (cr0) \ : "r" (xmm_save) \ : "memory"); \ } while(0) @@ -58,10 +58,10 @@ typedef struct { unsigned long a,b; } __ "movups 0x10(%1),%%xmm1 ;\n\t" \ "movups 0x20(%1),%%xmm2 ;\n\t" \ "movups 0x30(%1),%%xmm3 ;\n\t" \ - "movq %0,%%cr0 ;\n\t" \ : \ : "r" (cr0), "r" (xmm_save) \ : "memory"); \ + write_cr0(cr0); \ preempt_enable(); \ } while(0) =20 --=__PartBA9415CB.0__= Content-Type: text/plain; name="xen-x86-xor-unify.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-x86-xor-unify.patch" x86: make xor block handling uniform=0A=0AIrrespective of the elimination = of raw CR0 reads and writes, any of the=0Amethods requiring access to the = floating point/XMM state still perform=0Aworse than the integer register = based ones (at least as long as the=0Avirtual CR0.TS is set upon entry). = Thus un-define XOR_SELECT_TEMPLATE=0Ain both 32- and 64-bit.=0A=0AOn = 64-bit additionally make the integer register based routines=0Aavailable = for selection in the first place, and remove the duplicate=0Acode in the = Xen specific header in favor of a small adjustment to the=0Anative one = (using read_cr0()/clts()/write_cr0() instead of open coded=0Aaccesses in = the inline assembly).=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- /dev/null=0A+++ b/include/asm-i386/mach-xen/asm/xor.h=0A@@ -0,0 = +1,3 @@=0A+#include_next =0A+=0A+#undef XOR_SELECT_TEMPLATE=0A--= - a/include/asm-x86_64/mach-xen/asm/xor.h=0A+++ b/include/asm-x86_64/mach-x= en/asm/xor.h=0A@@ -1,328 +1,17 @@=0A-/*=0A- * x86-64 changes / gcc fixes = from Andi Kleen. =0A- * Copyright 2002 Andi Kleen, SuSE Labs.=0A- *=0A- * = This hasn't been optimized for the hammer yet, but there are likely=0A- * = no advantages to be gotten from x86-64 here anyways.=0A- */=0A+#include_nex= t =0A =0A-typedef struct { unsigned long a,b; } __attribute__((a= ligned(16))) xmm_store_t;=0A+#undef XOR_SELECT_TEMPLATE=0A =0A-/* Doesn't = use gcc to save the XMM registers, because there is no easy way to =0A- = tell it to do a clts before the register saving. */=0A-#define XMMS_SAVE = do { \=0A- preempt_disable(); = \=0A- if (!(current_thread_info()->status & TS_USEDFPU)) \=0A- = clts(); \=0A- __asm__ __volatile__ ( = \=0A- "movups %%xmm0,(%1) ;\n\t" \=0A- "movups = %%xmm1,0x10(%1) ;\n\t" \=0A- "movups %%xmm2,0x20(%1) ;\n\t" = \=0A- "movups %%xmm3,0x30(%1) ;\n\t" \=0A- : "=3D&r" = (cr0) \=0A- : "r" (xmm_save) = \=0A- : "memory"); \=0A-} while(0)=0A-=0A-#def= ine XMMS_RESTORE do { \=0A- asm volatile ( = \=0A- "sfence ;\n\t" \=0A- = "movups (%1),%%xmm0 ;\n\t" \=0A- "movups 0x10(%1),%%xmm1 = ;\n\t" \=0A- "movups 0x20(%1),%%xmm2 ;\n\t" \=0A- = "movups 0x30(%1),%%xmm3 ;\n\t" \=0A- : = \=0A- : "r" (cr0), "r" (xmm_save) \=0A- : = "memory"); \=0A- if (!(current_thread_info()->status= & TS_USEDFPU)) \=0A- stts(); \=0A- = preempt_enable(); \=0A-} while(0)=0A-=0A-#define = OFFS(x) "16*("#x")"=0A-#define PF_OFFS(x) "256+16*("#x")"=0A-= #define PF0(x) " prefetchnta "PF_OFFS(x)"(%[p1]) = ;\n"=0A-#define LD(x,y) " movaps "OFFS(x)"(%[p1]), = %%xmm"#y" ;\n"=0A-#define ST(x,y) " movaps %%xmm"#y", = "OFFS(x)"(%[p1]) ;\n"=0A-#define PF1(x) " prefetchnta= "PF_OFFS(x)"(%[p2]) ;\n"=0A-#define PF2(x) " = prefetchnta "PF_OFFS(x)"(%[p3]) ;\n"=0A-#define PF3(x) " = prefetchnta "PF_OFFS(x)"(%[p4]) ;\n"=0A-#define PF4(x) " = prefetchnta "PF_OFFS(x)"(%[p5]) ;\n"=0A-#define PF5(x) " = prefetchnta "PF_OFFS(x)"(%[p6]) ;\n"=0A-#define XO1(x,y) " = xorps "OFFS(x)"(%[p2]), %%xmm"#y" ;\n"=0A-#define XO2(x,y) = " xorps "OFFS(x)"(%[p3]), %%xmm"#y" ;\n"=0A-#define XO3(x,y) = " xorps "OFFS(x)"(%[p4]), %%xmm"#y" ;\n"=0A-#define XO4(x,y) = " xorps "OFFS(x)"(%[p5]), %%xmm"#y" ;\n"=0A-#define XO5(x,y) = " xorps "OFFS(x)"(%[p6]), %%xmm"#y" ;\n"=0A-=0A-=0A-static = void=0A-xor_sse_2(unsigned long bytes, unsigned long *p1, unsigned long = *p2)=0A-{=0A- unsigned int lines =3D bytes >> 8;=0A- unsigned = long cr0;=0A- xmm_store_t xmm_save[4];=0A-=0A- XMMS_SAVE;=0A-=0A- = asm volatile (=0A-#undef BLOCK=0A-#define BLOCK(i) \=0A- = LD(i,0) \=0A- LD(i+1,1) = \=0A- PF1(i) = \=0A- PF1(i+2) \=0A- = LD(i+2,2) \=0A- = LD(i+3,3) \=0A- PF0(i+4) = \=0A- PF0(i+6) \=0A- = XO1(i,0) \=0A- XO1(i+1,1) = \=0A- XO1(i+2,2) = \=0A- XO1(i+3,3) \=0A- = ST(i,0) \=0A- ST(i+1,1) = \=0A- ST(i+2,2) = \=0A- ST(i+3,3) \=0A-=0A-=0A- = PF0(0)=0A- PF0(2)=0A-=0A- " .align 32 = ;\n"=0A- " 1: ;\n"=0A-=0A- = BLOCK(0)=0A- BLOCK(4)=0A- BLOCK(8)=0A- = BLOCK(12)=0A-=0A- " addq %[inc], %[p1] ;\n"=0A- = " addq %[inc], %[p2] ;\n"=0A- " = decl %[cnt] ; jnz 1b"=0A- : [p1] "+r" (p1), [p2] "+r" (p2), [cnt] = "+r" (lines)=0A- : [inc] "r" (256UL) =0A- : "memory");=0A-=0A= - XMMS_RESTORE;=0A-}=0A-=0A-static void=0A-xor_sse_3(unsigned long = bytes, unsigned long *p1, unsigned long *p2,=0A- unsigned long = *p3)=0A-{=0A- unsigned int lines =3D bytes >> 8;=0A- xmm_store_t = xmm_save[4];=0A- unsigned long cr0;=0A-=0A- XMMS_SAVE;=0A-=0A- = __asm__ __volatile__ (=0A-#undef BLOCK=0A-#define BLOCK(i) \=0A- = PF1(i) \=0A- = PF1(i+2) \=0A- LD(i,0) = \=0A- LD(i+1,1) \=0A- = LD(i+2,2) \=0A- = LD(i+3,3) \=0A- PF2(i) = \=0A- PF2(i+2) \=0A- = PF0(i+4) \=0A- = PF0(i+6) \=0A- XO1(i,0) = \=0A- XO1(i+1,1) \=0A- = XO1(i+2,2) \=0A- = XO1(i+3,3) \=0A- XO2(i,0) = \=0A- XO2(i+1,1) \=0A- = XO2(i+2,2) \=0A- = XO2(i+3,3) \=0A- ST(i,0) = \=0A- ST(i+1,1) \=0A- = ST(i+2,2) \=0A- = ST(i+3,3) \=0A-=0A-=0A- PF0(0)=0A- = PF0(2)=0A-=0A- " .align 32 ;\n"=0A- " 1: = ;\n"=0A-=0A- BLOCK(0)=0A- = BLOCK(4)=0A- BLOCK(8)=0A- BLOCK(12)=0A-=0A- " = addq %[inc], %[p1] ;\n"=0A- " addq %[inc], = %[p2] ;\n"=0A- " addq %[inc], %[p3] = ;\n"=0A- " decl %[cnt] ; jnz 1b"=0A- : = [cnt] "+r" (lines),=0A- [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" = (p3)=0A- : [inc] "r" (256UL)=0A- : "memory"); =0A- XMMS_RESTOR= E;=0A-}=0A-=0A-static void=0A-xor_sse_4(unsigned long bytes, unsigned long = *p1, unsigned long *p2,=0A- unsigned long *p3, unsigned long = *p4)=0A-{=0A- unsigned int lines =3D bytes >> 8;=0A- xmm_store_t = xmm_save[4]; =0A- unsigned long cr0;=0A-=0A- XMMS_SAVE;=0A-=0A- = __asm__ __volatile__ (=0A-#undef BLOCK=0A-#define BLOCK(i) \=0A- = PF1(i) \=0A- = PF1(i+2) \=0A- LD(i,0) = \=0A- LD(i+1,1) \=0A- = LD(i+2,2) \=0A- = LD(i+3,3) \=0A- PF2(i) = \=0A- PF2(i+2) \=0A- = XO1(i,0) \=0A- XO1(i+1,1) = \=0A- XO1(i+2,2) = \=0A- XO1(i+3,3) \=0A- = PF3(i) \=0A- = PF3(i+2) \=0A- PF0(i+4) = \=0A- PF0(i+6) \=0A- = XO2(i,0) \=0A- XO2(i+1,1) = \=0A- XO2(i+2,2) = \=0A- XO2(i+3,3) \=0A- = XO3(i,0) \=0A- XO3(i+1,1) = \=0A- XO3(i+2,2) = \=0A- XO3(i+3,3) \=0A- = ST(i,0) \=0A- ST(i+1,1) = \=0A- ST(i+2,2) = \=0A- ST(i+3,3) \=0A-=0A-=0A- = PF0(0)=0A- PF0(2)=0A-=0A- " .align 32 = ;\n"=0A- " 1: ;\n"=0A-=0A- = BLOCK(0)=0A- BLOCK(4)=0A- BLOCK(8)=0A- = BLOCK(12)=0A-=0A- " addq %[inc], %[p1] ;\n"=0A- = " addq %[inc], %[p2] ;\n"=0A- " addq = %[inc], %[p3] ;\n"=0A- " addq %[inc], %[p4] = ;\n"=0A- " decl %[cnt] ; jnz 1b"=0A- : [cnt] "+c" = (lines),=0A- [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] = "+r" (p4)=0A- : [inc] "r" (256UL)=0A- : "memory" );=0A-=0A- = XMMS_RESTORE;=0A-}=0A-=0A-static void=0A-xor_sse_5(unsigned long bytes, = unsigned long *p1, unsigned long *p2,=0A- unsigned long *p3, = unsigned long *p4, unsigned long *p5)=0A-{=0A- unsigned int lines = =3D bytes >> 8;=0A- xmm_store_t xmm_save[4];=0A- unsigned long = cr0;=0A-=0A- XMMS_SAVE;=0A-=0A- __asm__ __volatile__ (=0A-#undef = BLOCK=0A-#define BLOCK(i) \=0A- PF1(i) = \=0A- PF1(i+2) \=0A- = LD(i,0) \=0A- LD(i+1,1) = \=0A- LD(i+2,2) = \=0A- LD(i+3,3) \=0A- = PF2(i) \=0A- = PF2(i+2) \=0A- XO1(i,0) = \=0A- XO1(i+1,1) \=0A- = XO1(i+2,2) \=0A- = XO1(i+3,3) \=0A- PF3(i) = \=0A- PF3(i+2) \=0A- = XO2(i,0) \=0A- XO2(i+1,1) = \=0A- XO2(i+2,2) = \=0A- XO2(i+3,3) \=0A- = PF4(i) \=0A- = PF4(i+2) \=0A- PF0(i+4) = \=0A- PF0(i+6) \=0A- = XO3(i,0) \=0A- XO3(i+1,1) = \=0A- XO3(i+2,2) = \=0A- XO3(i+3,3) \=0A- = XO4(i,0) \=0A- XO4(i+1,1) = \=0A- XO4(i+2,2) = \=0A- XO4(i+3,3) \=0A- = ST(i,0) \=0A- ST(i+1,1) = \=0A- ST(i+2,2) = \=0A- ST(i+3,3) \=0A-=0A-=0A- = PF0(0)=0A- PF0(2)=0A-=0A- " .align 32 = ;\n"=0A- " 1: ;\n"=0A-=0A- = BLOCK(0)=0A- BLOCK(4)=0A- BLOCK(8)=0A- = BLOCK(12)=0A-=0A- " addq %[inc], %[p1] ;\n"=0A- = " addq %[inc], %[p2] ;\n"=0A- " addq = %[inc], %[p3] ;\n"=0A- " addq %[inc], %[p4] = ;\n"=0A- " addq %[inc], %[p5] ;\n"=0A- " = decl %[cnt] ; jnz 1b"=0A- : [cnt] "+c" (lines),=0A- [p1] = "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" (p4), =0A- [p5] = "+r" (p5)=0A- : [inc] "r" (256UL)=0A- : "memory");=0A-=0A- XMMS_RESTOR= E;=0A-}=0A-=0A-static struct xor_block_template xor_block_sse =3D {=0A- = .name =3D "generic_sse",=0A- .do_2 =3D xor_sse_2,=0A- = .do_3 =3D xor_sse_3,=0A- .do_4 =3D xor_sse_4,=0A- .do_5 =3D = xor_sse_5,=0A-};=0A+/* Also try the generic routines. */=0A+#undef = XOR_TRY_TEMPLATES=0A+#include =0A =0A #undef XOR_TRY_TEM= PLATES=0A-#define XOR_TRY_TEMPLATES \=0A- do = { \=0A+#define XOR_TRY_TEMPLA= TES \=0A+ do { = \=0A+ xor_speed(&xor_block_8regs); \=0A+ xor_speed(&= xor_block_8regs_p); \=0A+ xor_speed(&xor_block_32regs); = \=0A+ xor_speed(&xor_block_32regs_p); \=0A xor_speed(&= xor_block_sse); \=0A } while (0)=0A-=0A-/* We force the use of the SSE = xor block because it can write around L2.=0A- We may also be able to = load into the L1 only depending on how the cpu=0A- deals with a load to = a line that is being prefetched. */=0A-#define XOR_SELECT_TEMPLATE(FASTEST= ) (&xor_block_sse)=0A--- a/include/asm-x86_64/xor.h=0A+++ b/include/asm-x86= _64/xor.h=0A@@ -39,14 +39,14 @@ typedef struct { unsigned long a,b; } = __=0A tell it to do a clts before the register saving. */=0A #define = XMMS_SAVE do { \=0A preempt_disable(); = \=0A+ cr0 =3D read_cr0(); \=0A+ clts(); = \=0A asm volatile ( = \=0A- "movq %%cr0,%0 ;\n\t" \=0A- "clts = ;\n\t" \=0A "movups %%xmm0,(%1) ;\n\t" \=0A = "movups %%xmm1,0x10(%1) ;\n\t" \=0A "movups %%xmm2,0x20(%1) = ;\n\t" \=0A "movups %%xmm3,0x30(%1) ;\n\t" \=0A- : = "=3D&r" (cr0) \=0A+ : "+r" (cr0) = \=0A : "r" (xmm_save) \=0A : = "memory"); \=0A } while(0)=0A@@ -58,10 +58,10 @@ = typedef struct { unsigned long a,b; } __=0A "movups 0x10(%1),%%= xmm1 ;\n\t" \=0A "movups 0x20(%1),%%xmm2 ;\n\t" \=0A = "movups 0x30(%1),%%xmm3 ;\n\t" \=0A- "movq %0,%%cr0 = ;\n\t" \=0A : \=0A : = "r" (cr0), "r" (xmm_save) \=0A : "memory"); = \=0A+ write_cr0(cr0); \=0A preempt_enable(); = \=0A } while(0)=0A =0A --=__PartBA9415CB.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.xen.org http://lists.xen.org/xen-devel --=__PartBA9415CB.0__=--