* Transparent Huge Pages
@ 2013-02-07 16:32 Michael Tokarev
0 siblings, 0 replies; only message in thread
From: Michael Tokarev @ 2013-02-07 16:32 UTC (permalink / raw)
To: Linux-kernel; +Cc: Serge Hallyn
Hello.
I'm trying to understand how to use transparent huge pages
(currently in x86). Before I used "explicit" huge pages
alot (mostly about hugetlbfs), but it looked like THP should
be easier so I gave it a try.
This tiny program:
----- cut -----
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <errno.h>
#include <string.h>
int main(int argc, char **argv) {
void *ptr;
size_t len = argv[1] ? atoi(argv[1]) : 1024*1024*1024;
/* no error checking! */
posix_memalign(&ptr, 2048*1024, len);
madvise(ptr, len, MADV_HUGEPAGE);
memset(ptr, 0, len);
usleep(500); /* let khugepagesd do its work */
system("grep ^AnonHugePages: /proc/meminfo");
return 0;
}
----- cut -----
which just tries to allocate some amount of RAM (1Gb by default)
aligned to 2Mb, uses madvise(HUGEPAGE) on it, and checks
/proc/meminfo for AnonHugePages.
The problem is: I've never seen any value for AnonHugePages
larger than about 16Mb. Usually it is around 10Mb or 8Mb,
no matter how large the requested memory size is, including
the default 1Gb.
The question, obviously, is: why so small?
My system (which is a few years old now) has 6Gb of RAM,
it uses AMD Athlon II X2 260 CPU, and is running 3.2
kernel.
Original question comes from grounds of of QEMU, which is
supposed to use THP for guest memory, but it also does not
use more than these ~10Mb, when allocating 1Gb to the guest.
Thanks!
/mjt
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-02-07 16:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-07 16:32 Transparent Huge Pages Michael Tokarev
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®