aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/boot/compressed/misc.c
diff options
context:
space:
mode:
authorZhao Yakui <yakui.zhao@intel.com>2010-10-07 21:47:33 -0400
committerH. Peter Anvin <hpa@zytor.com>2010-10-08 00:23:09 -0400
commit68f4d5a00adaab33b136fce2c72d5c377b39b0b0 (patch)
treedfd0404f760ca8ab117117e4388885255b47013b /arch/x86/boot/compressed/misc.c
parentcb655d0f3d57c23db51b981648e452988c0223f9 (diff)
x86, setup: Use string copy operation to optimze copy in kernel compression
The kernel decompression code parses the ELF header and then copies the segment to the corresponding destination. Currently it uses slow byte-copy code. This patch makes it use the string copy operations instead. In the test the copy performance can be improved very significantly after using the string copy operation mechanism. 1. The copy time can be reduced from 150ms to 20ms on one Atom machine 2. The copy time can be reduced about 80% on another machine The time is reduced from 7ms to 1.5ms when using 32-bit kernel. The time is reduced from 10ms to 2ms when using 64-bit kernel. Signed-off-by: Zhao Yakui <yakui.zhao@intel.com> LKML-Reference: <1286502453-7043-1-git-send-email-yakui.zhao@intel.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/boot/compressed/misc.c')
-rw-r--r--arch/x86/boot/compressed/misc.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 8f7bef8e9ff..23f315c9f21 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -229,18 +229,35 @@ void *memset(void *s, int c, size_t n)
229 ss[i] = c; 229 ss[i] = c;
230 return s; 230 return s;
231} 231}
232 232#ifdef CONFIG_X86_32
233void *memcpy(void *dest, const void *src, size_t n) 233void *memcpy(void *dest, const void *src, size_t n)
234{ 234{
235 int i; 235 int d0, d1, d2;
236 const char *s = src; 236 asm volatile(
237 char *d = dest; 237 "rep ; movsl\n\t"
238 "movl %4,%%ecx\n\t"
239 "rep ; movsb\n\t"
240 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
241 : "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src)
242 : "memory");
238 243
239 for (i = 0; i < n; i++)
240 d[i] = s[i];
241 return dest; 244 return dest;
242} 245}
246#else
247void *memcpy(void *dest, const void *src, size_t n)
248{
249 long d0, d1, d2;
250 asm volatile(
251 "rep ; movsq\n\t"
252 "movq %4,%%rcx\n\t"
253 "rep ; movsb\n\t"
254 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
255 : "0" (n >> 3), "g" (n & 7), "1" (dest), "2" (src)
256 : "memory");
243 257
258 return dest;
259}
260#endif
244 261
245static void error(char *x) 262static void error(char *x)
246{ 263{