Question about memcpy
Greg KH
greg at kroah.com
Tue Jul 10 10:57:48 EDT 2018
On Tue, Jul 10, 2018 at 10:51:34PM +0800, bing zhu wrote:
> Thank you ,I use this func for both kernel and user ,result are same.
> void *memcpy(void *dest, const void *src, size_t n)
> {
> long d0, d1, d2;
> asm volatile(
> "rep ; movsq\n\t"
> "movq %4,%%rcx\n\t"
> "rep ; movsb\n\t"
> : "=&c" (d0), "=&D" (d1), "=&S" (d2)
> : "0" (n >> 3), "g" (n & 7), "1" (dest), "2" (src)
> : "memory");
>
> return dest;
> }
> kernel is indeed faster than user.
Ok, and that is due to the fact that the kernel thread does not get
scheduled, unlike your userspace program. So this means the kernel is
working as designed :)
greg k-h
More information about the Kernelnewbies
mailing list