From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Virtual memory question
Date: Mon, 09 Aug 2010 11:46:06 -0500 [thread overview]
Message-ID: <4C6030CE.3080400@linux.vnet.ibm.com> (raw)
In-Reply-To: <AANLkTikv_Bi7uOX4GZh+de9XTcQMs4F8PdUJAZrbZsVt@mail.gmail.com>
On 08/09/2010 03:17 AM, Stefan Hajnoczi wrote:
>
> Use -mem-path /path/to/directory. It's used for hugetlbfs support on
> Linux but it should work on a normal filesystem too.
>
> Stefan
>
It *almost* works, except for some minor obstacles:
1) Normally the pages get mmap()'d with MAP_PRIVATE so they COW'd rather
than written to the backing file:
#ifdef MAP_POPULATE
/* NB: MAP_POPULATE won't exhaustively alloc all phys pages in the case
* MAP_PRIVATE is requested. For mem_prealloc we mmap as MAP_SHARED
* to sidestep this quirk.
*/
flags = mem_prealloc ? MAP_POPULATE | MAP_SHARED : MAP_PRIVATE;
area = mmap(0, memory, PROT_READ | PROT_WRITE, flags, fd, 0);
#else
area = mmap(0, memory, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
#endif
You can force a MAP_SHARED mapping without any changes to qemu by using
the -mem_prealloc option, but you'll get MAP_POPULATE as well, which may
not be desirable. A small patch would do the job though.
2) exec.c:file_ram_alloc() assumes you're allocating off a hugetlbfs and
makes some system calls to get the block/hugepage size. A quick hack
might be to comment out the following in exec.c:gethugepagesize():
if (fs.f_type != HUGETLBFS_MAGIC)
fprintf(stderr, "Warning: path not on HugeTLBFS: %s\n", path);
You may also want to replace the mkstemp() with a mkostemp() and set
O_SYNC on the file
But beyond hacks, I think generalizing -mempath might have some other
useful applications (using it as a way to expose tmpfs-backed/numactl'd
files as numa nodes to guests came up in an earlier discussion, and
memory compression via zram/compcache is another).
next prev parent reply other threads:[~2010-08-09 16:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-08 20:33 [Qemu-devel] Virtual memory question Dennis
2010-08-09 5:01 ` C K Kashyap
2010-08-09 18:49 ` Dennis
2010-08-09 19:41 ` Stefan Hajnoczi
2010-08-09 19:54 ` Dennis
2010-08-09 6:15 ` Mulyadi Santosa
2010-08-09 8:17 ` Stefan Hajnoczi
2010-08-09 16:46 ` Michael Roth [this message]
2010-08-09 18:49 ` Michael Roth
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=4C6030CE.3080400@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/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).