public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* Remove qemu_alloc_physram()
@ 2009-05-27 10:08 nicolas prochazka
  2009-05-27 12:50 ` Avi Kivity
  0 siblings, 1 reply; 9+ messages in thread
From: nicolas prochazka @ 2009-05-27 10:08 UTC (permalink / raw)
  To: kvm

Hello,
Since this patch :
http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commit;h=0e8d16ba06486ebf79f131f28121774715975248
Remove qemu_alloc_physram()
Obsolete.

function alloc_mem_area(memory, &map_len, mem_path);  is never calling in code,
and it seems that's  -mem-path ( or -mempath) /hugepages  does not
work for me now.
before this patch, i can see for example in /proc/meminfo :
HugePages_Total:  2560
HugePages_Free:   2301
when i start one kvm/qemu

now , HupePages_Free never down , hugepages_free = hugepages_total.




Regards,
Nicolas .

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Remove qemu_alloc_physram()
  2009-05-27 10:08 Remove qemu_alloc_physram() nicolas prochazka
@ 2009-05-27 12:50 ` Avi Kivity
  2009-05-27 13:30   ` nicolas prochazka
  0 siblings, 1 reply; 9+ messages in thread
From: Avi Kivity @ 2009-05-27 12:50 UTC (permalink / raw)
  To: nicolas prochazka; +Cc: kvm

[-- Attachment #1: Type: text/plain, Size: 688 bytes --]

nicolas prochazka wrote:
> Hello,
> Since this patch :
> http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commit;h=0e8d16ba06486ebf79f131f28121774715975248
> Remove qemu_alloc_physram()
> Obsolete.
>
> function alloc_mem_area(memory, &map_len, mem_path);  is never calling in code,
> and it seems that's  -mem-path ( or -mempath) /hugepages  does not
> work for me now.
> before this patch, i can see for example in /proc/meminfo :
> HugePages_Total:  2560
> HugePages_Free:   2301
> when i start one kvm/qemu
>
> now , HupePages_Free never down , hugepages_free = hugepages_total.
>
>   

Please test the attached patch.

-- 
error compiling committee.c: too many arguments to function


[-- Attachment #2: mem-path.patch --]
[-- Type: text/x-patch, Size: 6362 bytes --]

diff --git a/exec.c b/exec.c
index e241f05..c024b8b 100644
--- a/exec.c
+++ b/exec.c
@@ -2484,6 +2484,113 @@ static ram_addr_t kqemu_ram_alloc(ram_addr_t size)
 }
 #endif
 
+#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;
+    extern int mem_prealloc;
+
+    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, "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.
+     */
+    ftruncate(fd, memory);
+
+#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("alloc_mem_area: can't mmap hugetlbfs pages");
+	close(fd);
+	return (NULL);
+    }
+    return area;
+}
+
+#else
+
+static void *file_ram_alloc(ram_addr_t memory, const char *path)
+{
+    return NULL;
+}
+
+#endif
+
+extern const char *mem_path;
+
 ram_addr_t qemu_ram_alloc(ram_addr_t size)
 {
     RAMBlock *new_block;
@@ -2497,7 +2604,10 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size)
     size = TARGET_PAGE_ALIGN(size);
     new_block = qemu_malloc(sizeof(*new_block));
 
-    new_block->host = qemu_vmalloc(size);
+    new_block->host = file_ram_alloc(size, mem_path);
+    if (!new_block->host) {
+        new_block->host = qemu_vmalloc(size);
+    }
     new_block->offset = last_ram_offset;
     new_block->length = size;
 
diff --git a/hw/pc.c b/hw/pc.c
index 9e99b7c..585a4ef 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -914,14 +914,6 @@ static void pc_init1(ram_addr_t ram_size,
         hw_error("To much RAM for 32-bit physical address");
 #else
         ram_addr = qemu_ram_alloc(above_4g_mem_size);
-        if (hpagesize) {
-            if (ram_addr & (hpagesize-1)) {
-                unsigned long aligned_addr;
-                aligned_addr = (ram_addr + hpagesize - 1) & ~(hpagesize-1);
-                qemu_ram_alloc(aligned_addr - ram_addr);
-                ram_addr = aligned_addr;
-            }
-        }
         cpu_register_physical_memory(0x100000000ULL,
                                      above_4g_mem_size,
                                      ram_addr);
diff --git a/vl.c b/vl.c
index db8265b..8aea7d6 100644
--- a/vl.c
+++ b/vl.c
@@ -41,7 +41,6 @@
 #include <sys/ioctl.h>
 #include <sys/resource.h>
 #include <sys/socket.h>
-#include <sys/vfs.h>
 #include <netinet/in.h>
 #include <net/if.h>
 #if defined(__NetBSD__)
@@ -268,7 +267,6 @@ const char *mem_path = NULL;
 #ifdef MAP_POPULATE
 int mem_prealloc = 1;	/* force preallocation of physical target memory */
 #endif
-long hpagesize = 0;
 #ifdef TARGET_ARM
 int old_param = 0;
 #endif
@@ -4856,90 +4854,6 @@ int qemu_uuid_parse(const char *str, uint8_t *uuid)
 
 #define MAX_NET_CLIENTS 32
 
-#ifdef USE_KVM
-
-#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 *alloc_mem_area(size_t memory, unsigned long *len, const char *path)
-{
-    char *filename;
-    void *area;
-    int fd;
-#ifdef MAP_POPULATE
-    int flags;
-#endif
-
-    if (!kvm_has_sync_mmu()) {
-        fprintf(stderr, "host lacks mmu notifiers, disabling --mem-path\n");
-        return NULL;
-    }
-
-    if (asprintf(&filename, "%s/kvm.XXXXXX", path) == -1)
-	return NULL;
-
-    hpagesize = gethugepagesize(path);
-    if (!hpagesize)
-	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.
-     */
-    ftruncate(fd, memory);
-
-#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("alloc_mem_area: can't mmap hugetlbfs pages");
-	close(fd);
-	return (NULL);
-    }
-    *len = memory;
-    return area;
-}
-#endif
-
 #ifndef _WIN32
 
 static void termsig_handler(int signal)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: Remove qemu_alloc_physram()
  2009-05-27 12:50 ` Avi Kivity
