Question about memcpy

袁建鹏 yuanjp at hust.edu.cn
Mon Jul 9 03:54:05 EDT 2018


can you show all code kernel and userspace ?

Kernel compile options are optimized, very different from userspace.

you can use the same object (memcpy.o) to link userspace program and kernel module.

-----原始邮件-----
发件人:"bing zhu" <zhubohong12 at gmail.com>
发送时间:2018-07-08 22:03:48 (星期日)
收件人: "Valdis Kletnieks" <valdis.kletnieks at vt.edu>
抄送: kernelnewbies at kernelnewbies.org
主题: Re: Question about memcpy


void *p = malloc(4096 * max);
start = usec();
for (i = 0; i < max; i++) {
memcpy(p + i * 4096, page, 4096);
}
end = usec();
printf("%s : %d time use %lu us \n", __func__, max,end - start);


static unsigned long usec(void)
{
        struct timeval tv;
        gettimeofday(&tv, 0);
        return (unsigned long)tv.tv_sec * 1000000 + tv.tv_usec;
}




I'm don't think it's really precise but i did notice a difference ,


2018-07-08 2:44 GMT+08:00 <valdis.kletnieks at vt.edu>:
On Sat, 07 Jul 2018 19:36:47 +0800, bing zhu said:

> and in user space i do the same thing,I noticed that kernel is faster than
> user ,

How did you measure the times? Doing this right is actually harder than it looks...


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20180709/fc177327/attachment.html>


More information about the Kernelnewbies mailing list