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 03 of 10] Optimize memcpy for x86 arch. If source buf

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 03 of 10] Optimize memcpy for x86 arch. If source buffers does not start at a 64
From: <steven.smith@xxxxxxxxxx>
Date: Sun, 4 Oct 2009 16:00:33 +0100
Cc: keir.fraser@xxxxxxxxxx, joserenato.santos@xxxxxx
Delivery-date: Sun, 04 Oct 2009 08:02:39 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1254668430@xxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User root@xxxxxxxxxxxxxxxx
# Date 1221082224 25200
# Node ID 999da363259a122e0c15bf28a0885ec40751e906
# Parent  c630fa8e84bdb0e1a79f7ccc42733ef5ea247cd2
Optimize memcpy for x86 arch. If source buffers does not start at a 64
bit boundary, copy a few bytes at the beginnig up to next 64-bit
boundary and then does an aligned copy for the remaining data. This
can reduce the copy cost by up to 50%.

Signed-off-by: Jose Renato Santos <jsantos@xxxxxxxxxx>

diff -r c630fa8e84bd -r 999da363259a xen/include/asm-x86/string.h
--- a/xen/include/asm-x86/string.h      Mon Sep 22 12:23:27 2008 +0100
+++ b/xen/include/asm-x86/string.h      Wed Sep 10 14:30:24 2008 -0700
@@ -96,13 +96,29 @@
 }
 
 #define __HAVE_ARCH_MEMCPY
+/* align source to a 64-bit boundary */
+static always_inline
+void *__var_memcpy(void *t, const void *f, size_t n)
+{
+    int off = (unsigned long)f & 0x7;
+    /* just do alignment if needed and if size is worth */
+    if ( (n > 32) && off ) {
+        size_t n1 = 8 - off;
+        __variable_memcpy(t, f, n1);
+        __variable_memcpy(t + n1, f + n1, n - n1);
+        return t;
+    } else {
+            return (__variable_memcpy(t, f, n));
+    }
+}
+
 #define memcpy(t,f,n) (__memcpy((t),(f),(n)))
 static always_inline
 void *__memcpy(void *t, const void *f, size_t n)
 {
     return (__builtin_constant_p(n) ?
             __constant_memcpy((t),(f),(n)) :
-            __variable_memcpy((t),(f),(n)));
+            __var_memcpy((t),(f),(n)));
 }
 
 /* Some version of gcc don't have this builtin. It's non-critical anyway. */
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel