• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisãocf2d4aa8a276f8540eef593141b7933487fa32b2 (tree)
Hora2022-01-28 23:38:23
AutorJuan Quintela <quintela@redh...>
CommiterJuan Quintela

Mensagem de Log

multifd: Use normal pages array on the recv side

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

---

Rename num_normal_pages to total_normal_pages (peter)

Mudança Sumário

Diff

--- a/migration/multifd-zlib.c
+++ b/migration/multifd-zlib.c
@@ -225,7 +225,7 @@ static int zlib_recv_pages(MultiFDRecvParams *p, Error **errp)
225225 uint32_t in_size = p->next_packet_size;
226226 /* we measure the change of total_out */
227227 uint32_t out_size = zs->total_out;
228- uint32_t expected_size = p->pages->num * qemu_target_page_size();
228+ uint32_t expected_size = p->normal_num * page_size;
229229 uint32_t flags = p->flags & MULTIFD_FLAG_COMPRESSION_MASK;
230230 int ret;
231231 int i;
@@ -244,16 +244,16 @@ static int zlib_recv_pages(MultiFDRecvParams *p, Error **errp)
244244 zs->avail_in = in_size;
245245 zs->next_in = z->zbuff;
246246
247- for (i = 0; i < p->pages->num; i++) {
247+ for (i = 0; i < p->normal_num; i++) {
248248 int flush = Z_NO_FLUSH;
249249 unsigned long start = zs->total_out;
250250
251- if (i == p->pages->num - 1) {
251+ if (i == p->normal_num - 1) {
252252 flush = Z_SYNC_FLUSH;
253253 }
254254
255255 zs->avail_out = page_size;
256- zs->next_out = p->pages->block->host + p->pages->offset[i];
256+ zs->next_out = p->pages->block->host + p->normal[i];
257257
258258 /*
259259 * Welcome to inflate semantics
--- a/migration/multifd-zstd.c
+++ b/migration/multifd-zstd.c
@@ -242,7 +242,7 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
242242 uint32_t in_size = p->next_packet_size;
243243 uint32_t out_size = 0;
244244 size_t page_size = qemu_target_page_size();
245- uint32_t expected_size = p->pages->num * page_size;
245+ uint32_t expected_size = p->normal_num * page_size;
246246 uint32_t flags = p->flags & MULTIFD_FLAG_COMPRESSION_MASK;
247247 struct zstd_data *z = p->data;
248248 int ret;
@@ -263,8 +263,8 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
263263 z->in.size = in_size;
264264 z->in.pos = 0;
265265
266- for (i = 0; i < p->pages->num; i++) {
267- z->out.dst = p->pages->block->host + p->pages->offset[i];
266+ for (i = 0; i < p->normal_num; i++) {
267+ z->out.dst = p->pages->block->host + p->normal[i];
268268 z->out.size = page_size;
269269 z->out.pos = 0;
270270
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -146,11 +146,11 @@ static int nocomp_recv_pages(MultiFDRecvParams *p, Error **errp)
146146 p->id, flags, MULTIFD_FLAG_NOCOMP);
147147 return -1;
148148 }
149- for (int i = 0; i < p->pages->num; i++) {
150- p->iov[i].iov_base = p->pages->block->host + p->pages->offset[i];
149+ for (int i = 0; i < p->normal_num; i++) {
150+ p->iov[i].iov_base = p->pages->block->host + p->normal[i];
151151 p->iov[i].iov_len = page_size;
152152 }
153- return qio_channel_readv_all(p->c, p->iov, p->pages->num, errp);
153+ return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp);
154154 }
155155
156156 static MultiFDMethods multifd_nocomp_ops = {
@@ -282,7 +282,7 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
282282 {
283283 MultiFDPacket_t *packet = p->packet;
284284 size_t page_size = qemu_target_page_size();
285- uint32_t pages_max = MULTIFD_PACKET_SIZE / page_size;
285+ uint32_t page_count = MULTIFD_PACKET_SIZE / page_size;
286286 RAMBlock *block;
287287 int i;
288288
@@ -309,33 +309,25 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
309309 * If we received a packet that is 100 times bigger than expected
310310 * just stop migration. It is a magic number.
311311 */
312- if (packet->pages_alloc > pages_max * 100) {
312+ if (packet->pages_alloc > page_count) {
313313 error_setg(errp, "multifd: received packet "
314- "with size %u and expected a maximum size of %u",
315- packet->pages_alloc, pages_max * 100) ;
314+ "with size %u and expected a size of %u",
315+ packet->pages_alloc, page_count) ;
316316 return -1;
317317 }
318- /*
319- * We received a packet that is bigger than expected but inside
320- * reasonable limits (see previous comment). Just reallocate.
321- */
322- if (packet->pages_alloc > p->pages->allocated) {
323- multifd_pages_clear(p->pages);
324- p->pages = multifd_pages_init(packet->pages_alloc);
325- }
326318
327- p->pages->num = be32_to_cpu(packet->pages_used);
328- if (p->pages->num > packet->pages_alloc) {
319+ p->normal_num = be32_to_cpu(packet->pages_used);
320+ if (p->normal_num > packet->pages_alloc) {
329321 error_setg(errp, "multifd: received packet "
330322 "with %u pages and expected maximum pages are %u",
331- p->pages->num, packet->pages_alloc) ;
323+ p->normal_num, packet->pages_alloc) ;
332324 return -1;
333325 }
334326
335327 p->next_packet_size = be32_to_cpu(packet->next_packet_size);
336328 p->packet_num = be64_to_cpu(packet->packet_num);
337329
338- if (p->pages->num == 0) {
330+ if (p->normal_num == 0) {
339331 return 0;
340332 }
341333
@@ -349,7 +341,7 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
349341 }
350342
351343 p->pages->block = block;
352- for (i = 0; i < p->pages->num; i++) {
344+ for (i = 0; i < p->normal_num; i++) {
353345 uint64_t offset = be64_to_cpu(packet->offset[i]);
354346
355347 if (offset > (block->used_length - page_size)) {
@@ -358,7 +350,7 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
358350 offset, block->used_length);
359351 return -1;
360352 }
361- p->pages->offset[i] = offset;
353+ p->normal[i] = offset;
362354 }
363355
364356 return 0;
@@ -1022,6 +1014,8 @@ int multifd_load_cleanup(Error **errp)
10221014 p->packet = NULL;
10231015 g_free(p->iov);
10241016 p->iov = NULL;
1017+ g_free(p->normal);
1018+ p->normal = NULL;
10251019 multifd_recv_state->ops->recv_cleanup(p);
10261020 }
10271021 qemu_sem_destroy(&multifd_recv_state->sem_sync);
@@ -1095,13 +1089,13 @@ static void *multifd_recv_thread(void *opaque)
10951089 flags = p->flags;
10961090 /* recv methods don't know how to handle the SYNC flag */
10971091 p->flags &= ~MULTIFD_FLAG_SYNC;
1098- trace_multifd_recv(p->id, p->packet_num, p->pages->num, flags,
1092+ trace_multifd_recv(p->id, p->packet_num, p->normal_num, flags,
10991093 p->next_packet_size);
11001094 p->num_packets++;
1101- p->num_pages += p->pages->num;
1095+ p->total_normal_pages += p->normal_num;
11021096 qemu_mutex_unlock(&p->mutex);
11031097
1104- if (p->pages->num) {
1098+ if (p->normal_num) {
11051099 ret = multifd_recv_state->ops->recv_pages(p, &local_err);
11061100 if (ret != 0) {
11071101 break;
@@ -1123,7 +1117,7 @@ static void *multifd_recv_thread(void *opaque)
11231117 qemu_mutex_unlock(&p->mutex);
11241118
11251119 rcu_unregister_thread();
1126- trace_multifd_recv_thread_end(p->id, p->num_packets, p->num_pages);
1120+ trace_multifd_recv_thread_end(p->id, p->num_packets, p->total_normal_pages);
11271121
11281122 return NULL;
11291123 }
@@ -1161,6 +1155,7 @@ int multifd_load_setup(Error **errp)
11611155 p->packet = g_malloc0(p->packet_len);
11621156 p->name = g_strdup_printf("multifdrecv_%d", i);
11631157 p->iov = g_new0(struct iovec, page_count);
1158+ p->normal = g_new0(ram_addr_t, page_count);
11641159 }
11651160
11661161 for (i = 0; i < thread_count; i++) {
--- a/migration/multifd.h
+++ b/migration/multifd.h
@@ -151,12 +151,16 @@ typedef struct {
151151 uint32_t next_packet_size;
152152 /* packets sent through this channel */
153153 uint64_t num_packets;
154- /* pages sent through this channel */
155- uint64_t num_pages;
154+ /* non zero pages recv through this channel */
155+ uint64_t total_normal_pages;
156156 /* syncs main thread and channels */
157157 QemuSemaphore sem_sync;
158158 /* buffers to recv */
159159 struct iovec *iov;
160+ /* Pages that are not zero */
161+ ram_addr_t *normal;
162+ /* num of non zero pages */
163+ uint32_t normal_num;
160164 /* used for de-compression methods */
161165 void *data;
162166 } MultiFDRecvParams;