diff mbox

arch_init: Count the total number of pages by using helper function

Message ID 1425893258-12524-1-git-send-email-zhang.zhanghailiang@huawei.com
State New
Headers show

Commit Message

Zhanghailiang March 9, 2015, 9:27 a.m. UTC
There is already a helper function ram_bytes_total(), we can use it to
help counting the total number of pages used by ram blocks.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
---
 arch_init.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

Comments

Dr. David Alan Gilbert March 12, 2015, 10:59 a.m. UTC | #1
* zhanghailiang (zhang.zhanghailiang@huawei.com) wrote:
> There is already a helper function ram_bytes_total(), we can use it to
> help counting the total number of pages used by ram blocks.
> 
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> ---
>  arch_init.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/arch_init.c b/arch_init.c
> index 691b5e2..b22e38e 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -845,13 +845,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
>       * Count the total number of pages used by ram blocks not including any
>       * gaps due to alignment or unplugs.
>       */
> -    migration_dirty_pages = 0;
> -    QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
> -        uint64_t block_pages;
> -
> -        block_pages = block->used_length >> TARGET_PAGE_BITS;
> -        migration_dirty_pages += block_pages;
> -    }
> +    migration_dirty_pages = ram_bytes_total() >> TARGET_PAGE_BITS;

Yes, I think Markus had suggested something similar when I did the
original fix.

Thanks,

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

>  
>      memory_global_dirty_log_start();
>      migration_bitmap_sync();
> -- 
> 1.7.12.4
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Juan Quintela March 17, 2015, 1:52 p.m. UTC | #2
zhanghailiang <zhang.zhanghailiang@huawei.com> wrote:
> There is already a helper function ram_bytes_total(), we can use it to
> help counting the total number of pages used by ram blocks.
>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>

Applied, thanks.
diff mbox

Patch

diff --git a/arch_init.c b/arch_init.c
index 691b5e2..b22e38e 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -845,13 +845,7 @@  static int ram_save_setup(QEMUFile *f, void *opaque)
      * Count the total number of pages used by ram blocks not including any
      * gaps due to alignment or unplugs.
      */
-    migration_dirty_pages = 0;
-    QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
-        uint64_t block_pages;
-
-        block_pages = block->used_length >> TARGET_PAGE_BITS;
-        migration_dirty_pages += block_pages;
-    }
+    migration_dirty_pages = ram_bytes_total() >> TARGET_PAGE_BITS;
 
     memory_global_dirty_log_start();
     migration_bitmap_sync();