diff options
author | Soren Sandmann <sandmann@redhat.com> | 2008-02-16 15:54:40 +0000 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@src.gnome.org> | 2008-02-16 15:54:40 +0000 |
commit | 9d2f7a1a9d52115976b7268bd0ac6b2320ec3e3a (patch) | |
tree | 888a5cfbbbb5095d84e6e34f200c36e5385a2cb6 /module | |
parent | 64d220e3466c1e48caa853f154ea29bc224e6066 (diff) |
Add a memcpy() that uses nontemporal writes. (copy_kernel_stack): Add
2008-02-16 Soren Sandmann <sandmann@redhat.com>
* module/sysprof-module.c (nt_memcpy): Add a memcpy() that uses
nontemporal writes.
(copy_kernel_stack): Add commented-out use of it here.
svn path=/trunk/; revision=396
Diffstat (limited to 'module')
-rw-r--r-- | module/sysprof-module.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/module/sysprof-module.c b/module/sysprof-module.c index d5dfe9e..94a67ad 100644 --- a/module/sysprof-module.c +++ b/module/sysprof-module.c @@ -112,6 +112,38 @@ minimum (int a, int b) return a > b ? b : a; } +static void +nt_memcpy (void *dst, void *src, int n_bytes) +{ +#if defined(CONFIG_X86_64) || defined(CONFIG_X86) + if (((unsigned long)dst & 3) || + ((unsigned long)src & 3)) { + memcpy (dst, src, n_bytes); + } + else { + int i; + if ((unsigned long)src & 7) { + *(uint32_t *)dst = *(uint32_t *)src; + src += 4; + dst += 4; + } + + for (i = 0; i < n_bytes; i += 8) { + __asm__ __volatile__ ( + " movq (%0, %2), %%mm0\n" + " movntq %%mm0, (%1, %2)\n" + : + : "r" (src), "r" (dst), "r" (i) + : "memory"); + } + __asm__ __volatile__ ( + "emms\n"); + } +#else + memcpy (dst, src, n_bytes); +#endif +} + static struct pt_regs * copy_kernel_stack (struct pt_regs *regs, SysprofStackTrace *trace) @@ -137,6 +169,9 @@ copy_kernel_stack (struct pt_regs *regs, sizeof (trace->kernel_stack)); if (n_bytes > 0) { +#if 0 + nt_memcpy (&(trace->kernel_stack[1]), esp, n_bytes); +#endif memcpy (&(trace->kernel_stack[1]), esp, n_bytes); trace->n_kernel_words += (n_bytes) / sizeof (void *); @@ -203,7 +238,7 @@ heuristic_trace (struct pt_regs *regs, if (vma && vma->vm_flags & VM_EXEC) if (vma->vm_start <= x && x <= vma->vm_end) - trace->addresses[j++] = x; + trace->addresses[j++] = (void *)x; } #if 0 |