qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] split memory allocation
@ 2008-09-11 13:42 Glauber Costa
  2008-09-11 14:18 ` Aurelien Jarno
  2008-09-11 15:28 ` Avi Kivity
  0 siblings, 2 replies; 9+ messages in thread
From: Glauber Costa @ 2008-09-11 13:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori

Right now, kvm keeps the memory allocation split, so we can
handle different areas in different ways. This schema works with qemu
too, so it appears to be the common ground.

This patch proposes using this common ground for everyone, by spliting
raw qemu.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 hw/pc.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 435c7d4..d6084ee 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -777,16 +777,24 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
     vmport_init();
 
     /* allocate RAM */
-    ram_addr = qemu_ram_alloc(ram_size);
-    cpu_register_physical_memory(0, below_4g_mem_size, ram_addr);
+    ram_addr = qemu_ram_alloc(0xa0000);
+    cpu_register_physical_memory(0, 0xa0000, ram_addr);
+
+    ram_addr = qemu_ram_alloc(0x100000 - 0xa0000);   /* hole */
+    ram_addr = qemu_ram_alloc(below_4g_mem_size - 0x100000);
+    cpu_register_physical_memory(0x100000,
+                 below_4g_mem_size - 0x100000,
+                 ram_addr);
 
     /* above 4giga memory allocation */
     if (above_4g_mem_size > 0) {
-        cpu_register_physical_memory((target_phys_addr_t) 0x100000000ULL,
+        ram_addr = qemu_ram_alloc(above_4g_mem_size);
+        cpu_register_physical_memory(0x100000000ULL,
                                      above_4g_mem_size,
-                                     ram_addr + below_4g_mem_size);
+                                     ram_addr);
     }
 
+
     /* allocate VGA RAM */
     vga_ram_addr = qemu_ram_alloc(vga_ram_size);
 
-- 
1.5.5.1

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

* Re: [Qemu-devel] [PATCH] split memory allocation
  2008-09-11 13:42 Glauber Costa
@ 2008-09-11 14:18 ` Aurelien Jarno
  2008-09-11 14:35   ` Anthony Liguori
  2008-09-11 15:28 ` Avi Kivity
  1 sibling, 1 reply; 9+ messages in thread
From: Aurelien Jarno @ 2008-09-11 14:18 UTC (permalink / raw)
  To: Glauber Causta; +Cc: aliguori, qemu-devel

Glauber Costa a écrit :
> Right now, kvm keeps the memory allocation split, so we can
> handle different areas in different ways. This schema works with qemu
> too, so it appears to be the common ground.
> 
> This patch proposes using this common ground for everyone, by spliting
> raw qemu.
> 
> Signed-off-by: Glauber Costa <glommer@redhat.com>
> ---
>  hw/pc.c |   16 ++++++++++++----
>  1 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/pc.c b/hw/pc.c
> index 435c7d4..d6084ee 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -777,16 +777,24 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
>      vmport_init();
>  
>      /* allocate RAM */
> -    ram_addr = qemu_ram_alloc(ram_size);
> -    cpu_register_physical_memory(0, below_4g_mem_size, ram_addr);
> +    ram_addr = qemu_ram_alloc(0xa0000);
> +    cpu_register_physical_memory(0, 0xa0000, ram_addr);
> +
> +    ram_addr = qemu_ram_alloc(0x100000 - 0xa0000);   /* hole */

What the point of allocating RAM for the memory hole if it is not mapped?

> +    ram_addr = qemu_ram_alloc(below_4g_mem_size - 0x100000);
> +    cpu_register_physical_memory(0x100000,
> +                 below_4g_mem_size - 0x100000,
> +                 ram_addr);
>  
>      /* above 4giga memory allocation */
>      if (above_4g_mem_size > 0) {
> -        cpu_register_physical_memory((target_phys_addr_t) 0x100000000ULL,
> +        ram_addr = qemu_ram_alloc(above_4g_mem_size);
> +        cpu_register_physical_memory(0x100000000ULL,
>                                       above_4g_mem_size,
> -                                     ram_addr + below_4g_mem_size);
> +                                     ram_addr);
>      }
>  
> +
>      /* allocate VGA RAM */
>      vga_ram_addr = qemu_ram_alloc(vga_ram_size);
>  


-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

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

* Re: [Qemu-devel] [PATCH] split memory allocation
  2008-09-11 14:18 ` Aurelien Jarno
@ 2008-09-11 14:35   ` Anthony Liguori
  2008-09-11 14:42     ` Glauber Costa
  0 siblings, 1 reply; 9+ messages in thread
From: Anthony Liguori @ 2008-09-11 14:35 UTC (permalink / raw)
  Cc: Glauber Causta, qemu-devel

