split memory allocation
PATCH 1/1 split memory allocation
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.
--- hw/pc.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-)
hw/pc.c +12 -4
@@ -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);
Signature · 1 line
1.5.5.1
Quoted 17 lines · Glauber Costa
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 <[email protected]>--- hw/pc.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-)hw/pc.c +0
-0
hw/pc.c static void pc_init1(ram_addr_t ram_size, int vga_ram_size, · line 783
Quoted 9 lines
hw/pc.c +4
-2@@ -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?
Quoted 19 lines
hw/pc.c +8
-2+ 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);
Signature · 4 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net
Quoted 21 lines · Aurelien Jarno
Quoted 19 lines · Glauber Costa
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 <[email protected]>--- hw/pc.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-)hw/pc.c +0
-0@@ -777,16 +777,24 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,vmport_init ();
Quoted 11 lines
hw/pc.c static void pc_init1(ram_addr_t ram_size, int vga_ram_size, · line 788
Quoted 8 lines
hw/pc.c +4
-2/* 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
Quoted 37 lines · Anthony Liguori
Quoted 14 lines · Aurelien Jarno
Quoted 12 lines · Glauber Costa
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 <[email protected]>--- hw/pc.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-)Quoted 17 lines
Quoted 5 lines
hw/pc.c +0
-0hw/pc.c static void pc_init1(ram_addr_t ram_size, int vga_ram_size, · line 783
Quoted 9 lines
hw/pc.c +4
-2@@ -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.
Quoted 7 lines
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.
Quoted 17 lines · Glauber Costa
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 <[email protected]>--- hw/pc.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-)hw/pc.c +0
-0
hw/pc.c static void pc_init1(ram_addr_t ram_size, int vga_ram_size, · line 784
Quoted 10 lines
hw/pc.c +4
-2@@ -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 */
It's not really a hole. QEMU leaves a hole from 0xa0000 to 0xc0000 because this is the VGA area. KVM remaps this range to normal RAM when the guest sets the VGA card to have a linear framebuffer as an optimization.
Later, 0xc0000 to 0xd0000 gets registered as ROM (because it's the VGA BIOS), and 0xd0000 to about 0xe0000 is option ROM space, and 0xe0000 to 0x100000 is where the BIOS gets mapped.
So the comment code be improved to explain what goes in this region and why we need to allocate ram for it in the first place.
Regards,
Anthony Liguori
Quoted 20 lines
hw/pc.c +8
-2+ 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);
Quoted 34 lines · Anthony Liguori
Quoted 17 lines · Glauber Costa
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 <[email protected]>--- hw/pc.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-)hw/pc.c +0
-0hw/pc.c static void pc_init1(ram_addr_t ram_size, int vga_ram_size, · line 784
Quoted 10 lines
hw/pc.c +4
-2@@ -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 */ It's not really a hole. QEMU leaves a hole from
0xa0000to0xc0000because this is the VGA area. KVM remaps this range to normal RAM when the guest sets the VGA card to have a linear framebuffer as an optimization.
Quoted 7 lines
Later,
0xc0000to0xd0000gets registered as ROM (because it's the VGA BIOS), and0xd0000to about0xe0000is option ROM space, and0xe0000to0x100000is where the BIOS gets mapped.So the comment code be improved to explain what goes in this region and why we need to allocate ram for it in the first place.
150 % in agreement.
Wait for a new one.
Quoted 25 lines
Regards,
Anthony Liguori
Quoted 20 lines
hw/pc.c +8
-2+ 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);
Quoted 7 lines · Glauber Costa
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).
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 3 lines · Anthony Liguori
It's not really a hole. QEMU leaves a hole from
0xa0000to0xc0000because this is the VGA area. KVM remaps this range to normal RAM when the guest sets the VGA card to have a linear framebuffer as an optimization.
kvm doesn't remap it to normal RAM, it remaps it to a framebuffer. So from the RAM viewpoint, it is a hole.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 10 lines · Avi Kivity
Quoted 6 lines · Anthony Liguori
It's not really a hole. QEMU leaves a hole from
0xa0000to0xc0000because this is the VGA area. KVM remaps this range to normal RAM when the guest sets the VGA card to have a linear framebuffer as an optimization.kvm doesn't remap it to normal RAM, it remaps it to a framebuffer. So from the RAM viewpoint, it is a hole.
for VGA yes, but the said "hole" is much bigger than the vga space itself. Not all of it is "hole".
Quoted 4 lines
Signature · 2 lines
-- error compiling committee.c: too many arguments to function
Quoted 3 lines · Glauber Costa
for VGA yes, but the said "hole" is much bigger than the vga space itself. Not all of it is "hole".
There is a hole in the hole?
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.