qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Eduardo Habkost" <ehabkost@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Pankaj Gupta" <pankaj.gupta@cloud.ionos.com>,
	"Juan Quintela" <quintela@redhat.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Marek Kedzierski" <mkedzier@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	teawater <teawaterz@linux.alibaba.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Andrey Gruzdev" <andrey.gruzdev@virtuozzo.com>,
	"Wei Yang" <richard.weiyang@linux.alibaba.com>
Subject: [PATCH v4 8/9] migration/ram: Factor out populating pages readable in ram_block_populate_pages()
Date: Thu,  2 Sep 2021 15:14:31 +0200	[thread overview]
Message-ID: <20210902131432.23103-9-david@redhat.com> (raw)
In-Reply-To: <20210902131432.23103-1-david@redhat.com>

Let's factor out prefaulting/populating to make further changes easier to
review. While at it, use the actual page size of the ramblock, which
defaults to qemu_real_host_page_size for anonymous memory.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 migration/ram.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index e1c158dc92..de47650c90 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1639,6 +1639,17 @@ out:
     return ret;
 }
 
+static inline void populate_range(RAMBlock *block, ram_addr_t offset,
+                                  ram_addr_t size)
+{
+    for (; offset < size; offset += block->page_size) {
+        char tmp = *((char *)block->host + offset);
+
+        /* Don't optimize the read out */
+        asm volatile("" : "+r" (tmp));
+    }
+}
+
 /*
  * ram_block_populate_pages: populate memory in the RAM block by reading
  *   an integer from the beginning of each page.
@@ -1650,15 +1661,7 @@ out:
  */
 static void ram_block_populate_pages(RAMBlock *block)
 {
-    char *ptr = (char *) block->host;
-
-    for (ram_addr_t offset = 0; offset < block->used_length;
-            offset += qemu_real_host_page_size) {
-        char tmp = *(ptr + offset);
-
-        /* Don't optimize the read out */
-        asm volatile("" : "+r" (tmp));
-    }
+    populate_range(block, 0, block->used_length);
 }
 
 /*
-- 
2.31.1



  parent reply	other threads:[~2021-09-02 13:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-02 13:14 [PATCH v4 0/9] migration/ram: Optimize for virtio-mem via RamDiscardManager David Hildenbrand
2021-09-02 13:14 ` [PATCH v4 1/9] memory: Introduce replay_discarded callback for RamDiscardManager David Hildenbrand
2021-09-02 13:14 ` [PATCH v4 2/9] virtio-mem: Implement replay_discarded RamDiscardManager callback David Hildenbrand
2021-09-02 13:14 ` [PATCH v4 3/9] migration/ram: Don't passs RAMState to migration_clear_memory_region_dirty_bitmap_*() David Hildenbrand
2021-09-02 13:14 ` [PATCH v4 4/9] migration/ram: Handle RAMBlocks with a RamDiscardManager on the migration source David Hildenbrand
2021-09-02 13:14 ` [PATCH v4 5/9] virtio-mem: Drop precopy notifier David Hildenbrand
2021-09-02 13:14 ` [PATCH v4 6/9] migration/postcopy: Handle RAMBlocks with a RamDiscardManager on the destination David Hildenbrand
2021-09-02 13:14 ` [PATCH v4 7/9] migration: Simplify alignment and alignment checks David Hildenbrand
2021-09-02 22:32   ` Peter Xu
2021-09-03  8:47     ` David Hildenbrand
2021-09-03 10:07       ` David Hildenbrand
2021-09-03 10:22         ` David Hildenbrand
2021-09-03 19:14         ` Peter Xu
2021-09-03 19:37           ` David Hildenbrand
2021-09-02 13:14 ` David Hildenbrand [this message]
2021-09-02 22:28   ` [PATCH v4 8/9] migration/ram: Factor out populating pages readable in ram_block_populate_pages() Peter Xu
2021-09-03  7:45     ` David Hildenbrand
2021-09-03  7:58       ` David Hildenbrand
2021-09-03 19:20         ` Peter Xu
2021-09-03 19:40           ` David Hildenbrand
2021-09-03 19:45             ` David Hildenbrand
2021-09-02 13:14 ` [PATCH v4 9/9] migration/ram: Handle RAMBlocks with a RamDiscardManager on background snapshots David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210902131432.23103-9-david@redhat.com \
    --to=david@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=andrey.gruzdev@virtuozzo.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=mkedzier@redhat.com \
    --cc=mst@redhat.com \
    --cc=pankaj.gupta@cloud.ionos.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=richard.weiyang@linux.alibaba.com \
    --cc=teawaterz@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).