@ 2009-05-27 13:30   ` nicolas prochazka
  2009-05-27 13:40     ` nicolas prochazka
  0 siblings, 1 reply; 9+ messages in thread
From: nicolas prochazka @ 2009-05-27 13:30 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

hello again,
after applying patch :

HugePages_Total:  2560
HugePages_Free:   2558
HugePages_Rsvd:    262
HugePages_Surp:      0
Hugepagesize:     2048 kB

with a running command :
/usr/local/bin/qemu  -localtime -usb -usbdevice tablet -net
vde,vlan=0,sock=/tmpsafe/switch -vnc 10.98.98.1:111 -monitor
tcp:127.0.0.1:10111,server,nowait,nodelay -vga std -m 512 -net
nic,vlan=0,macaddr=ac:de:48:44:d3:d7,model=e1000 -drive
file=windowsxp,boot=on,snapshot=on -mem-prealloc -mempath /hugepages
-no-kvm-irqchip -startdate now

only 2 pages are used ?  qemu runs for 30 minutes.

2009/5/27 Avi Kivity <avi@redhat.com>:
> nicolas prochazka wrote:
>>
>> Hello,
>> Since this patch :
>>
>> http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commit;h=0e8d16ba06486ebf79f131f28121774715975248
>> Remove qemu_alloc_physram()
>> Obsolete.
>>
>> function alloc_mem_area(memory, &map_len, mem_path);  is never calling in
>> code,
>> and it seems that's  -mem-path ( or -mempath) /hugepages  does not
>> work for me now.
>> before this patch, i can see for example in /proc/meminfo :
>> HugePages_Total:  2560
>> HugePages_Free:   2301
>> when i start one kvm/qemu
>>
>> now , HupePages_Free never down , hugepages_free = hugepages_total.
>>
>>
>
> Please test the attached patch.
>
> --
> error compiling committee.c: too many arguments to function
>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Remove qemu_alloc_physram()
  2009-05-27 13:30   ` nicolas prochazka
@ 2009-05-27 13:40     ` nicolas prochazka
  2009-05-27 13:59       ` Avi Kivity
  0 siblings, 1 reply; 9+ messages in thread
From: nicolas prochazka @ 2009-05-27 13:40 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

without -mem-prealloc
HugePages_Total:  2560
HugePages_Free:   2296
HugePages_Rsvd:      0

so after minimum test, i can say that's your patch seems to be correct
this problem.
Thanks.
Nicolas

2009/5/27 nicolas prochazka <prochazka.nicolas@gmail.com>:
> hello again,
> after applying patch :
>
> HugePages_Total:  2560
> HugePages_Free:   2558
> HugePages_Rsvd:    262
> HugePages_Surp:      0
> Hugepagesize:     2048 kB
>
> with a running command :
> /usr/local/bin/qemu  -localtime -usb -usbdevice tablet -net
> vde,vlan=0,sock=/tmpsafe/switch -vnc 10.98.98.1:111 -monitor
> tcp:127.0.0.1:10111,server,nowait,nodelay -vga std -m 512 -net
> nic,vlan=0,macaddr=ac:de:48:44:d3:d7,model=e1000 -drive
> file=windowsxp,boot=on,snapshot=on -mem-prealloc -mempath /hugepages
> -no-kvm-irqchip -startdate now
>
> only 2 pages are used ?  qemu runs for 30 minutes.
>
> 2009/5/27 Avi Kivity <avi@redhat.com>:
>> nicolas prochazka wrote:
>>>
>>> Hello,
>>> Since this patch :
>>>
>>> http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commit;h=0e8d16ba06486ebf79f131f28121774715975248
>>> Remove qemu_alloc_physram()
>>> Obsolete.
>>>
>>> function alloc_mem_area(memory, &map_len, mem_path);  is never calling in
>>> code,
>>> and it seems that's  -mem-path ( or -mempath) /hugepages  does not
>>> work for me now.
>>> before this patch, i can see for example in /proc/meminfo :
>>> HugePages_Total:  2560
>>> HugePages_Free:   2301
>>> when i start one kvm/qemu
>>>
>>> now , HupePages_Free never down , hugepages_free = hugepages_total.
>>>
>>>
>>
>> Please test the attached patch.
>>
>> --
>> error compiling committee.c: too many arguments to function
>>
>>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Remove qemu_alloc_physram()
  2009-05-27 13:40     ` nicolas prochazka
