<span style="font-size:14px;white-space:normal;">can you show all code kernel and userspace ?</span>
<p style="font-size:14px;white-space:normal;">
        Kernel compile options are optimized, very different from userspace.
</p>
<p style="font-size:14px;white-space:normal;">
        you can use the same object (memcpy.o) to link userspace program and kernel module.
</p>
<div>
</div>
<blockquote name="replyContent" class="ReferenceQuote" style="padding-left:5px;margin-left:5px;border-left:#b6b6b6 2px solid;margin-right:0;">
        -----原始邮件-----<br>
<b>发件人:</b><span id="rc_from">"bing zhu" <zhubohong12@gmail.com></span><br>
<b>发送时间:</b><span id="rc_senttime">2018-07-08 22:03:48 (星期日)</span><br>
<b>收件人:</b> "Valdis Kletnieks" <valdis.kletnieks@vt.edu><br>
<b>抄送:</b> kernelnewbies@kernelnewbies.org<br>
<b>主题:</b> Re: Question about memcpy<br>
<br>
        <div dir="ltr">
                <div>
                        void *p = malloc(4096 * max);
                </div>
                <div>
                        start = usec();
                </div>
                <div>
                        for (i = 0; i < max; i++) {
                </div>
                <div>
                        memcpy(p + i * 4096, page, 4096);
                </div>
                <div>
                        }
                </div>
                <div>
                        end = usec();
                </div>
                <div>
                        printf("%s : %d time use %lu us \n", __func__, max,end - start);
                </div>
                <div>
                        <br>
                </div>
                <div>
                        static unsigned long usec(void)
                </div>
                <div>
                        {
                </div>
                <div>
                                struct timeval tv;
                </div>
                <div>
                                gettimeofday(&tv, 0);
                </div>
                <div>
                                return (unsigned long)tv.tv_sec * 1000000 + tv.tv_usec;
                </div>
                <div>
                        }
                </div>
                <div>
                        <br>
                </div>
                <div>
                        <br>
                </div>
                <div>
                        I'm don't think it's really precise but i did notice a difference ,
                </div>
        </div>
        <div class="gmail_extra">
                <br>
                <div class="gmail_quote">
                        2018-07-08 2:44 GMT+08:00 <span dir="ltr"><<a href="mailto:valdis.kletnieks@vt.edu" target="_blank">valdis.kletnieks@vt.edu</a>></span>:<br>
                        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
                                <span class="">On Sat, 07 Jul 2018 19:36:47 +0800, bing zhu said:<br>
<br>
> and in user space i do the same thing,I noticed that kernel is faster than<br>
> user ,<br>
<br>
</span>How did you measure the times? Doing this right is actually harder than it looks...<br>
                        </blockquote>
                </div>
<br>
        </div>
</blockquote>