Question about memcpy
bing zhu
zhubohong12 at gmail.com
Tue Jul 10 10:51:34 EDT 2018
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.
2018-07-10 14:22 GMT+08:00 Greg KH <greg at kroah.com>:
> On Tue, Jul 10, 2018 at 12:50:21PM +0800, bing zhu wrote:
> > I agree !,just i think the problem is still there,memcpy is indeed
> faster in
> > kernel than in user,i've tried both ways .
>
> Make sure you are actually using the same code for memcpy in both
> places. Do not rely on your libc or the kernel library for such a
> thing, otherwise you are not comparing the same code exactly.
>
> > schedule might be to blame.
>
> Lots of things "might be to blame", but first off, try to work out
> exactly what you are trying to test, and why, and work on that.
>
> good luck!
>
> greg k-h
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20180710/30970b5b/attachment.html>
More information about the Kernelnewbies
mailing list