qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] cpu_physical_memory_sync_dirty_bitmap: Fix alignment check
@ 2017-07-24 16:51 Dr. David Alan Gilbert (git)
  2017-07-24 17:09 ` Paolo Bonzini
  2017-07-25 21:07 ` Juan Quintela
  0 siblings, 2 replies; 4+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2017-07-24 16:51 UTC (permalink / raw)
  To: qemu-devel, pbonzini, quintela, alex.bennee
  Cc: haozhong.zhang, peterx, lvivier

From: Dr. David Alan Gilbert <dgilbert@redhat.com>

This code has an optimised, word aligned version, and a boring
unaligned version.  Recently 084140bd498909 fixed a missing offset
addition from the core of both versions.  However, the offset isn't
necessarily aligned and thus the choice between the two versions
needs fixing up to also include the offset.

Symptom:
  A few stuck unsent pages during migration; not normally noticed
unless under very low bandwidth in which case the migration may get
stuck never ending and never performing a 2nd sync; noticed by
a hanging postcopy-test on a very heavily loaded system.

Fixes: 084140bd498909

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reported-by: Alex Benneé <alex.benee@linaro.org>
Tested-by: Alex Benneé <alex.benee@linaro.org>

--
v2
  Move 'page' inside the if (Comment from Paolo)
---
 include/exec/ram_addr.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index c04f4f67f6..d017639f7e 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -377,19 +377,20 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb,
                                                uint64_t *real_dirty_pages)
 {
     ram_addr_t addr;
-    unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS);
+    unsigned long word = BIT_WORD((start + rb->offset) >> TARGET_PAGE_BITS);
     uint64_t num_dirty = 0;
     unsigned long *dest = rb->bmap;
 
     /* start address is aligned at the start of a word? */