@ 2009-05-27 13:59       ` Avi Kivity
  2009-05-27 16:22         ` Avi Kivity
  0 siblings, 1 reply; 9+ messages in thread
From: Avi Kivity @ 2009-05-27 13:59 UTC (permalink / raw)
  To: nicolas prochazka; +Cc: kvm

nicolas prochazka wrote:
> without -mem-prealloc
> HugePages_Total:  2560
> HugePages_Free:   2296
> HugePages_Rsvd:      0
>
> so after minimum test, i can say that's your patch seems to be correct
> this problem.
>   

It isn't correct, it doesn't generate the right alignment.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Remove qemu_alloc_physram()
  2009-05-27 13:59       ` Avi Kivity
@ 2009-05-27 16:22         ` Avi Kivity
  2009-05-28  9:25           ` nicolas prochazka
  2009-05-28 21:53           ` Ryan Harper
  0 siblings, 2 replies; 9+ messages in thread
From: Avi Kivity @ 2009-05-27 16:22 UTC (permalink / raw)
  To: nicolas prochazka; +Cc: kvm

[-- Attachment #1: Type: text/plain, Size: 402 bytes --]

Avi Kivity wrote:
> nicolas prochazka wrote:
>> without -mem-prealloc
>> HugePages_Total:  2560
>> HugePages_Free:   2296
>> HugePages_Rsvd:      0
>>
>> so after minimum test, i can say that's your patch seems to be correct
>> this problem.
>>   
>
> It isn't correct, it doesn't generate the right alignment.
>
Better patch attached.

-- 
error compiling committee.c: too many arguments to function


[-- Attachment #2: mem-path.patch --]
[-- Type: text/x-patch, Size: 7199 bytes --]

diff --git a/exec.c b/exec.c
index e241f05..c024b8b 100644
--- a/exec.c
+++ b/exec.c
@@ -2484,6 +2484,113 @@ static ram_addr_t kqemu_ram_alloc(ram_addr_t size)
 }
 #endif
 
+#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;
+    extern int mem_prealloc;
+
+    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, "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.
+     */
+    ftruncate(fd, memory);
+
+#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("alloc_mem_area: can't mmap hugetlbfs pages");
+	close(fd);
+	return (NULL);
+    }
+    return area;
+}
+
+#else
+
+static void *file_ram_alloc(ram_addr_t memory, const char *path)
+{
+    return NULL;
+}
+
+#endif
+
+extern const char *mem_path;
+
 ram_addr_t qemu_ram_alloc(ram_addr_t size)
 {
     RAMBlock *new_block;
@@ -2497,7 +2604,10 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size)
     size = TARGET_PAGE_ALIGN(size);
     new_block = qemu_malloc(sizeof(*new_block));
 