Aurelien Jarno wrote:
> Glauber Costa a écrit :
>   
>> Right now, kvm keeps the memory allocation split, so we can
>> handle different areas in different ways. This schema works with qemu
>> too, so it appears to be the common ground.
>>
>> This patch proposes using this common ground for everyone, by spliting
>> raw qemu.
>>
>> Signed-off-by: Glauber Costa <glommer@redhat.com>
>> ---
>>  hw/pc.c |   16 ++++++++++++----
>>  1 files changed, 12 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/pc.c b/hw/pc.c
>> index 435c7d4..d6084ee 100644
>> --- a/hw/pc.c
>> +++ b/hw/pc.c
>> @@ -777,16 +777,24 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
>>      vmport_init();
>>  
>>      /* allocate RAM */
>> -    ram_addr = qemu_ram_alloc(ram_size);
>> -    cpu_register_physical_memory(0, below_4g_mem_size, ram_addr);
>> +    ram_addr = qemu_ram_alloc(0xa0000);
>> +    cpu_register_physical_memory(0, 0xa0000, ram_addr);
>> +
>> +    ram_addr = qemu_ram_alloc(0x100000 - 0xa0000);   /* hole */
>>     
>
> What the point of allocating RAM for the memory hole if it is not mapped?
>   

If you don't, you violate the phys_ram_base + PA assumption for all of 
memory.  No code should rely on this but practically speaking, there is 
still some code in QEMU that does.

Since the RAM is never touched, it doesn't actually impact the RSS size 
so it's not all that important.

Regards,

Anthony Liguori

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

* Re: [Qemu-devel] [PATCH] split memory allocation
  2008-09-11 14:35   ` Anthony Liguori
@ 2008-09-11 14:42     ` Glauber Costa
  0 siblings, 0 replies; 9+ messages in thread
From: Glauber Costa @ 2008-09-11 14:42 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel

On Thu, Sep 11, 2008 at 09:35:44AM -0500, Anthony Liguori wrote:
> Aurelien Jarno wrote:
>> Glauber Costa a écrit :
>>   
>>> Right now, kvm keeps the memory allocation split, so we can
>>> handle different areas in different ways. This schema works with qemu
>>> too, so it appears to be the common ground.
>>>
>>> This patch proposes using this common ground for everyone, by spliting
>>> raw qemu.
>>>
>>> Signed-off-by: Glauber Costa <glommer@redhat.com>
>>> ---
>>>  hw/pc.c |   16 ++++++++++++----
>>>  1 files changed, 12 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/hw/pc.c b/hw/pc.c
>>> index 435c7d4..d6084ee 100644
>>> --- a/hw/pc.c
>>> +++ b/hw/pc.c
>>> @@ -777,16 +777,24 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
>>>      vmport_init();
>>>       /* allocate RAM */
>>> -    ram_addr = qemu_ram_alloc(ram_size);
>>> -    cpu_register_physical_memory(0, below_4g_mem_size, ram_addr);
>>> +    ram_addr = qemu_ram_alloc(0xa0000);
>>> +    cpu_register_physical_memory(0, 0xa0000, ram_addr);
>>> +
>>> +    ram_addr = qemu_ram_alloc(0x100000 - 0xa0000);   /* hole */
>>>     
>>
>> What the point of allocating RAM for the memory hole if it is not mapped?
>>   
>
> If you don't, you violate the phys_ram_base + PA assumption for all of  
> memory.  No code should rely on this but practically speaking, there is  
> still some code in QEMU that does.
>
> Since the RAM is never touched, it doesn't actually impact the RSS size  
> so it's not all that important.
>
> Regards,
>
> Anthony Liguori
>
Precisely.

We actually saw this a while ago. the kernel loader was broken due to that.

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

* Re: [Qemu-devel] [PATCH] split memory allocation
  2008-09-11 13:42 Glauber Costa
  2008-09-11 14:18 ` Aurelien Jarno
@ 2008-09-11 15:28 ` Avi Kivity
  1 sibling, 0 replies; 9+ messages in thread
From: Avi Kivity @ 2008-09-11 15:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori

Glauber Costa wrote:
> Right now, kvm keeps the memory allocation split, so we can
> handle different areas in different ways. This schema works with qemu
> too, so it appears to be the common ground.
>
> This patch proposes using this common ground for everyone, by spliting
> raw qemu.
>   

I would rather see qemu switched to using memory slots.  The big chunk 
approach doesn't work well with memory hotplug (or with device hotplug 
when the device provides a memory resource).

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

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

* [Qemu-devel] [PATCH] split memory allocation
@ 2008-09-12 13:18 Glauber Costa
  0 siblings, 0 replies; 9+ messages in thread
From: Glauber Costa @ 2008-09-12 13:18 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori

Right now, kvm keeps the memory allocation split, so we can
handle different areas in different ways. This schema works with qemu
too, so it appears to be the common ground.

This patch proposes using this common ground for everyone, by spliting
raw qemu.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 hw/pc.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 435c7d4..d6084ee 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -777,16 +777,24 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
     vmport_init();
 
     /* allocate RAM */
