diff mbox

[1/6] qemu-kvm: Introduce bit-based phys_ram_dirty for VGA, CODE and MIGRATION.

Message ID 1268736839-27371-2-git-send-email-tamura.yoshiaki@lab.ntt.co.jp
State New
Headers show

Commit Message

Yoshiaki Tamura March 16, 2010, 10:53 a.m. UTC
Replaces byte-based phys_ram_dirty bitmap with 
three bit-based phys_ram_dirty bitmap.
On allocation, it sets all bits in the bitmap.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: OHMURA Kei <ohmura.kei@lab.ntt.co.jp>
---
 exec.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

Comments

Avi Kivity March 16, 2010, 12:26 p.m. UTC | #1
On 03/16/2010 12:53 PM, Yoshiaki Tamura wrote:
> Replaces byte-based phys_ram_dirty bitmap with
> three bit-based phys_ram_dirty bitmap.
> On allocation, it sets all bits in the bitmap.
>
> Signed-off-by: Yoshiaki Tamura<tamura.yoshiaki@lab.ntt.co.jp>
> Signed-off-by: OHMURA Kei<ohmura.kei@lab.ntt.co.jp>
> ---
>   exec.c |   22 +++++++++++++++++-----
>   1 files changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/exec.c b/exec.c
> index 9bcb4de..ba334e7 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -119,7 +119,9 @@ uint8_t *code_gen_ptr;
>
>   #if !defined(CONFIG_USER_ONLY)
>   int phys_ram_fd;
> -uint8_t *phys_ram_dirty;
> +unsigned long *phys_ram_vga_dirty;
> +unsigned long *phys_ram_code_dirty;
> +unsigned long *phys_ram_migration_dirty;
>    

Would be nice to make this an array.
Yoshiaki Tamura March 16, 2010, 1:01 p.m. UTC | #2
Avi Kivity wrote:
> On 03/16/2010 12:53 PM, Yoshiaki Tamura wrote:
>> Replaces byte-based phys_ram_dirty bitmap with
>> three bit-based phys_ram_dirty bitmap.
>> On allocation, it sets all bits in the bitmap.
>>
>> Signed-off-by: Yoshiaki Tamura<tamura.yoshiaki@lab.ntt.co.jp>
>> Signed-off-by: OHMURA Kei<ohmura.kei@lab.ntt.co.jp>
>> ---
>> exec.c | 22 +++++++++++++++++-----
>> 1 files changed, 17 insertions(+), 5 deletions(-)
>>
>> diff --git a/exec.c b/exec.c
>> index 9bcb4de..ba334e7 100644
>> --- a/exec.c
>> +++ b/exec.c
>> @@ -119,7 +119,9 @@ uint8_t *code_gen_ptr;
>>
>> #if !defined(CONFIG_USER_ONLY)
>> int phys_ram_fd;
>> -uint8_t *phys_ram_dirty;
>> +unsigned long *phys_ram_vga_dirty;
>> +unsigned long *phys_ram_code_dirty;
>> +unsigned long *phys_ram_migration_dirty;
>
> Would be nice to make this an array.

Thanks for pointing out.
I have a question regarding the index of the array.
 From the compatibility perspective, I would prefer using the existing macros.

#define VGA_DIRTY_FLAG       0x01
#define CODE_DIRTY_FLAG      0x02
#define MIGRATION_DIRTY_FLAG 0x08

However, if I use them as is, I'll get a sparse array...
Is it acceptable to change these values like 0, 1, 2?
Avi Kivity March 16, 2010, 1:04 p.m. UTC | #3
On 03/16/2010 03:01 PM, Yoshiaki Tamura wrote:
>>> -uint8_t *phys_ram_dirty;
>>> +unsigned long *phys_ram_vga_dirty;
>>> +unsigned long *phys_ram_code_dirty;
>>> +unsigned long *phys_ram_migration_dirty;
>>
>> Would be nice to make this an array.
>
>
> Thanks for pointing out.
> I have a question regarding the index of the array.
> From the compatibility perspective, I would prefer using the existing 
> macros.
>
> #define VGA_DIRTY_FLAG       0x01
> #define CODE_DIRTY_FLAG      0x02
> #define MIGRATION_DIRTY_FLAG 0x08
>
> However, if I use them as is, I'll get a sparse array...
> Is it acceptable to change these values like 0, 1, 2?

Sure.
diff mbox

Patch

diff --git a/exec.c b/exec.c
index 9bcb4de..ba334e7 100644
--- a/exec.c
+++ b/exec.c
@@ -119,7 +119,9 @@  uint8_t *code_gen_ptr;
 
 #if !defined(CONFIG_USER_ONLY)
 int phys_ram_fd;
-uint8_t *phys_ram_dirty;
+unsigned long *phys_ram_vga_dirty;
+unsigned long *phys_ram_code_dirty;
+unsigned long *phys_ram_migration_dirty;
 uint8_t *bios_mem;
 static int in_migration;
 
@@ -2659,10 +2661,20 @@  ram_addr_t qemu_ram_alloc(ram_addr_t size)
     new_block->next = ram_blocks;
     ram_blocks = new_block;
 
-    phys_ram_dirty = qemu_realloc(phys_ram_dirty,
-        (last_ram_offset + size) >> TARGET_PAGE_BITS);
-    memset(phys_ram_dirty + (last_ram_offset >> TARGET_PAGE_BITS),
-           0xff, size >> TARGET_PAGE_BITS);
+    if (BITMAP_SIZE(last_ram_offset + size) != BITMAP_SIZE(last_ram_offset)) {
+        phys_ram_vga_dirty = qemu_realloc(phys_ram_vga_dirty,
+            BITMAP_SIZE(last_ram_offset + size));
+        phys_ram_code_dirty = qemu_realloc(phys_ram_code_dirty,
+            BITMAP_SIZE(last_ram_offset + size));
+        phys_ram_migration_dirty = qemu_realloc(phys_ram_migration_dirty,
+            BITMAP_SIZE(last_ram_offset + size));
+        memset((uint8_t *)phys_ram_vga_dirty +
+               BITMAP_SIZE(last_ram_offset), 0xff, BITMAP_SIZE(size));
+        memset((uint8_t *)phys_ram_code_dirty + 
+               BITMAP_SIZE(last_ram_offset), 0xff, BITMAP_SIZE(size));
+        memset((uint8_t *)phys_ram_migration_dirty +
+               BITMAP_SIZE(last_ram_offset), 0xff, BITMAP_SIZE(size));
+    }
 
     last_ram_offset += size;