From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Question about memcpy
Date: Tue, 10 Jul 2018 16:57:48 +0200 [thread overview]
Message-ID: <20180710145748.GA16629@kroah.com> (raw)
In-Reply-To: <CACdNawrZxMSGT5he7Vnhy0e6kz1MAOT7G2fNUPFs9gUx8G2duA@mail.gmail.com>
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
next prev parent reply other threads:[~2018-07-10 14:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-07 11:36 Question about memcpy bing zhu
2018-07-07 18:44 ` valdis.kletnieks at vt.edu
2018-07-08 14:03 ` bing zhu
2018-07-09 7:54 ` 袁建鹏
2018-07-09 8:14 ` bing zhu
2018-07-09 14:04 ` Himanshu Jha
2018-07-09 16:16 ` valdis.kletnieks at vt.edu
2018-07-14 10:10 ` Himanshu Jha
2018-07-10 4:50 ` bing zhu
2018-07-10 6:22 ` Greg KH
2018-07-10 14:51 ` bing zhu
2018-07-10 14:57 ` Greg KH [this message]
2018-07-10 16:03 ` valdis.kletnieks at vt.edu
2018-07-12 4:47 ` bing zhu
2018-07-12 5:34 ` Greg KH
2018-07-12 14:27 ` bing zhu
2018-07-12 14:53 ` Greg KH
2018-07-13 3:02 ` bing zhu
2018-07-13 7:33 ` valdis.kletnieks at vt.edu
2018-07-17 2:44 ` bing zhu
2018-07-12 16:49 ` valdis.kletnieks at vt.edu
-- strict thread matches above, loose matches on Subject: below --
2018-07-07 13:21 Alex Arvelaez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180710145748.GA16629@kroah.com \
--to=greg@kroah.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).