From: Kevin Easton <kevin@guarana.org>
To: Micha Nelissen <micha@neli.hopto.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Why is get_user_pages so slow?
Date: Thu, 12 Aug 2010 13:43:38 +1000 [thread overview]
Message-ID: <20100812134338.14856uchty1ra39c@guarana.org> (raw)
In-Reply-To: <4C61AD7A.7040400@neli.hopto.org>
Quoting Micha Nelissen <micha@neli.hopto.org>:
> Hi all,
>
> Why is get_user_pages much slower than taking the faults? (I would
> expect it to be faster).
>
> Attached example program first mallocs a piece of memory (64MB in
> this case) then reads it "to take the faults". Afterwards, it uses
> mmap with MAP_POPULATE to "speed up" and not to have to take the
> faults, but have everything mapped in one go. I think mmap is using
> get_user_pages in this case.
>
> $ ./memspeed
> malloc took 0 msecs
> read took 14 msecs
> write took 0 msecs
> free took 1 msecs
> mmap took 45 msecs
> munmap took 5 msecs
>
> Using MAP_POPULATE is 3 times as slow as the 'stupid'
> implementation! I'm running a Core 2 duo e6300 system with linux
> 2.6.28.4.
>
> Am I doing something wrong? MAP_POPULATE seems a bit of a joke to me.
Hi Micha,
Yep, you are. Because your pointer 'p' is a pointer to int, when you
increment it by 0x1000 in your loops you are actually incrementing it
by 0x1000 * sizeof(int) - so you're only actually touching one page in
four.
If you change the types of 'buf', 'p' and 'e' to 'char *' then it
touches every page - and (and least on my test box) the MAP_POPULATE
case pulls ahead.
- Kevin
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
next prev parent reply other threads:[~2010-08-12 3:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-10 19:50 Micha Nelissen
2010-08-12 3:43 ` Kevin Easton [this message]
2010-08-12 10:08 ` Micha Nelissen
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=20100812134338.14856uchty1ra39c@guarana.org \
--to=kevin@guarana.org \
--cc=linux-kernel@vger.kernel.org \
--cc=micha@neli.hopto.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
all inboxes | Powered by JetHome®