qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 6/8] migration: Make none operations into its own structure
Date: Wed, 29 May 2019 17:34:48 +0100	[thread overview]
Message-ID: <20190529163447.GK2882@work-vm> (raw)
In-Reply-To: <20190515121544.4597-7-quintela@redhat.com>

* Juan Quintela (quintela@redhat.com) wrote:
> It will be used later.

'none' is confusing - I think this is no-compression specifically -
right?
I'd be happy with something abbreviated like 'nocomp'

> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  migration/ram.c | 54 ++++++++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 49 insertions(+), 5 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index 1ca9ba77b6..6679e4f213 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -700,6 +700,40 @@ typedef struct {
>      QemuSemaphore sem_sync;
>  } MultiFDRecvParams;
>  
> +typedef struct {
> +    /* Prepare the send packet */
> +    int (*send_prepare)(MultiFDSendParams *p, uint32_t used);
> +    /* Write the send packet */
> +    int (*send_write)(MultiFDSendParams *p, uint32_t used, Error **perr);
> +    /* Read all pages */
> +    int (*recv_pages)(MultiFDRecvParams *p, uint32_t used, Error **perr);
> +} MultifdMethods;
> +
> +/* Multifd without compression */
> +
> +static int none_send_prepare(MultiFDSendParams *p, uint32_t used)
> +{
> +    p->next_packet_size = used * qemu_target_page_size();
> +    return 0;
> +}
> +
> +static int none_send_write(MultiFDSendParams *p, uint32_t used, Error **perr)
> +{
> +    return qio_channel_writev_all(p->c, p->pages->iov, used, perr);
> +}
> +
> +static int none_recv_pages(MultiFDRecvParams *p, uint32_t used, Error **perr)
> +{
> +    return qio_channel_readv_all(p->c, p->pages->iov, used, perr);
> +
> +}
> +
> +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 agree with Wei Yang that is a bad idea; that should be done once
before the first thread is started.

Dave

>      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;
>      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
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


  parent reply	other threads:[~2019-05-29 16:36 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
2019-06-10  9:54     ` Juan Quintela
2019-05-29 16:34   ` Dr. David Alan Gilbert [this message]
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=20190529163447.GK2882@work-vm \
    --to=dgilbert@redhat.com \
    --cc=armbru@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).