[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 8/9] migration/ram: Factor out populating pages readable in ra
From: |
David Hildenbrand |
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 |
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
- [PATCH v4 4/9] migration/ram: Handle RAMBlocks with a RamDiscardManager on the migration source, (continued)
- [PATCH v4 4/9] migration/ram: Handle RAMBlocks with a RamDiscardManager on the migration source, David Hildenbrand, 2021/09/02
- [PATCH v4 5/9] virtio-mem: Drop precopy notifier, David Hildenbrand, 2021/09/02
- [PATCH v4 6/9] migration/postcopy: Handle RAMBlocks with a RamDiscardManager on the destination, David Hildenbrand, 2021/09/02
- [PATCH v4 7/9] migration: Simplify alignment and alignment checks, David Hildenbrand, 2021/09/02
- Re: [PATCH v4 7/9] migration: Simplify alignment and alignment checks, Peter Xu, 2021/09/02
- Re: [PATCH v4 7/9] migration: Simplify alignment and alignment checks, David Hildenbrand, 2021/09/03
- Re: [PATCH v4 7/9] migration: Simplify alignment and alignment checks, David Hildenbrand, 2021/09/03
- Re: [PATCH v4 7/9] migration: Simplify alignment and alignment checks, David Hildenbrand, 2021/09/03
- Re: [PATCH v4 7/9] migration: Simplify alignment and alignment checks, Peter Xu, 2021/09/03
- Re: [PATCH v4 7/9] migration: Simplify alignment and alignment checks, David Hildenbrand, 2021/09/03
[PATCH v4 8/9] migration/ram: Factor out populating pages readable in ram_block_populate_pages(),
David Hildenbrand <=
- Re: [PATCH v4 8/9] migration/ram: Factor out populating pages readable in ram_block_populate_pages(), Peter Xu, 2021/09/02
- Re: [PATCH v4 8/9] migration/ram: Factor out populating pages readable in ram_block_populate_pages(), David Hildenbrand, 2021/09/03
- Re: [PATCH v4 8/9] migration/ram: Factor out populating pages readable in ram_block_populate_pages(), David Hildenbrand, 2021/09/03
- Re: [PATCH v4 8/9] migration/ram: Factor out populating pages readable in ram_block_populate_pages(), Peter Xu, 2021/09/03
- Re: [PATCH v4 8/9] migration/ram: Factor out populating pages readable in ram_block_populate_pages(), David Hildenbrand, 2021/09/03
- Re: [PATCH v4 8/9] migration/ram: Factor out populating pages readable in ram_block_populate_pages(), David Hildenbrand, 2021/09/03
[PATCH v4 9/9] migration/ram: Handle RAMBlocks with a RamDiscardManager on background snapshots, David Hildenbrand, 2021/09/02