-    if (((page * BITS_PER_LONG) << TARGET_PAGE_BITS) == start) {
+    if (((word * BITS_PER_LONG) << TARGET_PAGE_BITS) ==
+         (start + rb->offset)) {
         int k;
         int nr = BITS_TO_LONGS(length >> TARGET_PAGE_BITS);
         unsigned long * const *src;
-        unsigned long word = BIT_WORD((start + rb->offset) >> TARGET_PAGE_BITS);
         unsigned long idx = (word * BITS_PER_LONG) / DIRTY_MEMORY_BLOCK_SIZE;
         unsigned long offset = BIT_WORD((word * BITS_PER_LONG) %
                                         DIRTY_MEMORY_BLOCK_SIZE);
+        unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS);
 
         rcu_read_lock();
 
-- 
2.13.3

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

* Re: [Qemu-devel] [PATCH v2] cpu_physical_memory_sync_dirty_bitmap: Fix alignment check
  2017-07-24 16:51 [Qemu-devel] [PATCH v2] cpu_physical_memory_sync_dirty_bitmap: Fix alignment check Dr. David Alan Gilbert (git)
@ 2017-07-24 17:09 ` Paolo Bonzini
  2017-07-24 17:27   ` Dr. David Alan Gilbert
  2017-07-25 21:07 ` Juan Quintela
  1 sibling, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2017-07-24 17:09 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git), qemu-devel, quintela, alex.bennee
  Cc: haozhong.zhang, peterx, lvivier

On 24/07/2017 18:51, Dr. David Alan Gilbert (git) wrote:
> From: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 
> This code has an optimised, word aligned version, and a boring
> unaligned version.  Recently 084140bd498909 fixed a missing offset
> addition from the core of both versions.  However, the offset isn't
> necessarily aligned and thus the choice between the two versions
> needs fixing up to also include the offset.
> 
> Symptom:
>   A few stuck unsent pages during migration; not normally noticed
> unless under very low bandwidth in which case the migration may get
> stuck never ending and never performing a 2nd sync; noticed by
> a hanging postcopy-test on a very heavily loaded system.
> 
> Fixes: 084140bd498909
> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Reported-by: Alex Benneé <alex.benee@linaro.org>
> Tested-by: Alex Benneé <alex.benee@linaro.org>
> 
> --
> v2
>   Move 'page' inside the if (Comment from Paolo)
> ---
>  include/exec/ram_addr.h | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
> index c04f4f67f6..d017639f7e 100644
> --- a/include/exec/ram_addr.h
> +++ b/include/exec/ram_addr.h
> @@ -377,19 +377,20 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb,
>                                                 uint64_t *real_dirty_pages)
>  {
>      ram_addr_t addr;
> -    unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS);
> +    unsigned long word = BIT_WORD((start + rb->offset) >> TARGET_PAGE_BITS);
>      uint64_t num_dirty = 0;
>      unsigned long *dest = rb->bmap;
>  
>      /* start address is aligned at the start of a word? */
> -    if (((page * BITS_PER_LONG) << TARGET_PAGE_BITS) == start) {
> +    if (((word * BITS_PER_LONG) << TARGET_PAGE_BITS) ==
> +         (start + rb->offset)) {
>          int k;
>          int nr = BITS_TO_LONGS(length >> TARGET_PAGE_BITS);
>          unsigned long * const *src;
> -        unsigned long word = BIT_WORD((start + rb->offset) >> TARGET_PAGE_BITS);
>          unsigned long idx = (word * BITS_PER_LONG) / DIRTY_MEMORY_BLOCK_SIZE;
>          unsigned long offset = BIT_WORD((word * BITS_PER_LONG) %
>                                          DIRTY_MEMORY_BLOCK_SIZE);
> +        unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS);
>  
>          rcu_read_lock();
>  
> 


Thanks, do you want me to queue this patch?

Paolo

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

* Re: [Qemu-devel] [PATCH v2] cpu_physical_memory_sync_dirty_bitmap: Fix alignment check
  2017-07-24 17:09 ` Paolo Bonzini
@ 2017-07-24 17:27   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 4+ messages in thread
From: Dr. David Alan Gilbert @ 2017-07-24 17:27 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: qemu-devel, quintela, alex.bennee, haozhong.zhang, peterx,
	lvivier

* Paolo Bonzini (pbonzini@redhat.com) wrote:
> On 24/07/2017 18:51, Dr. David Alan Gilbert (git) wrote:
> > From: Dr. David Alan Gilbert <dgilbert@redhat.com>
> > 
> > This code has an optimised, word aligned version, and a boring
> > unaligned version.  Recently 084140bd498909 fixed a missing offset
> > addition from the core of both versions.  However, the offset isn't
> > necessarily aligned and thus the choice between the two versions
> > needs fixing up to also include the offset.
> > 
> > Symptom:
> >   A few stuck unsent pages during migration; not normally noticed
> > unless under very low bandwidth in which case the migration may get
> > stuck never ending and never performing a 2nd sync; noticed by
> > a hanging postcopy-test on a very heavily loaded system.
> > 
> > Fixes: 084140bd498909
> > 
> > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> > Reported-by: Alex Benneé <alex.benee@linaro.org>
> > Tested-by: Alex Benneé <alex.benee@linaro.org>
> > 
> > --
> > v2
> >   Move 'page' inside the if (Comment from Paolo)
> > ---
> >  include/exec/ram_addr.h | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
> > index c04f4f67f6..d017639f7e 100644
> > --- a/include/exec/ram_addr.h
> > +++ b/include/exec/ram_addr.h
> > @@ -377,19 +377,20 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb,
> >                                                 uint64_t *real_dirty_pages)
> >  {
> >      ram_addr_t addr;
> > -    unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS);
> > +    unsigned long word = BIT_WORD((start + rb->offset) >> TARGET_PAGE_BITS);
> >      uint64_t num_dirty = 0;
> >      unsigned long *dest = rb->bmap;
> >  
> >      /* start address is aligned at the start of a word? */
> > -    if (((page * BITS_PER_LONG) << TARGET_PAGE_BITS) == start) {
> > +    if (((word * BITS_PER_LONG) << TARGET_PAGE_BITS) ==
> > +         (start + rb->offset)) {
> >          int k;
> >          int nr = BITS_TO_LONGS(length >> TARGET_PAGE_BITS);
> >          unsigned long * const *src;
> > -        unsigned long word = BIT_WORD((start + rb->offset) >> TARGET_PAGE_BITS);
> >          unsigned long idx = (word * BITS_PER_LONG) / DIRTY_MEMORY_BLOCK_SIZE;
> >          unsigned long offset = BIT_WORD((word * BITS_PER_LONG) %
> >                                          DIRTY_MEMORY_BLOCK_SIZE);
> > +        unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS);
> >  
> >          rcu_read_lock();
> >  
> > 
> 
> 
> Thanks, do you want me to queue this patch?

Yes please.

Dave

> Paolo
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

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

* Re: [Qemu-devel] [PATCH v2] cpu_physical_memory_sync_dirty_bitmap: Fix alignment check
  2017-07-24 16:51 [Qemu-devel] [PATCH v2] cpu_physical_memory_sync_dirty_bitmap: Fix alignment check Dr. David Alan Gilbert (git)
  2017-07-24 17:09 ` Paolo Bonzini
@ 2017-07-25 21:07 ` Juan Quintela
  1 sibling, 0 replies; 4+ messages in thread
From: Juan Quintela @ 2017-07-25 21:07 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git)
  Cc: qemu-devel, pbonzini, alex.bennee, haozhong.zhang, peterx,
	lvivier

"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:
> From: Dr. David Alan Gilbert <dgilbert@redhat.com>
>
> This code has an optimised, word aligned version, and a boring
> unaligned version.  Recently 084140bd498909 fixed a missing offset
> addition from the core of both versions.  However, the offset isn't
> necessarily aligned and thus the choice between the two versions
> needs fixing up to also include the offset.
>
> Symptom:
>   A few stuck unsent pages during migration; not normally noticed
> unless under very low bandwidth in which case the migration may get
> stuck never ending and never performing a 2nd sync; noticed by
> a hanging postcopy-test on a very heavily loaded system.
>
> Fixes: 084140bd498909
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Reported-by: Alex Benneé <alex.benee@linaro.org>
> Tested-by: Alex Benneé <alex.benee@linaro.org>
>

Reviewed-by: Juan Quintela <quintela@redhat.com>

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

end of thread, other threads:[~2017-07-25 21:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-24 16:51 [Qemu-devel] [PATCH v2] cpu_physical_memory_sync_dirty_bitmap: Fix alignment check Dr. David Alan Gilbert (git)
2017-07-24 17:09 ` Paolo Bonzini
2017-07-24 17:27   ` Dr. David Alan Gilbert
2017-07-25 21:07 ` Juan Quintela

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