qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix calculation of number of bits in the migration bitmap
@ 2012-10-31 11:19 Orit Wasserman
  2012-10-31 11:24 ` Avi Kivity
  2012-10-31 11:25 ` Peter Maydell
  0 siblings, 2 replies; 5+ messages in thread
From: Orit Wasserman @ 2012-10-31 11:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, aliguori, Orit Wasserman, avi, quintela

The number of bits is off by one, for example if last_ram_offset
is 0x1000 (the guest has one page) we get 0 bits instead of 1.

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
---
 arch_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch_init.c b/arch_init.c
index b75a4c5..a80c3c8 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -565,7 +565,7 @@ static void reset_ram_globals(void)
 static int ram_save_setup(QEMUFile *f, void *opaque)
 {
     RAMBlock *block;
-    int64_t ram_pages = last_ram_offset() >> TARGET_PAGE_BITS;
+    int64_t ram_pages = (last_ram_offset() >> TARGET_PAGE_BITS) + 1;
 
     migration_bitmap = bitmap_new(ram_pages);
     bitmap_set(migration_bitmap, 0, ram_pages);
-- 
1.7.11.7

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

* Re: [Qemu-devel] [PATCH] Fix calculation of number of bits in the migration bitmap
  2012-10-31 11:19 [Qemu-devel] [PATCH] Fix calculation of number of bits in the migration bitmap Orit Wasserman
@ 2012-10-31 11:24 ` Avi Kivity
  2012-10-31 12:00   ` Orit Wasserman
  2012-10-31 11:25 ` Peter Maydell
  1 sibling, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2012-10-31 11:24 UTC (permalink / raw)
  To: Orit Wasserman; +Cc: pbonzini, aliguori, qemu-devel, quintela

On 10/31/2012 01:19 PM, Orit Wasserman wrote:
> The number of bits is off by one, for example if last_ram_offset
> is 0x1000 (the guest has one page) we get 0 bits instead of 1.
> 
> Signed-off-by: Orit Wasserman <owasserm@redhat.com>
> ---
>  arch_init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch_init.c b/arch_init.c
> index b75a4c5..a80c3c8 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -565,7 +565,7 @@ static void reset_ram_globals(void)
>  static int ram_save_setup(QEMUFile *f, void *opaque)
>  {
>      RAMBlock *block;
> -    int64_t ram_pages = last_ram_offset() >> TARGET_PAGE_BITS;
> +    int64_t ram_pages = (last_ram_offset() >> TARGET_PAGE_BITS) + 1;
>  

The original code calculates 1 for your example case.


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

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

* Re: [Qemu-devel] [PATCH] Fix calculation of number of bits in the migration bitmap
  2012-10-31 11:19 [Qemu-devel] [PATCH] Fix calculation of number of bits in the migration bitmap Orit Wasserman
  2012-10-31 11:24 ` Avi Kivity
@ 2012-10-31 11:25 ` Peter Maydell
  2012-10-31 12:04   ` Orit Wasserman
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2012-10-31 11:25 UTC (permalink / raw)
  To: Orit Wasserman; +Cc: pbonzini, aliguori, quintela, qemu-devel, avi

On 31 October 2012 12:19, Orit Wasserman <owasserm@redhat.com> wrote:
> The number of bits is off by one, for example if last_ram_offset
> is 0x1000 (the guest has one page) we get 0 bits instead of 1.
>
> Signed-off-by: Orit Wasserman <owasserm@redhat.com>
> ---
>  arch_init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch_init.c b/arch_init.c
> index b75a4c5..a80c3c8 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -565,7 +565,7 @@ static void reset_ram_globals(void)
>  static int ram_save_setup(QEMUFile *f, void *opaque)
>  {
>      RAMBlock *block;
> -    int64_t ram_pages = last_ram_offset() >> TARGET_PAGE_BITS;
> +    int64_t ram_pages = (last_ram_offset() >> TARGET_PAGE_BITS) + 1;

This will give you an extra bit if the last_ram_offset()
is an exact multiple of the page size, though. Try
  int64_t ram_pages = DIV_ROUND_UP(last_ram_offset(), TARGET_PAGE_SIZE);
?

-- PMM

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

* Re: [Qemu-devel] [PATCH] Fix calculation of number of bits in the migration bitmap
  2012-10-31 11:24 ` Avi Kivity
@ 2012-10-31 12:00   ` Orit Wasserman
  0 siblings, 0 replies; 5+ messages in thread
From: Orit Wasserman @ 2012-10-31 12:00 UTC (permalink / raw)
  To: Avi Kivity; +Cc: pbonzini, aliguori, qemu-devel, quintela

On 10/31/2012 01:24 PM, Avi Kivity wrote:
> On 10/31/2012 01:19 PM, Orit Wasserman wrote:
>> The number of bits is off by one, for example if last_ram_offset
>> is 0x1000 (the guest has one page) we get 0 bits instead of 1.
>>
>> Signed-off-by: Orit Wasserman <owasserm@redhat.com>
>> ---
>>  arch_init.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch_init.c b/arch_init.c
>> index b75a4c5..a80c3c8 100644
>> --- a/arch_init.c
>> +++ b/arch_init.c
>> @@ -565,7 +565,7 @@ static void reset_ram_globals(void)
>>  static int ram_save_setup(QEMUFile *f, void *opaque)
>>  {
>>      RAMBlock *block;
>> -    int64_t ram_pages = last_ram_offset() >> TARGET_PAGE_BITS;
>> +    int64_t ram_pages = (last_ram_offset() >> TARGET_PAGE_BITS) + 1;
>>  
> 
> The original code calculates 1 for your example case.
You correct ...
sorry ...

> 
> 

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

* Re: [Qemu-devel] [PATCH] Fix calculation of number of bits in the migration bitmap
  2012-10-31 11:25 ` Peter Maydell
@ 2012-10-31 12:04   ` Orit Wasserman
  0 siblings, 0 replies; 5+ messages in thread
From: Orit Wasserman @ 2012-10-31 12:04 UTC (permalink / raw)
  To: Peter Maydell; +Cc: pbonzini, aliguori, quintela, qemu-devel, avi

On 10/31/2012 01:25 PM, Peter Maydell wrote:
> On 31 October 2012 12:19, Orit Wasserman <owasserm@redhat.com> wrote:
>> The number of bits is off by one, for example if last_ram_offset
>> is 0x1000 (the guest has one page) we get 0 bits instead of 1.
>>
>> Signed-off-by: Orit Wasserman <owasserm@redhat.com>
>> ---
>>  arch_init.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch_init.c b/arch_init.c
>> index b75a4c5..a80c3c8 100644
>> --- a/arch_init.c
>> +++ b/arch_init.c
>> @@ -565,7 +565,7 @@ static void reset_ram_globals(void)
>>  static int ram_save_setup(QEMUFile *f, void *opaque)
>>  {
>>      RAMBlock *block;
>> -    int64_t ram_pages = last_ram_offset() >> TARGET_PAGE_BITS;
>> +    int64_t ram_pages = (last_ram_offset() >> TARGET_PAGE_BITS) + 1;
> 
> This will give you an extra bit if the last_ram_offset()
> is an exact multiple of the page size, though. Try
>   int64_t ram_pages = DIV_ROUND_UP(last_ram_offset(), TARGET_PAGE_SIZE);
Good idea ...
> ?
> 
> -- PMM
> 

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

end of thread, other threads:[~2012-10-31 12:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-31 11:19 [Qemu-devel] [PATCH] Fix calculation of number of bits in the migration bitmap Orit Wasserman
2012-10-31 11:24 ` Avi Kivity
2012-10-31 12:00   ` Orit Wasserman
2012-10-31 11:25 ` Peter Maydell
2012-10-31 12:04   ` Orit Wasserman

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).