[Qemu-devel] [RFC 01/29] migration: fix incorrect postcopy recved_bitmap

Peter Xu posted 29 patches 8 years, 6 months ago
There is a newer version of this series
[Qemu-devel] [RFC 01/29] migration: fix incorrect postcopy recved_bitmap
Posted by Peter Xu 8 years, 6 months ago
The bitmap setup during postcopy is incorrectly when the pgaes are huge
pages. Fix it.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/postcopy-ram.c | 2 +-
 migration/ram.c          | 8 ++++++++
 migration/ram.h          | 2 ++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 276ce12..952b73a 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -578,7 +578,7 @@ static int qemu_ufd_copy_ioctl(int userfault_fd, void *host_addr,
         ret = ioctl(userfault_fd, UFFDIO_ZEROPAGE, &zero_struct);
     }
     if (!ret) {
-        ramblock_recv_bitmap_set(host_addr, rb);
+        ramblock_recv_bitmap_set_range(rb, host_addr, pagesize / getpagesize());
     }
     return ret;
 }
diff --git a/migration/ram.c b/migration/ram.c
index 107ee9d..c93973c 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -168,6 +168,14 @@ void ramblock_recv_bitmap_set(void *host_addr, RAMBlock *rb)
     set_bit_atomic(ramblock_recv_bitmap_offset(host_addr, rb), rb->receivedmap);
 }
 
+void ramblock_recv_bitmap_set_range(RAMBlock *rb, void *host_addr,
+                                    size_t len)
+{
+    bitmap_set(rb->receivedmap,
+               ramblock_recv_bitmap_offset(host_addr, rb),
+               len);
+}
+
 void ramblock_recv_bitmap_clear(void *host_addr, RAMBlock *rb)
 {
     clear_bit(ramblock_recv_bitmap_offset(host_addr, rb), rb->receivedmap);
diff --git a/migration/ram.h b/migration/ram.h
index b711552..84e8623 100644
--- a/migration/ram.h
+++ b/migration/ram.h
@@ -55,6 +55,8 @@ void ram_handle_compressed(void *host, uint8_t ch, uint64_t size);
 
 int ramblock_recv_bitmap_test(void *host_addr, RAMBlock *rb);
 void ramblock_recv_bitmap_set(void *host_addr, RAMBlock *rb);
+void ramblock_recv_bitmap_set_range(RAMBlock *rb, void *host_addr,
+                                    size_t len);
 void ramblock_recv_bitmap_clear(void *host_addr, RAMBlock *rb);
 
 #endif
-- 
2.7.4


Re: [Qemu-devel] [RFC 01/29] migration: fix incorrect postcopy recved_bitmap
Posted by Dr. David Alan Gilbert 8 years, 6 months ago
* Peter Xu (peterx@redhat.com) wrote:
> The bitmap setup during postcopy is incorrectly when the pgaes are huge
> pages. Fix it.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  migration/postcopy-ram.c | 2 +-
>  migration/ram.c          | 8 ++++++++
>  migration/ram.h          | 2 ++
>  3 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
> index 276ce12..952b73a 100644
> --- a/migration/postcopy-ram.c
> +++ b/migration/postcopy-ram.c
> @@ -578,7 +578,7 @@ static int qemu_ufd_copy_ioctl(int userfault_fd, void *host_addr,
>          ret = ioctl(userfault_fd, UFFDIO_ZEROPAGE, &zero_struct);
>      }
>      if (!ret) {
> -        ramblock_recv_bitmap_set(host_addr, rb);
> +        ramblock_recv_bitmap_set_range(rb, host_addr, pagesize / getpagesize());

isn't that   pagesize / qemu_target_page_size() ?

Other than that it looks OK.

>      }
>      return ret;
>  }
> diff --git a/migration/ram.c b/migration/ram.c
> index 107ee9d..c93973c 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -168,6 +168,14 @@ void ramblock_recv_bitmap_set(void *host_addr, RAMBlock *rb)
>      set_bit_atomic(ramblock_recv_bitmap_offset(host_addr, rb), rb->receivedmap);
>  }
>  
> +void ramblock_recv_bitmap_set_range(RAMBlock *rb, void *host_addr,
> +                                    size_t len)
> +{
> +    bitmap_set(rb->receivedmap,
> +               ramblock_recv_bitmap_offset(host_addr, rb),
> +               len);
> +}
> +
>  void ramblock_recv_bitmap_clear(void *host_addr, RAMBlock *rb)
>  {
>      clear_bit(ramblock_recv_bitmap_offset(host_addr, rb), rb->receivedmap);
> diff --git a/migration/ram.h b/migration/ram.h
> index b711552..84e8623 100644
> --- a/migration/ram.h
> +++ b/migration/ram.h
> @@ -55,6 +55,8 @@ void ram_handle_compressed(void *host, uint8_t ch, uint64_t size);
>  
>  int ramblock_recv_bitmap_test(void *host_addr, RAMBlock *rb);
>  void ramblock_recv_bitmap_set(void *host_addr, RAMBlock *rb);
> +void ramblock_recv_bitmap_set_range(RAMBlock *rb, void *host_addr,
> +                                    size_t len);
>  void ramblock_recv_bitmap_clear(void *host_addr, RAMBlock *rb);
>  
>  #endif
> -- 
> 2.7.4
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Re: [Qemu-devel] [RFC 01/29] migration: fix incorrect postcopy recved_bitmap
Posted by Peter Xu 8 years, 6 months ago
On Mon, Jul 31, 2017 at 05:34:14PM +0100, Dr. David Alan Gilbert wrote:
> * Peter Xu (peterx@redhat.com) wrote:
> > The bitmap setup during postcopy is incorrectly when the pgaes are huge
> > pages. Fix it.
> > 
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >  migration/postcopy-ram.c | 2 +-
> >  migration/ram.c          | 8 ++++++++
> >  migration/ram.h          | 2 ++
> >  3 files changed, 11 insertions(+), 1 deletion(-)
> > 
> > diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
> > index 276ce12..952b73a 100644
> > --- a/migration/postcopy-ram.c
> > +++ b/migration/postcopy-ram.c
> > @@ -578,7 +578,7 @@ static int qemu_ufd_copy_ioctl(int userfault_fd, void *host_addr,
> >          ret = ioctl(userfault_fd, UFFDIO_ZEROPAGE, &zero_struct);
> >      }
> >      if (!ret) {
> > -        ramblock_recv_bitmap_set(host_addr, rb);
> > +        ramblock_recv_bitmap_set_range(rb, host_addr, pagesize / getpagesize());
> 
> isn't that   pagesize / qemu_target_page_size() ?
> 
> Other than that it looks OK.

Yes, I should have fixed this before.

I guess Alexey will handle this change (along with the copied bitmap
series)?  Anyway, I'll fix it as well in my series, until Alexey post
the new version that I can rebase to.  Thanks,

-- 
Peter Xu

Re: [Qemu-devel] [RFC 01/29] migration: fix incorrect postcopy recved_bitmap
Posted by Alexey Perevalov 8 years, 6 months ago
On 08/01/2017 05:11 AM, Peter Xu wrote:
> On Mon, Jul 31, 2017 at 05:34:14PM +0100, Dr. David Alan Gilbert wrote:
>> * Peter Xu (peterx@redhat.com) wrote:
>>> The bitmap setup during postcopy is incorrectly when the pgaes are huge
>>> pages. Fix it.
>>>
>>> Signed-off-by: Peter Xu <peterx@redhat.com>
>>> ---
>>>   migration/postcopy-ram.c | 2 +-
>>>   migration/ram.c          | 8 ++++++++
>>>   migration/ram.h          | 2 ++
>>>   3 files changed, 11 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
>>> index 276ce12..952b73a 100644
>>> --- a/migration/postcopy-ram.c
>>> +++ b/migration/postcopy-ram.c
>>> @@ -578,7 +578,7 @@ static int qemu_ufd_copy_ioctl(int userfault_fd, void *host_addr,
>>>           ret = ioctl(userfault_fd, UFFDIO_ZEROPAGE, &zero_struct);
>>>       }
>>>       if (!ret) {
>>> -        ramblock_recv_bitmap_set(host_addr, rb);
>>> +        ramblock_recv_bitmap_set_range(rb, host_addr, pagesize / getpagesize());
>> isn't that   pagesize / qemu_target_page_size() ?
>>
>> Other than that it looks OK.
> Yes, I should have fixed this before.
>
> I guess Alexey will handle this change (along with the copied bitmap
> series)?  Anyway, I'll fix it as well in my series, until Alexey post
> the new version that I can rebase to.  Thanks,
>
I'll squash it, and I'll resend it today.
Are you agree to add

Signed-off-by: Peter Xu <peterx@redhat.com>

to my patch?


-- 
Best regards,
Alexey Perevalov

Re: [Qemu-devel] [RFC 01/29] migration: fix incorrect postcopy recved_bitmap
Posted by Peter Xu 8 years, 6 months ago
On Tue, Aug 01, 2017 at 08:48:18AM +0300, Alexey Perevalov wrote:
> On 08/01/2017 05:11 AM, Peter Xu wrote:
> >On Mon, Jul 31, 2017 at 05:34:14PM +0100, Dr. David Alan Gilbert wrote:
> >>* Peter Xu (peterx@redhat.com) wrote:
> >>>The bitmap setup during postcopy is incorrectly when the pgaes are huge
> >>>pages. Fix it.
> >>>
> >>>Signed-off-by: Peter Xu <peterx@redhat.com>
> >>>---
> >>>  migration/postcopy-ram.c | 2 +-
> >>>  migration/ram.c          | 8 ++++++++
> >>>  migration/ram.h          | 2 ++
> >>>  3 files changed, 11 insertions(+), 1 deletion(-)
> >>>
> >>>diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
> >>>index 276ce12..952b73a 100644
> >>>--- a/migration/postcopy-ram.c
> >>>+++ b/migration/postcopy-ram.c
> >>>@@ -578,7 +578,7 @@ static int qemu_ufd_copy_ioctl(int userfault_fd, void *host_addr,
> >>>          ret = ioctl(userfault_fd, UFFDIO_ZEROPAGE, &zero_struct);
> >>>      }
> >>>      if (!ret) {
> >>>-        ramblock_recv_bitmap_set(host_addr, rb);
> >>>+        ramblock_recv_bitmap_set_range(rb, host_addr, pagesize / getpagesize());
> >>isn't that   pagesize / qemu_target_page_size() ?
> >>
> >>Other than that it looks OK.
> >Yes, I should have fixed this before.
> >
> >I guess Alexey will handle this change (along with the copied bitmap
> >series)?  Anyway, I'll fix it as well in my series, until Alexey post
> >the new version that I can rebase to.  Thanks,
> >
> I'll squash it, and I'll resend it today.
> Are you agree to add
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>
> 
> to my patch?

Firstly, if you are squashing the patch, fixing the issue that Dave
has pointed out, please feel free to add my R-b on the patch.

I don't know whether it would be suitable to add my S-o-b here - since
most of the patch content is written by you, not me. But I'm totally
fine if you want to include that (btw, thanks for the offer :).

So either one R-b or S-o-b is okay to me.  Thanks,

-- 
Peter Xu

Re: [Qemu-devel] [RFC 01/29] migration: fix incorrect postcopy recved_bitmap
Posted by Alexey Perevalov 8 years, 6 months ago
On 08/01/2017 09:02 AM, Peter Xu wrote:
> On Tue, Aug 01, 2017 at 08:48:18AM +0300, Alexey Perevalov wrote:
>> On 08/01/2017 05:11 AM, Peter Xu wrote:
>>> On Mon, Jul 31, 2017 at 05:34:14PM +0100, Dr. David Alan Gilbert wrote:
>>>> * Peter Xu (peterx@redhat.com) wrote:
>>>>> The bitmap setup during postcopy is incorrectly when the pgaes are huge
>>>>> pages. Fix it.
>>>>>
>>>>> Signed-off-by: Peter Xu <peterx@redhat.com>
>>>>> ---
>>>>>   migration/postcopy-ram.c | 2 +-
>>>>>   migration/ram.c          | 8 ++++++++
>>>>>   migration/ram.h          | 2 ++
>>>>>   3 files changed, 11 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
>>>>> index 276ce12..952b73a 100644
>>>>> --- a/migration/postcopy-ram.c
>>>>> +++ b/migration/postcopy-ram.c
>>>>> @@ -578,7 +578,7 @@ static int qemu_ufd_copy_ioctl(int userfault_fd, void *host_addr,
>>>>>           ret = ioctl(userfault_fd, UFFDIO_ZEROPAGE, &zero_struct);
>>>>>       }
>>>>>       if (!ret) {
>>>>> -        ramblock_recv_bitmap_set(host_addr, rb);
>>>>> +        ramblock_recv_bitmap_set_range(rb, host_addr, pagesize / getpagesize());
>>>> isn't that   pagesize / qemu_target_page_size() ?
>>>>
>>>> Other than that it looks OK.
>>> Yes, I should have fixed this before.
>>>
>>> I guess Alexey will handle this change (along with the copied bitmap
>>> series)?  Anyway, I'll fix it as well in my series, until Alexey post
>>> the new version that I can rebase to.  Thanks,
>>>
>> I'll squash it, and I'll resend it today.
>> Are you agree to add
>>
>> Signed-off-by: Peter Xu <peterx@redhat.com>
>>
>> to my patch?
> Firstly, if you are squashing the patch, fixing the issue that Dave
> has pointed out, please feel free to add my R-b on the patch.
Of course I'll take into account David's suggestion.
>
> I don't know whether it would be suitable to add my S-o-b here - since
> most of the patch content is written by you, not me. But I'm totally
> fine if you want to include that (btw, thanks for the offer :).
>
> So either one R-b or S-o-b is okay to me.  Thanks,
>

-- 
Best regards,
Alexey Perevalov