-    new_block->host = qemu_vmalloc(size);
+    new_block->host = file_ram_alloc(size, mem_path);
+    if (!new_block->host) {
+        new_block->host = qemu_vmalloc(size);
+    }
     new_block->offset = last_ram_offset;
     new_block->length = size;
 
diff --git a/hw/pc.c b/hw/pc.c
index 9e99b7c..74754a3 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -895,18 +895,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) {
@@ -914,14 +907,6 @@ static void pc_init1(ram_addr_t ram_size,
         hw_error("To much RAM for 32-bit physical address");
 #else
         ram_addr = qemu_ram_alloc(above_4g_mem_size);
-        if (hpagesize) {
-            if (ram_addr & (hpagesize-1)) {
-                unsigned long aligned_addr;
-                aligned_addr = (ram_addr + hpagesize - 1) & ~(hpagesize-1);
-                qemu_ram_alloc(aligned_addr - ram_addr);
-                ram_addr = aligned_addr;
-            }
-        }
         cpu_register_physical_memory(0x100000000ULL,
                                      above_4g_mem_size,
                                      ram_addr);
diff --git a/vl.c b/vl.c
index db8265b..8aea7d6 100644
--- a/vl.c
+++ b/vl.c
@@ -41,7 +41,6 @@
 #include <sys/ioctl.h>
 #include <sys/resource.h>
 #include <sys/socket.h>
-#include <sys/vfs.h>
 #include <netinet/in.h>
 #include <net/if.h>
 #if defined(__NetBSD__)
@@ -268,7 +267,6 @@ const char *mem_path = NULL;
 #ifdef MAP_POPULATE
 int mem_prealloc = 1;	/* force preallocation of physical target memory */
 #endif
-long hpagesize = 0;
 #ifdef TARGET_ARM
 int old_param = 0;
 #endif
@@ -4856,90 +4854,6 @@ int qemu_uuid_parse(const char *str, uint8_t *uuid)
 
 #define MAX_NET_CLIENTS 32
 
-#ifdef USE_KVM
-
-#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 *alloc_mem_area(size_t memory, unsigned long *len, const char *path)
-{
-    char *filename;
-    void *area;
-    int fd;
-#ifdef MAP_POPULATE
-    int flags;
-#endif
-
-    if (!kvm_has_sync_mmu()) {
-        fprintf(stderr, "host lacks mmu notifiers, disabling --mem-path\n");
-        return NULL;
-    }
-
-    if (asprintf(&filename, "%s/kvm.XXXXXX", path) == -1)
-	return NULL;
-
-    hpagesize = gethugepagesize(path);
-    if (!hpagesize)
-	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.
-     */
-    ftruncate(fd, memory);
-
-#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("alloc_mem_area: can't mmap hugetlbfs pages");
-	close(fd);
-	return (NULL);
-    }
-    *len = memory;
-    return area;
-}
-#endif
-
 #ifndef _WIN32
 
 static void termsig_handler(int signal)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: Remove qemu_alloc_physram()
  2009-05-27 16:22         ` Avi Kivity
@ 2009-05-28  9:25           ` nicolas prochazka
  2009-05-28 21:53           ` Ryan Harper
  1 sibling, 0 replies; 9+ messages in thread
From: nicolas prochazka @ 2009-05-28  9:25 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

After some tests :
with kvm-85  all seems to be ok for me, multiple qemu runs well with hugepage
with kvm-86 + patch : after some time, vm reboot with strange disk
corruption ( windows tells that's some file missing ) and cpu load is
very important.

Note :
KVM 85 : ( run one qemu with -m 512 )
HugePages_Total: 13676
HugePages_Free:  13409
HugePages_Rsvd:      0
HugePages_Surp:      0

KVM 86 + patche
HugePages_Total: 13676
HugePages_Free:  13412
HugePages_Rsvd:      0
HugePages_Surp:      0

I do not known if this difference is the bug cause.

Regards
Nicolas

2009/5/27 Avi Kivity <avi@redhat.com>:
> Avi Kivity wrote:
>>
>> nicolas prochazka wrote:
>>>
>>> without -mem-prealloc
>>> HugePages_Total:  2560
>>> HugePages_Free:   2296
>>> HugePages_Rsvd:      0
>>>
>>> so after minimum test, i can say that's your patch seems to be correct
>>> this problem.
>>>
>>
>> It isn't correct, it doesn't generate the right alignment.
>>
> Better patch attached.
>
> --
> error compiling committee.c: too many arguments to function
>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Remove qemu_alloc_physram()
  2009-05-27 16:22         ` Avi Kivity
  2009-05-28  9:25           ` nicolas prochazka
@ 2009-05-28 21:53           ` Ryan Harper
  2009-05-29  8:35             ` Avi Kivity
  1 sibling, 1 reply; 9+ messages in thread
From: Ryan Harper @ 2009-05-28 21:53 UTC (permalink / raw)
  To: Avi Kivity; +Cc: nicolas prochazka, kvm

* Avi Kivity <avi@redhat.com> [2009-05-27 11:23]:
> Avi Kivity wrote:
> >nicolas prochazka wrote:
> >>without -mem-prealloc
> >>HugePages_Total:  2560
> >>HugePages_Free:   2296
> >>HugePages_Rsvd:      0
> >>
> >>so after minimum test, i can say that's your patch seems to be correct
> >>this problem.
> >>  
> >
> >It isn't correct, it doesn't generate the right alignment.
> >
> Better patch attached.

This patch restores -mempath working for me on latest qemu-kvm.git.

btw, why'd we go from -mem-path (kvm-84/stable) to -mempath (kvm-85 and
newer)? Changing these breaks existing scripts.  Not a big deal, but
wondering what was the motivation for the change.

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ryanh@us.ibm.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Remove qemu_alloc_physram()
  2009-05-28 21:53           ` Ryan Harper
@ 2009-05-29  8:35             ` Avi Kivity
  0 siblings, 0 replies; 9+ messages in thread
From: Avi Kivity @ 2009-05-29  8:35 UTC (permalink / raw)
  To: Ryan Harper; +Cc: nicolas prochazka, kvm

Ryan Harper wrote:
> This patch restores -mempath working for me on latest qemu-kvm.git.
>   

Thanks for confirming.

> btw, why'd we go from -mem-path (kvm-84/stable) to -mempath (kvm-85 and
> newer)? Changing these breaks existing scripts.  Not a big deal, but
> wondering what was the motivation for the change.
>   

It was accidental.  Upstream moved the command line options definitions 
to a different file, and when  I merged I didn't move over this option 
correctly.  Code written during a merge is often of substandard quality.

I'll fix it up.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-05-29  8:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-27 10:08 Remove qemu_alloc_physram() nicolas prochazka
2009-05-27 12:50 ` Avi Kivity
2009-05-27 13:30   ` nicolas prochazka
2009-05-27 13:40     ` nicolas prochazka
2009-05-27 13:59       ` Avi Kivity
2009-05-27 16:22         ` Avi Kivity
2009-05-28  9:25           ` nicolas prochazka
2009-05-28 21:53           ` Ryan Harper
2009-05-29  8:35             ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox