* [Qemu-devel] [patch uq/master 0/2] port qemu-kvm's -mem-path and -mem-prealloc to qemu
@ 2010-02-24 21:11 Marcelo Tosatti
2010-02-24 21:11 ` [Qemu-devel] [patch uq/master 1/2] Allocate memory below 4GB as one chunk Marcelo Tosatti
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2010-02-24 21:11 UTC (permalink / raw)
To: kvm, qemu-devel; +Cc: avi
-mem-path option allows file backed guest memory.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [patch uq/master 1/2] Allocate memory below 4GB as one chunk
2010-02-24 21:11 [Qemu-devel] [patch uq/master 0/2] port qemu-kvm's -mem-path and -mem-prealloc to qemu Marcelo Tosatti
@ 2010-02-24 21:11 ` Marcelo Tosatti
2010-02-25 13:33 ` [Qemu-devel] " Avi Kivity
2010-02-24 21:11 ` [Qemu-devel] [patch uq/master 2/2] Add option to use file backed guest memory Marcelo Tosatti
2010-02-25 13:32 ` [Qemu-devel] Re: [patch uq/master 0/2] port qemu-kvm's -mem-path and -mem-prealloc to qemu Avi Kivity
2 siblings, 1 reply; 8+ messages in thread
From: Marcelo Tosatti @ 2010-02-24 21:11 UTC (permalink / raw)
To: kvm, qemu-devel; +Cc: avi
[-- Attachment #1: one-4gb-area.patch --]
[-- Type: text/plain, Size: 1297 bytes --]
From: Avi Kivity <avi@redhat.com>
Instead of allocating a separate chunk for the first 640KB and another
for 1MB+, allocate one large chunk. This plays well in terms of alignment
and size with large pages.
Signed-off-by: Avi Kivity <avi@redhat.com>
(cherry picked from commit cfe0cef63988a7876a9bbcb098500a3983e63814)
Index: qemu-kvm/hw/pc.c
===================================================================
--- qemu-kvm.orig/hw/pc.c
+++ qemu-kvm/hw/pc.c
@@ -798,18 +798,11 @@ static void pc_init1(ram_addr_t ram_size
vmport_init();
/* allocate RAM */
- ram_addr = qemu_ram_alloc(0xa0000);
+ ram_addr = qemu_ram_alloc(below_4g_mem_size);
cpu_register_physical_memory(0, 0xa0000, ram_addr);
-
- /* Allocate, even though we won't register, so we don't break the
- * phys_ram_base + PA assumption. This range includes vga (0xa0000 - 0xc0000),
- * and some bios areas, which will be registered later
- */
- ram_addr = qemu_ram_alloc(0x100000 - 0xa0000);
- ram_addr = qemu_ram_alloc(below_4g_mem_size - 0x100000);
cpu_register_physical_memory(0x100000,
below_4g_mem_size - 0x100000,
- ram_addr);
+ ram_addr + 0x100000);
/* above 4giga memory allocation */
if (above_4g_mem_size > 0) {
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [patch uq/master 2/2] Add option to use file backed guest memory
2010-02-24 21:11 [Qemu-devel] [patch uq/master 0/2] port qemu-kvm's -mem-path and -mem-prealloc to qemu Marcelo Tosatti
2010-02-24 21:11 ` [Qemu-devel] [patch uq/master 1/2] Allocate memory below 4GB as one chunk Marcelo Tosatti
@ 2010-02-24 21:11 ` Marcelo Tosatti
2010-02-28 1:28 ` Paul Brook
2010-02-25 13:32 ` [Qemu-devel] Re: [patch uq/master 0/2] port qemu-kvm's -mem-path and -mem-prealloc to qemu Avi Kivity
2 siblings, 1 reply; 8+ messages in thread
From: Marcelo Tosatti @ 2010-02-24 21:11 UTC (permalink / raw)
To: kvm, qemu-devel; +Cc: john cooper, Marcelo Tosatti, avi
[-- Attachment #1: mempath --]
[-- Type: text/plain, Size: 6105 bytes --]
Port qemu-kvm's -mem-path and -mem-prealloc options. These are useful
for backing guest memory with huge pages via hugetlbfs.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
CC: john cooper <john.cooper@redhat.com>
Index: qemu-kvm/cpu-all.h
===================================================================
--- qemu-kvm.orig/cpu-all.h
+++ qemu-kvm/cpu-all.h
@@ -850,6 +850,9 @@ extern uint8_t *phys_ram_dirty;
extern ram_addr_t ram_size;
extern ram_addr_t last_ram_offset;
+extern const char *mem_path;
+extern int mem_prealloc;
+
/* physical memory access */
/* MMIO pages are identified by a combination of an IO device index and
Index: qemu-kvm/exec.c
===================================================================
--- qemu-kvm.orig/exec.c
+++ qemu-kvm/exec.c
@@ -2513,6 +2513,111 @@ void qemu_flush_coalesced_mmio_buffer(vo
kvm_flush_coalesced_mmio_buffer();
}
+#ifdef __linux__
+
+#include <sys/vfs.h>
+
+#define HUGETLBFS_MAGIC 0x958458f6
+
+static long gethugepagesize(const char *path)
+{
+ struct statfs fs;
+ int ret;
+
+ do {
+ ret = statfs(path, &fs);
+ } while (ret != 0 && errno == EINTR);
+
+ if (ret != 0) {
+ perror("statfs");
+ return 0;
+ }
+
+ if (fs.f_type != HUGETLBFS_MAGIC)
+ fprintf(stderr, "Warning: path not on HugeTLBFS: %s\n", path);
+
+ return fs.f_bsize;
+}
+
+static void *file_ram_alloc(ram_addr_t memory, const char *path)
+{
+ char *filename;
+ void *area;
+ int fd;
+#ifdef MAP_POPULATE
+ int flags;
+#endif
+ unsigned long hpagesize;
+
+ if (!path) {
+ return NULL;
+ }
+
+ hpagesize = gethugepagesize(path);
+ if (!hpagesize) {
+ return NULL;
+ }
+
+ if (memory < hpagesize) {
+ return NULL;
+ }
+
+ if (kvm_enabled() && !kvm_has_sync_mmu()) {
+ fprintf(stderr, "kvm: host lacks mmu notifiers, disabling -mem-path\n");
+ return NULL;
+ }
+
+ if (asprintf(&filename, "%s/kvm.XXXXXX", path) == -1) {
+ return NULL;
+ }
+
+ fd = mkstemp(filename);
+ if (fd < 0) {
+ perror("mkstemp");
+ free(filename);
+ return NULL;
+ }
+ unlink(filename);
+ free(filename);
+
+ memory = (memory+hpagesize-1) & ~(hpagesize-1);
+
+ /*
+ * ftruncate is not supported by hugetlbfs in older
+ * hosts, so don't bother checking for errors.
+ * If anything goes wrong with it under other filesystems,
+ * mmap will fail.
+ */
+ if (ftruncate(fd, memory))
+ perror("ftruncate");
+
+#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
+ if (area == MAP_FAILED) {
+ perror("file_ram_alloc: can't mmap RAM pages");
+ close(fd);
+ return (NULL);
+ }
+ return area;
+}
+
+#else
+
+static void *file_ram_alloc(ram_addr_t memory, const char *path)
+{
+ return NULL;
+}
+
+#endif
+
ram_addr_t qemu_ram_alloc(ram_addr_t size)
{
RAMBlock *new_block;
@@ -2520,16 +2625,20 @@ ram_addr_t qemu_ram_alloc(ram_addr_t siz
size = TARGET_PAGE_ALIGN(size);
new_block = qemu_malloc(sizeof(*new_block));
+ new_block->host = file_ram_alloc(size, mem_path);
+ if (!new_block->host) {
#if defined(TARGET_S390X) && defined(CONFIG_KVM)
- /* XXX S390 KVM requires the topmost vma of the RAM to be < 256GB */
- new_block->host = mmap((void*)0x1000000, size, PROT_EXEC|PROT_READ|PROT_WRITE,
- MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+ /* XXX S390 KVM requires the topmost vma of the RAM to be < 256GB */
+ new_block->host = mmap((void*)0x1000000, size,
+ PROT_EXEC|PROT_READ|PROT_WRITE,
+ MAP_SHARED | MAP_ANONYMOUS, -1, 0);
#else
- new_block->host = qemu_vmalloc(size);
+ new_block->host = qemu_vmalloc(size);
#endif
#ifdef MADV_MERGEABLE
- madvise(new_block->host, size, MADV_MERGEABLE);
+ madvise(new_block->host, size, MADV_MERGEABLE);
#endif
+ }
new_block->offset = last_ram_offset;
new_block->length = size;
Index: qemu-kvm/qemu-options.hx
===================================================================
--- qemu-kvm.orig/qemu-options.hx
+++ qemu-kvm/qemu-options.hx
@@ -314,6 +314,22 @@ a suffix of ``M'' or ``G'' can be used t
gigabytes respectively.
ETEXI
+DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
+ "-mem-path FILE provide backing storage for guest RAM\n")
+STEXI
+@item -mem-path @var{path}
+Allocate guest RAM from a temporarily created file in @var{path}.
+ETEXI
+
+#ifdef MAP_POPULATE
+DEF("mem-prealloc", 0, QEMU_OPTION_mem_prealloc,
+ "-mem-prealloc preallocate guest memory (use with -mem-path)\n")
+STEXI
+@item -mem-prealloc
+Preallocate memory when using -mem-path.
+ETEXI
+#endif
+
DEF("k", HAS_ARG, QEMU_OPTION_k,
"-k language use keyboard layout (for example 'fr' for French)\n")
STEXI
Index: qemu-kvm/vl.c
===================================================================
--- qemu-kvm.orig/vl.c
+++ qemu-kvm/vl.c
@@ -186,6 +186,10 @@ static DisplayState *display_state;
DisplayType display_type = DT_DEFAULT;
const char* keyboard_layout = NULL;
ram_addr_t ram_size;
+const char *mem_path = NULL;
+#ifdef MAP_POPULATE
+int mem_prealloc = 1; /* force preallocation of physical target memory */
+#endif
int nb_nics;
NICInfo nd_table[MAX_NICS];
int vm_running;
@@ -5252,6 +5256,13 @@ int main(int argc, char **argv, char **e
ram_size = value;
break;
}
+ case QEMU_OPTION_mempath:
+ mem_path = optarg;
+ break;
+#ifdef MAP_POPULATE
+ case QEMU_OPTION_mem_prealloc:
+ mem_prealloc = !mem_prealloc;
+#endif
case QEMU_OPTION_d:
{
int mask;
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] Re: [patch uq/master 0/2] port qemu-kvm's -mem-path and -mem-prealloc to qemu
2010-02-24 21:11 [Qemu-devel] [patch uq/master 0/2] port qemu-kvm's -mem-path and -mem-prealloc to qemu Marcelo Tosatti
2010-02-24 21:11 ` [Qemu-devel] [patch uq/master 1/2] Allocate memory below 4GB as one chunk Marcelo Tosatti
2010-02-24 21:11 ` [Qemu-devel] [patch uq/master 2/2] Add option to use file backed guest memory Marcelo Tosatti
@ 2010-02-25 13:32 ` Avi Kivity
2 siblings, 0 replies; 8+ messages in thread
From: Avi Kivity @ 2010-02-25 13:32 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: qemu-devel, kvm
On 02/24/2010 11:11 PM, Marcelo Tosatti wrote:
> -mem-path option allows file backed guest memory.
>
Applied, thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] Re: [patch uq/master 1/2] Allocate memory below 4GB as one chunk
2010-02-24 21:11 ` [Qemu-devel] [patch uq/master 1/2] Allocate memory below 4GB as one chunk Marcelo Tosatti
@ 2010-02-25 13:33 ` Avi Kivity
0 siblings, 0 replies; 8+ messages in thread
From: Avi Kivity @ 2010-02-25 13:33 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: qemu-devel, kvm
On 02/24/2010 11:11 PM, Marcelo Tosatti wrote:
> From: Avi Kivity<avi@redhat.com>
>
> Instead of allocating a separate chunk for the first 640KB and another
> for 1MB+, allocate one large chunk. This plays well in terms of alignment
> and size with large pages.
>
> Signed-off-by: Avi Kivity<avi@redhat.com>
> (cherry picked from commit cfe0cef63988a7876a9bbcb098500a3983e63814)
>
Note: qemu-kvm.git commit hashes are not meaningful in qemu.git, so
don't add them to uq commit logs please.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [patch uq/master 2/2] Add option to use file backed guest memory
2010-02-24 21:11 ` [Qemu-devel] [patch uq/master 2/2] Add option to use file backed guest memory Marcelo Tosatti
@ 2010-02-28 1:28 ` Paul Brook
2010-03-01 23:25 ` Marcelo Tosatti
0 siblings, 1 reply; 8+ messages in thread
From: Paul Brook @ 2010-02-28 1:28 UTC (permalink / raw)
To: qemu-devel; +Cc: john cooper, Marcelo Tosatti, avi, kvm
>+ /*
>+ * ftruncate is not supported by hugetlbfs in older
>+ * hosts, so don't bother checking for errors.
>+ * If anything goes wrong with it under other filesystems,
>+ * mmap will fail.
>+ */
>+ if (ftruncate(fd, memory))
>+ perror("ftruncate");
Code does not match comment.
>+ if (asprintf(&filename, "%s/kvm.XXXXXX", path) == -1) {
>+ return NULL;
>+ }
This isn't kvm any more :-)
>+ flags = mem_prealloc ? MAP_POPULATE|MAP_SHARED : MAP_PRIVATE;
Missing spaces round logic operator (plus several other occurrences).
>+static void *file_ram_alloc(ram_addr_t memory, const char *path)
>+{
>+ return NULL;
>+}
Silently ignoring commandline options is bad.
Especially as the other option you added (-mem-prealloc) causes an error if
not supported.
>+ if (kvm_enabled() && !kvm_has_sync_mmu()) {
>+ fprintf(stderr, "kvm: host lacks mmu notifiers, disabling
> -mem-path\n"); + return NULL;
>+ }
Code does not match error message. Users are liable to see this many times.
>+ new_block->host = file_ram_alloc(size, mem_path);
IMHO it would be better to check the mem_path != NULL here, rather that
burying the check in file_ram_alloc.
>+ if (memory < hpagesize) {
>+ return NULL;
>+ }
Ah, so it's actually "allocate memory in $path, if you feel like it". Good job
we aren't relying on this for correctness. At minimum I recommend documenting
this heuristic.
>+ if (!new_block->host) {
> #if defined(TARGET_S390X) && defined(CONFIG_KVM)
>- /* XXX S390 KVM requires the topmost vma of the RAM to be < 256GB */
By my reading this implies -mempath is probably broken on s390 KVM?
>+DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
>+ "-mem-path FILE provide backing storage for guest RAM\n")
>+STEXI
>+@item -mem-path @var{path}
>+Allocate guest RAM from a temporarily created file in @var{path}.
>+ETEXI
You should mention that this is only useful when PATH happens to be a linux
hugetlbfs mount.
>+#ifdef MAP_POPULATE
>+ case QEMU_OPTION_mem_prealloc:
>+ mem_prealloc = !mem_prealloc;
>+#endif
This looks highly suspect. Having redundant options toggle the sate seems
like a particularly bad UI.
Paul
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [patch uq/master 2/2] Add option to use file backed guest memory
2010-02-28 1:28 ` Paul Brook
@ 2010-03-01 23:25 ` Marcelo Tosatti
2010-03-01 23:32 ` Marcelo Tosatti
0 siblings, 1 reply; 8+ messages in thread
From: Marcelo Tosatti @ 2010-03-01 23:25 UTC (permalink / raw)
To: Paul Brook; +Cc: john cooper, qemu-devel, kvm, avi
Hi Paul,
Thank you for reviewing.
On Sun, Feb 28, 2010 at 01:28:16AM +0000, Paul Brook wrote:
> IMHO it would be better to check the mem_path != NULL here, rather that
> burying the check in file_ram_alloc.
>
> >+ if (memory < hpagesize) {
> >+ return NULL;
> >+ }
>
> Ah, so it's actually "allocate memory in $path, if you feel like it". Good job
> we aren't relying on this for correctness. At minimum I recommend documenting
> this heuristic.
More like "allocate memory in $path, if it its larger than a hugepage."
Huge pages are an optimization.
>
> >+ if (!new_block->host) {
> > #if defined(TARGET_S390X) && defined(CONFIG_KVM)
> >- /* XXX S390 KVM requires the topmost vma of the RAM to be < 256GB */
>
> By my reading this implies -mempath is probably broken on s390 KVM?
>
> >+DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
> >+ "-mem-path FILE provide backing storage for guest RAM\n")
> >+STEXI
> >+@item -mem-path @var{path}
> >+Allocate guest RAM from a temporarily created file in @var{path}.
> >+ETEXI
>
> You should mention that this is only useful when PATH happens to be a linux
> hugetlbfs mount.
It can be used with a file, since its mapped as MAP_PRIVATE.
Can you check whether the patch below properly addresses your concerns.
Add option to use file backed guest memory
Port qemu-kvm's -mem-path and -mem-prealloc options. These are useful
for backing guest memory with huge pages via hugetlbfs.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
CC: john cooper <john.cooper@redhat.com>
Index: qemu/cpu-all.h
===================================================================
--- qemu.orig/cpu-all.h
+++ qemu/cpu-all.h
@@ -847,6 +847,9 @@ extern uint8_t *phys_ram_dirty;
extern ram_addr_t ram_size;
extern ram_addr_t last_ram_offset;
+extern const char *mem_path;
+extern int mem_prealloc;
+
/* physical memory access */
/* MMIO pages are identified by a combination of an IO device index and
Index: qemu/exec.c
===================================================================
--- qemu.orig/exec.c
+++ qemu/exec.c
@@ -2529,6 +2529,99 @@ void qemu_flush_coalesced_mmio_buffer(vo
kvm_flush_coalesced_mmio_buffer();
}
+#if defined(__linux__) && !defined(TARGET_S390X)
+
+#include <sys/vfs.h>
+
+#define HUGETLBFS_MAGIC 0x958458f6
+
+static long gethugepagesize(const char *path)
+{
+ struct statfs fs;
+ int ret;
+
+ do {
+ ret = statfs(path, &fs);
+ } while (ret != 0 && errno == EINTR);
+
+ if (ret != 0) {
+ perror("statfs");
+ return 0;
+ }
+
+ if (fs.f_type != HUGETLBFS_MAGIC)
+ fprintf(stderr, "Warning: path not on HugeTLBFS: %s\n", path);
+
+ return fs.f_bsize;
+}
+
+static void *file_ram_alloc(ram_addr_t memory, const char *path)
+{
+ char *filename;
+ void *area;
+ int fd;
+#ifdef MAP_POPULATE
+ int flags;
+#endif
+ unsigned long hpagesize;
+
+ hpagesize = gethugepagesize(path);
+ if (!hpagesize) {
+ return NULL;
+ }
+
+ if (memory < hpagesize) {
+ return NULL;
+ }
+
+ if (kvm_enabled() && !kvm_has_sync_mmu()) {
+ fprintf(stderr, "host lacks kvm mmu notifiers, -mem-path unsupported\n");
+ return NULL;
+ }
+
+ if (asprintf(&filename, "%s/qemu_back_mem.XXXXXX", path) == -1) {
+ return NULL;
+ }
+
+ fd = mkstemp(filename);
+ if (fd < 0) {
+ perror("mkstemp");
+ free(filename);
+ return NULL;
+ }
+ unlink(filename);
+ free(filename);
+
+ memory = (memory+hpagesize-1) & ~(hpagesize-1);
+
+ /*
+ * ftruncate is not supported by hugetlbfs in older
+ * hosts, so don't bother bailing out on errors.
+ * If anything goes wrong with it under other filesystems,
+ * mmap will fail.
+ */
+ if (ftruncate(fd, memory))
+ perror("ftruncate");
+
+#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
+ if (area == MAP_FAILED) {
+ perror("file_ram_alloc: can't mmap RAM pages");
+ close(fd);
+ return (NULL);
+ }
+ return area;
+}
+#endif
+
ram_addr_t qemu_ram_alloc(ram_addr_t size)
{
RAMBlock *new_block;
@@ -2536,16 +2629,28 @@ ram_addr_t qemu_ram_alloc(ram_addr_t siz
size = TARGET_PAGE_ALIGN(size);
new_block = qemu_malloc(sizeof(*new_block));
+ if (mem_path) {
+#if defined (__linux__) && !defined(TARGET_S390X)
+ new_block->host = file_ram_alloc(size, mem_path);
+ if (!new_block->host)
+ exit(1);
+#else
+ fprintf(stderr, "-mem-path option unsupported\n");
+ exit(1);
+#endif
+ } else {
#if defined(TARGET_S390X) && defined(CONFIG_KVM)
- /* XXX S390 KVM requires the topmost vma of the RAM to be < 256GB */
- new_block->host = mmap((void*)0x1000000, size, PROT_EXEC|PROT_READ|PROT_WRITE,
- MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+ /* XXX S390 KVM requires the topmost vma of the RAM to be < 256GB */
+ new_block->host = mmap((void*)0x1000000, size,
+ PROT_EXEC|PROT_READ|PROT_WRITE,
+ MAP_SHARED | MAP_ANONYMOUS, -1, 0);
#else
- new_block->host = qemu_vmalloc(size);
+ new_block->host = qemu_vmalloc(size);
#endif
#ifdef MADV_MERGEABLE
- madvise(new_block->host, size, MADV_MERGEABLE);
+ madvise(new_block->host, size, MADV_MERGEABLE);
#endif
+ }
new_block->offset = last_ram_offset;
new_block->length = size;
Index: qemu/qemu-options.hx
===================================================================
--- qemu.orig/qemu-options.hx
+++ qemu/qemu-options.hx
@@ -314,6 +314,22 @@ a suffix of ``M'' or ``G'' can be used t
gigabytes respectively.
ETEXI
+DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
+ "-mem-path FILE provide backing storage for guest RAM\n")
+STEXI
+@item -mem-path @var{path}
+Allocate guest RAM from a temporarily created file in @var{path}.
+ETEXI
+
+#ifdef MAP_POPULATE
+DEF("mem-prealloc", 0, QEMU_OPTION_mem_prealloc,
+ "-mem-prealloc preallocate guest memory (use with -mem-path)\n")
+STEXI
+@item -mem-prealloc
+Preallocate memory when using -mem-path.
+ETEXI
+#endif
+
DEF("k", HAS_ARG, QEMU_OPTION_k,
"-k language use keyboard layout (for example 'fr' for French)\n")
STEXI
Index: qemu/vl.c
===================================================================
--- qemu.orig/vl.c
+++ qemu/vl.c
@@ -185,6 +185,10 @@ enum vga_retrace_method vga_retrace_meth
DisplayType display_type = DT_DEFAULT;
const char* keyboard_layout = NULL;
ram_addr_t ram_size;
+const char *mem_path = NULL;
+#ifdef MAP_POPULATE
+int mem_prealloc = 0; /* force preallocation of physical target memory */
+#endif
int nb_nics;
NICInfo nd_table[MAX_NICS];
int vm_running;
@@ -5216,6 +5220,14 @@ int main(int argc, char **argv, char **e
ram_size = value;
break;
}
+ case QEMU_OPTION_mempath:
+ mem_path = optarg;
+ break;
+#ifdef MAP_POPULATE
+ case QEMU_OPTION_mem_prealloc:
+ mem_prealloc = 1;
+ break;
+#endif
case QEMU_OPTION_d:
{
int mask;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [patch uq/master 2/2] Add option to use file backed guest memory
2010-03-01 23:25 ` Marcelo Tosatti
@ 2010-03-01 23:32 ` Marcelo Tosatti
0 siblings, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2010-03-01 23:32 UTC (permalink / raw)
To: Paul Brook; +Cc: john cooper, qemu-devel, kvm, avi
On Mon, Mar 01, 2010 at 08:25:08PM -0300, Marcelo Tosatti wrote:
> Hi Paul,
>
> Thank you for reviewing.
>
> On Sun, Feb 28, 2010 at 01:28:16AM +0000, Paul Brook wrote:
> > IMHO it would be better to check the mem_path != NULL here, rather that
> > burying the check in file_ram_alloc.
> >
> > >+ if (memory < hpagesize) {
> > >+ return NULL;
> > >+ }
> >
> > Ah, so it's actually "allocate memory in $path, if you feel like it". Good job
> > we aren't relying on this for correctness. At minimum I recommend documenting
> > this heuristic.
>
> More like "allocate memory in $path, if it its larger than a hugepage."
>
> Huge pages are an optimization.
>
> >
> > >+ if (!new_block->host) {
> > > #if defined(TARGET_S390X) && defined(CONFIG_KVM)
> > >- /* XXX S390 KVM requires the topmost vma of the RAM to be < 256GB */
> >
> > By my reading this implies -mempath is probably broken on s390 KVM?
> >
> > >+DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
> > >+ "-mem-path FILE provide backing storage for guest RAM\n")
> > >+STEXI
> > >+@item -mem-path @var{path}
> > >+Allocate guest RAM from a temporarily created file in @var{path}.
> > >+ETEXI
> >
> > You should mention that this is only useful when PATH happens to be a linux
> > hugetlbfs mount.
>
> It can be used with a file, since its mapped as MAP_PRIVATE.
I meant non hugetlbfs backed file.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-03-01 23:33 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-24 21:11 [Qemu-devel] [patch uq/master 0/2] port qemu-kvm's -mem-path and -mem-prealloc to qemu Marcelo Tosatti
2010-02-24 21:11 ` [Qemu-devel] [patch uq/master 1/2] Allocate memory below 4GB as one chunk Marcelo Tosatti
2010-02-25 13:33 ` [Qemu-devel] " Avi Kivity
2010-02-24 21:11 ` [Qemu-devel] [patch uq/master 2/2] Add option to use file backed guest memory Marcelo Tosatti
2010-02-28 1:28 ` Paul Brook
2010-03-01 23:25 ` Marcelo Tosatti
2010-03-01 23:32 ` Marcelo Tosatti
2010-02-25 13:32 ` [Qemu-devel] Re: [patch uq/master 0/2] port qemu-kvm's -mem-path and -mem-prealloc to qemu Avi Kivity
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).