Skip to contentSkip to conversation

linux-2.6.18/x86: make xor block handling uniform

PATCH New Jan Beulich 1 participant 1 message Jun 29, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-2.6.18/x86: make xor block handling uniform

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).

include/asm-i386/mach-xen/asm/xor.h new file +3 -0
@@ -0,0 +1,3 @@
+#include_next <asm/xor.h>
+
+#undef XOR_SELECT_TEMPLATE
include/asm-x86_64/mach-xen/asm/xor.h +11 -322

339 lines not on this page · raw message

include/asm-x86_64/xor.h +4 -4
@@ -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 = 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"	\
-		: "=&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)
 

x86: make xor block handling uniform

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).

include/asm-i386/mach-xen/asm/xor.h new file +3 -0
@@ -0,0 +1,3 @@
+#include_next <asm/xor.h>
+
+#undef XOR_SELECT_TEMPLATE
include/asm-x86_64/mach-xen/asm/xor.h +11 -322

339 lines not on this page · raw message

include/asm-x86_64/xor.h +4 -4
@@ -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 = 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"	\
-		: "=&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)
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel