From: Wei Yang <richardw.yang@linux.intel.com>
To: Juan Quintela <quintela@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
Thomas Huth <thuth@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 6/8] migration: Make none operations into its own structure
Date: Tue, 21 May 2019 10:47:48 +0800 [thread overview]
Message-ID: <20190521024748.GA23193@richard> (raw)
In-Reply-To: <20190515121544.4597-7-quintela@redhat.com>
On Wed, May 15, 2019 at 02:15:42PM +0200, Juan Quintela wrote:
>+
>+MultifdMethods multifd_none_ops = {
>+ .send_prepare = none_send_prepare,
>+ .send_write = none_send_write,
>+ .recv_pages = none_recv_pages
>+};
>+
> static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp)
> {
> MultiFDInit_t msg;
>@@ -904,6 +938,8 @@ struct {
> uint64_t packet_num;
> /* send channels ready */
> QemuSemaphore channels_ready;
>+ /* multifd ops */
>+ MultifdMethods *ops;
> } *multifd_send_state;
>
> /*
>@@ -1093,6 +1129,8 @@ static void *multifd_send_thread(void *opaque)
> /* initial packet */
> p->num_packets = 1;
>
>+ multifd_send_state->ops = &multifd_none_ops;
>+
I am afraid it is not a good practice to assign ops when each thread starts
work.
> while (true) {
> qemu_sem_wait(&p->sem);
> qemu_mutex_lock(&p->mutex);
>@@ -1102,7 +1140,12 @@ static void *multifd_send_thread(void *opaque)
> uint64_t packet_num = p->packet_num;
> uint32_t flags = p->flags;
>
>- p->next_packet_size = used * qemu_target_page_size();
>+ if (used) {
>+ ret = multifd_send_state->ops->send_prepare(p, used);
>+ if (ret != 0) {
>+ break;
>+ }
>+ }
> multifd_send_fill_packet(p);
> p->flags = 0;
> p->num_packets++;
>@@ -1120,8 +1163,7 @@ static void *multifd_send_thread(void *opaque)
> }
>
> if (used) {
>- ret = qio_channel_writev_all(p->c, p->pages->iov,
>- used, &local_err);
>+ ret = multifd_send_state->ops->send_write(p, used, &local_err);
> if (ret != 0) {
> break;
> }
>@@ -1223,6 +1265,8 @@ struct {
> QemuSemaphore sem_sync;
> /* global number of generated multifd packets */
> uint64_t packet_num;
>+ /* multifd ops */
>+ MultifdMethods *ops;
> } *multifd_recv_state;
>
> static void multifd_recv_terminate_threads(Error *err)
>@@ -1324,6 +1368,7 @@ static void *multifd_recv_thread(void *opaque)
> trace_multifd_recv_thread_start(p->id);
> rcu_register_thread();
>
>+ multifd_recv_state->ops = &multifd_none_ops;
same as here.
> while (true) {
> uint32_t used;
> uint32_t flags;
>@@ -1353,8 +1398,7 @@ static void *multifd_recv_thread(void *opaque)
> qemu_mutex_unlock(&p->mutex);
>
> if (used) {
>- ret = qio_channel_readv_all(p->c, p->pages->iov,
>- used, &local_err);
>+ ret = multifd_recv_state->ops->recv_pages(p, used, &local_err);
> if (ret != 0) {
> break;
> }
>--
>2.21.0
>
--
Wei Yang
Help you, Help me
next prev parent reply other threads:[~2019-05-21 2:49 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-15 12:15 [Qemu-devel] [PATCH v3 0/8] WIP: Multifd compression support Juan Quintela
2019-05-15 12:15 ` [Qemu-devel] [PATCH v3 1/8] migration: fix multifd_recv event typo Juan Quintela
2019-05-17 17:25 ` Dr. David Alan Gilbert
2019-05-20 6:38 ` Wei Yang
2019-05-15 12:15 ` [Qemu-devel] [PATCH v3 2/8] migration-test: rename parameter to parameter_int Juan Quintela
2019-05-20 6:43 ` Wei Yang
2019-05-15 12:15 ` [Qemu-devel] [PATCH v3 3/8] tests: Add migration multifd test Juan Quintela
2019-05-20 2:03 ` Wei Yang
2019-06-10 9:20 ` Juan Quintela
2019-05-20 6:48 ` Wei Yang
2019-06-10 9:23 ` Juan Quintela
2019-05-15 12:15 ` [Qemu-devel] [PATCH v3 4/8] migration-test: introduce functions to handle string parameters Juan Quintela
2019-05-15 12:15 ` [Qemu-devel] [PATCH v3 5/8] migration: Add multifd-compress parameter Juan Quintela
2019-05-15 15:34 ` Markus Armbruster
2019-06-10 9:38 ` Juan Quintela
2019-05-20 7:11 ` Wei Yang
2019-06-10 9:41 ` Juan Quintela
2019-05-20 12:53 ` Wei Yang
2019-06-10 9:42 ` Juan Quintela
2019-05-20 21:32 ` Wei Yang
2019-06-10 9:45 ` Juan Quintela
2019-05-15 12:15 ` [Qemu-devel] [PATCH v3 6/8] migration: Make none operations into its own structure Juan Quintela
2019-05-21 2:47 ` Wei Yang [this message]
2019-06-10 9:54 ` Juan Quintela
2019-05-29 16:34 ` Dr. David Alan Gilbert
2019-06-10 9:54 ` Juan Quintela
2019-06-12 11:54 ` Juan Quintela
2019-05-15 12:15 ` [Qemu-devel] [PATCH v3 7/8] multifd: Add zlib compression support Juan Quintela
2019-05-21 3:07 ` Wei Yang
2019-06-11 16:50 ` Juan Quintela
2019-05-29 16:48 ` Dr. David Alan Gilbert
2019-06-11 16:46 ` Juan Quintela
2019-05-15 12:15 ` [Qemu-devel] [PATCH v3 8/8] multifd: rest of zlib compression Juan Quintela
2019-05-21 3:11 ` Wei Yang
2019-06-11 16:54 ` Juan Quintela
2019-05-29 17:15 ` Dr. David Alan Gilbert
2019-06-12 8:33 ` Juan Quintela
2019-05-20 6:35 ` [Qemu-devel] [PATCH v3 0/8] WIP: Multifd compression support Wei Yang
2019-06-10 14:27 ` Eric Blake
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=20190521024748.GA23193@richard \
--to=richardw.yang@linux.intel.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=thuth@redhat.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).