[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC 19/21] migration: Add postcopy_mark_received()
From: |
Peter Xu |
Subject: |
[PATCH RFC 19/21] migration: Add postcopy_mark_received() |
Date: |
Tue, 17 Jan 2023 17:09:12 -0500 |
We have a few maintainance work to do after we UFFDIO_[ZERO]COPY a page
before, e.g. on requested list of pages or when measuring page latencies.
Move those steps into a separate function so that it can be easily reused
when we're going to support UFFDIO_CONTINUE.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/postcopy-ram.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 0cfe5174a5..8a2259581e 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -1288,6 +1288,25 @@ int postcopy_ram_incoming_setup(MigrationIncomingState
*mis)
return 0;
}
+static void
+postcopy_mark_received(MigrationIncomingState *mis, RAMBlock *rb,
+ void *host_addr, size_t npages)
+{
+ qemu_mutex_lock(&mis->page_request_mutex);
+ ramblock_recv_bitmap_set_range(rb, host_addr, npages);
+ /*
+ * If this page resolves a page fault for a previous recorded faulted
+ * address, take a special note to maintain the requested page list.
+ */
+ if (g_tree_lookup(mis->page_requested, host_addr)) {
+ g_tree_remove(mis->page_requested, host_addr);
+ mis->page_requested_count--;
+ trace_postcopy_page_req_del(host_addr, mis->page_requested_count);
+ }
+ qemu_mutex_unlock(&mis->page_request_mutex);
+ mark_postcopy_blocktime_end((uintptr_t)host_addr);
+}
+
static int qemu_ufd_copy_ioctl(MigrationIncomingState *mis, void *host_addr,
void *from_addr, uint64_t pagesize, RAMBlock
*rb)
{
@@ -1309,20 +1328,8 @@ static int qemu_ufd_copy_ioctl(MigrationIncomingState
*mis, void *host_addr,
ret = ioctl(userfault_fd, UFFDIO_ZEROPAGE, &zero_struct);
}
if (!ret) {
- qemu_mutex_lock(&mis->page_request_mutex);
- ramblock_recv_bitmap_set_range(rb, host_addr,
- pagesize / qemu_target_page_size());
- /*
- * If this page resolves a page fault for a previous recorded faulted
- * address, take a special note to maintain the requested page list.
- */
- if (g_tree_lookup(mis->page_requested, host_addr)) {
- g_tree_remove(mis->page_requested, host_addr);
- mis->page_requested_count--;
- trace_postcopy_page_req_del(host_addr, mis->page_requested_count);
- }
- qemu_mutex_unlock(&mis->page_request_mutex);
- mark_postcopy_blocktime_end((uintptr_t)host_addr);
+ postcopy_mark_received(mis, rb, host_addr,
+ pagesize / qemu_target_page_size());
}
return ret;
}
--
2.37.3
- Re: [PATCH RFC 12/21] migration: Introduce page size for-migration-only, (continued)
- [PATCH RFC 13/21] migration: Add migration_ram_pagesize_largest(), Peter Xu, 2023/01/17
- [PATCH RFC 14/21] migration: Map hugetlbfs ramblocks twice, and pre-allocate, Peter Xu, 2023/01/17
- [PATCH RFC 16/21] migration: Enable doublemap with MADV_SPLIT, Peter Xu, 2023/01/17
- [PATCH RFC 18/21] migration: Allow postcopy_register_shared_ufd() to fail, Peter Xu, 2023/01/17
- [PATCH RFC 19/21] migration: Add postcopy_mark_received(),
Peter Xu <=
- [PATCH RFC 15/21] migration: Teach qemu about minor faults and doublemap, Peter Xu, 2023/01/17
- [PATCH RFC 20/21] migration: Handle page faults using UFFDIO_CONTINUE, Peter Xu, 2023/01/17
- [PATCH RFC 17/21] migration: Rework ram discard logic for hugetlb double-map, Peter Xu, 2023/01/17
- [PATCH RFC 21/21] migration: Collapse huge pages again after postcopy finished, Peter Xu, 2023/01/17