-    ram_addr = qemu_ram_alloc(ram_size);
-    cpu_register_physical_memory(0, below_4g_mem_size, ram_addr);
+    ram_addr = qemu_ram_alloc(0xa0000);
+    cpu_register_physical_memory(0, 0xa0000, ram_addr);
+
+    ram_addr = qemu_ram_alloc(0x100000 - 0xa0000);   /* hole */
+    ram_addr = qemu_ram_alloc(below_4g_mem_size - 0x100000);
+    cpu_register_physical_memory(0x100000,
+                 below_4g_mem_size - 0x100000,
+                 ram_addr);
 
     /* above 4giga memory allocation */
     if (above_4g_mem_size > 0) {
-        cpu_register_physical_memory((target_phys_addr_t) 0x100000000ULL,
+        ram_addr = qemu_ram_alloc(above_4g_mem_size);
+        cpu_register_physical_memory(0x100000000ULL,
                                      above_4g_mem_size,
-                                     ram_addr + below_4g_mem_size);
+                                     ram_addr);
     }
 
+
     /* allocate VGA RAM */
     vga_ram_addr = qemu_ram_alloc(vga_ram_size);
 
-- 
1.5.5.1

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

* [Qemu-devel] [PATCH] split memory allocation
@ 2008-09-15 15:49 Glauber Costa
  2008-09-15 16:00 ` Anthony Liguori
  0 siblings, 1 reply; 9+ messages in thread
From: Glauber Costa @ 2008-09-15 15:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori

Right now, kvm keeps the memory allocation split, so we can
handle different areas in different ways. This schema works with qemu
too, so it appears to be the common ground.

This patch proposes using this common ground for everyone, by spliting
raw qemu.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 hw/pc.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 435c7d4..9fd1bdf 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -777,16 +777,28 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
     vmport_init();
 
     /* allocate RAM */
-    ram_addr = qemu_ram_alloc(ram_size);
-    cpu_register_physical_memory(0, below_4g_mem_size, ram_addr);
+    ram_addr = qemu_ram_alloc(0xa0000);
+    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);
 
     /* above 4giga memory allocation */
     if (above_4g_mem_size > 0) {
-        cpu_register_physical_memory((target_phys_addr_t) 0x100000000ULL,
+        ram_addr = qemu_ram_alloc(above_4g_mem_size);
+        cpu_register_physical_memory(0x100000000ULL,
                                      above_4g_mem_size,
-                                     ram_addr + below_4g_mem_size);
+                                     ram_addr);
     }
 
+
     /* allocate VGA RAM */
     vga_ram_addr = qemu_ram_alloc(vga_ram_size);
 
-- 
1.5.5.1

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

* Re: [Qemu-devel] [PATCH] split memory allocation
  2008-09-15 15:49 Glauber Costa
@ 2008-09-15 16:00 ` Anthony Liguori
  2008-09-15 16:11   ` Glauber Costa
  0 siblings, 1 reply; 9+ messages in thread
From: Anthony Liguori @ 2008-09-15 16:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: Glauber de Oliveira Costa

Glauber Costa wrote:
> Right now, kvm keeps the memory allocation split, so we can
> handle different areas in different ways. This schema works with qemu
> too, so it appears to be the common ground.
>
> This patch proposes using this common ground for everyone, by spliting
> raw qemu.
>   

Applied.  Thanks.

Regards,

Anthony Liguori

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

* Re: [Qemu-devel] [PATCH] split memory allocation
  2008-09-15 16:00 ` Anthony Liguori
@ 2008-09-15 16:11   ` Glauber Costa
  0 siblings, 0 replies; 9+ messages in thread
From: Glauber Costa @ 2008-09-15 16:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Glauber de Oliveira Costa

On Mon, Sep 15, 2008 at 1:00 PM, Anthony Liguori <anthony@codemonkey.ws> wrote:
> Glauber Costa wrote:
>>
>> Right now, kvm keeps the memory allocation split, so we can
>> handle different areas in different ways. This schema works with qemu
>> too, so it appears to be the common ground.
>>
>> This patch proposes using this common ground for everyone, by spliting
>> raw qemu.
>>
>
> Applied.  Thanks.
you're welcome ;-)

>
> Regards,
>
> Anthony Liguori
>
>
>
>



-- 
Glauber Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."

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

end of thread, other threads:[~2008-09-15 16:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-12 13:18 [Qemu-devel] [PATCH] split memory allocation Glauber Costa
  -- strict thread matches above, loose matches on Subject: below --
2008-09-15 15:49 Glauber Costa
2008-09-15 16:00 ` Anthony Liguori
2008-09-15 16:11   ` Glauber Costa
2008-09-11 13:42 Glauber Costa
2008-09-11 14:18 ` Aurelien Jarno
2008-09-11 14:35   ` Anthony Liguori
2008-09-11 14:42     ` Glauber Costa
2008-09-11 15:28 ` 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).