All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zheng Chuan <zhengchuan@huawei.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: yubihong@huawei.com, zhang.zhanghailiang@huawei.com,
	quintela@redhat.com, fengzhimin1@huawei.com,
	qemu-devel@nongnu.org, xiexiangyou@huawei.com,
	alex.chen@huawei.com, wanghao232@huawei.com
Subject: Re: [PATCH v3 04/18] migration/rdma: add multifd_setup_ops for rdma
Date: Wed, 11 Nov 2020 15:56:52 +0800	[thread overview]
Message-ID: <44d5f215-673a-cddb-2429-175f20bb266d@huawei.com> (raw)
In-Reply-To: <20201110123037.GE3108@work-vm>



On 2020/11/10 20:30, Dr. David Alan Gilbert wrote:
> * Chuan Zheng (zhengchuan@huawei.com) wrote:
>> Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
>> ---
>>  migration/multifd.c |  6 ++++
>>  migration/multifd.h |  4 +++
>>  migration/rdma.c    | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 92 insertions(+)
>>
>> diff --git a/migration/multifd.c b/migration/multifd.c
>> index 1f82307..0d494df 100644
>> --- a/migration/multifd.c
>> +++ b/migration/multifd.c
>> @@ -1210,6 +1210,12 @@ MultiFDSetup *multifd_setup_ops_init(void)
>>  {
>>      MultiFDSetup *ops;
>>  
>> +#ifdef CONFIG_RDMA
>> +    if (migrate_use_rdma()) {
>> +        ops = multifd_rdma_setup();
>> +        return ops;
>> +    }
>> +#endif
>>      ops = &multifd_socket_ops;
>>      return ops;
>>  }
>> diff --git a/migration/multifd.h b/migration/multifd.h
>> index 446315b..62a0b2a 100644
>> --- a/migration/multifd.h
>> +++ b/migration/multifd.h
>> @@ -173,6 +173,10 @@ typedef struct {
>>      void (*recv_channel_setup)(QIOChannel *ioc, MultiFDRecvParams *p);
>>  } MultiFDSetup;
>>  
>> +#ifdef CONFIG_RDMA
>> +MultiFDSetup *multifd_rdma_setup(void);
>> +#endif
>> +MultiFDSetup *multifd_setup_ops_init(void);
>>  void multifd_register_ops(int method, MultiFDMethods *ops);
>>  
>>  #endif
>> diff --git a/migration/rdma.c b/migration/rdma.c
>> index 0340841..ad4e4ba 100644
>> --- a/migration/rdma.c
>> +++ b/migration/rdma.c
>> @@ -19,6 +19,7 @@
>>  #include "qemu/cutils.h"
>>  #include "rdma.h"
>>  #include "migration.h"
>> +#include "multifd.h"
>>  #include "qemu-file.h"
>>  #include "ram.h"
>>  #include "qemu-file-channel.h"
>> @@ -4138,3 +4139,84 @@ err:
>>      g_free(rdma);
>>      g_free(rdma_return_path);
>>  }
>> +
>> +static void *multifd_rdma_send_thread(void *opaque)
>> +{
>> +    MultiFDSendParams *p = opaque;
>> +
>> +    while (true) {
>> +        qemu_mutex_lock(&p->mutex);
>> +        if (p->quit) {
>> +            qemu_mutex_unlock(&p->mutex);
>> +            break;
>> +        }
>> +        qemu_mutex_unlock(&p->mutex);
>> +        qemu_sem_wait(&p->sem);
>> +    }
>> +
>> +    qemu_mutex_lock(&p->mutex);
>> +    p->running = false;
>> +    qemu_mutex_unlock(&p->mutex);
>> +
>> +    return NULL;
>> +}
> 
> You might like to consider using WITH_QEMU_LOCK_GUARD, I think that
> would become:
> 
>   while (true) {
>       WITH_QEMU_LOCK_GUARD(&p->mutex) {
>           if (p->quit) {
>               break;
>           }
>       }
>       qemu_sem_wait(&p->sem);
>   }
>   WITH_QEMU_LOCK_GUARD(&p->mutex) {
>       p->running = false;
>   }
> 
OK. and this remind me now we keep qemu_mutex_lock(&p->mutex); in our multifd code, it that should also optimized?
>> +
>> +static void multifd_rdma_send_channel_setup(MultiFDSendParams *p)
>> +{
>> +    Error *local_err = NULL;
>> +
>> +    if (p->quit) {
>> +        error_setg(&local_err, "multifd: send id %d already quit", p->id);
>> +        return ;
>> +    }
>> +    p->running = true;
>> +
>> +    qemu_thread_create(&p->thread, p->name, multifd_rdma_send_thread, p,
>> +                       QEMU_THREAD_JOINABLE);
>> +}
>> +
>> +static void *multifd_rdma_recv_thread(void *opaque)
>> +{
>> +    MultiFDRecvParams *p = opaque;
>> +
>> +    while (true) {
>> +        qemu_mutex_lock(&p->mutex);
>> +        if (p->quit) {
>> +            qemu_mutex_unlock(&p->mutex);
>> +            break;
>> +        }
>> +        qemu_mutex_unlock(&p->mutex);
>> +        qemu_sem_wait(&p->sem_sync);
>> +    }
>> +
>> +    qemu_mutex_lock(&p->mutex);
>> +    p->running = false;
>> +    qemu_mutex_unlock(&p->mutex);
>> +
>> +    return NULL;
>> +}
>> +
>> +static void multifd_rdma_recv_channel_setup(QIOChannel *ioc,
>> +                                            MultiFDRecvParams *p)
>> +{
>> +    QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(ioc);
>> +
>> +    p->file = rioc->file;
>> +    return;
>> +}
>> +
>> +static MultiFDSetup multifd_rdma_ops = {
>> +    .send_thread_setup = multifd_rdma_send_thread,
>> +    .recv_thread_setup = multifd_rdma_recv_thread,
>> +    .send_channel_setup = multifd_rdma_send_channel_setup,
>> +    .recv_channel_setup = multifd_rdma_recv_channel_setup
>> +};
>> +
>> +MultiFDSetup *multifd_rdma_setup(void)
>> +{
>> +    MultiFDSetup *rdma_ops;
>> +
>> +    rdma_ops = &multifd_rdma_ops;
>> +
>> +    return rdma_ops;
> 
> Why bother making this a function - just export multifd_rdma_ops ?
> 
> Dave
> 
OK, will consider in that way.

>> +}
>> -- 
>> 1.8.3.1
>>

-- 
Regards.
Chuan


  reply	other threads:[~2020-11-11  7:57 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-17  4:25 [PATCH v3 00/18] Support Multifd for RDMA migration Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 01/18] migration/rdma: add the 'migrate_use_rdma_pin_all' function Chuan Zheng
2020-11-10 11:52   ` Dr. David Alan Gilbert
2020-10-17  4:25 ` [PATCH v3 02/18] migration/rdma: judge whether or not the RDMA is used for migration Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 03/18] migration/rdma: create multifd_setup_ops for Tx/Rx thread Chuan Zheng
2020-11-10 12:11   ` Dr. David Alan Gilbert
2020-11-11  7:51     ` Zheng Chuan
2020-10-17  4:25 ` [PATCH v3 04/18] migration/rdma: add multifd_setup_ops for rdma Chuan Zheng
2020-11-10 12:30   ` Dr. David Alan Gilbert
2020-11-11  7:56     ` Zheng Chuan [this message]
2020-10-17  4:25 ` [PATCH v3 05/18] migration/rdma: do not need sync main " Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 06/18] migration/rdma: export MultiFDSendParams/MultiFDRecvParams Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 07/18] migration/rdma: add rdma field into multifd send/recv param Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 08/18] migration/rdma: export getQIOChannel to get QIOchannel in rdma Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 09/18] migration/rdma: add multifd_rdma_load_setup() to setup multifd rdma Chuan Zheng
2020-11-10 16:51   ` Dr. David Alan Gilbert
2020-10-17  4:25 ` [PATCH v3 10/18] migration/rdma: Create the multifd recv channels for RDMA Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 11/18] migration/rdma: record host_port for multifd RDMA Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 12/18] migration/rdma: Create the multifd send channels for RDMA Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 13/18] migration/rdma: Add the function for dynamic page registration Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 14/18] migration/rdma: register memory for multifd RDMA channels Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 15/18] migration/rdma: only register the memory for multifd channels Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 16/18] migration/rdma: add rdma_channel into Migrationstate field Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 17/18] migration/rdma: send data for both rdma-pin-all and NOT rdma-pin-all mode Chuan Zheng
2020-10-17  4:25 ` [PATCH v3 18/18] migration/rdma: RDMA cleanup for multifd migration Chuan Zheng
2020-10-21  9:25 ` [PATCH v3 00/18] Support Multifd for RDMA migration Zhanghailiang
2020-10-21  9:33   ` Zheng Chuan
2020-10-23 19:02     ` Dr. David Alan Gilbert
2020-10-25  2:29       ` Zheng Chuan
2020-12-15  7:28         ` Zheng Chuan
2020-12-18 20:01           ` Dr. David Alan Gilbert

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=44d5f215-673a-cddb-2429-175f20bb266d@huawei.com \
    --to=zhengchuan@huawei.com \
    --cc=alex.chen@huawei.com \
    --cc=dgilbert@redhat.com \
    --cc=fengzhimin1@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=wanghao232@huawei.com \
    --cc=xiexiangyou@huawei.com \
    --cc=yubihong@huawei.com \
    --cc=zhang.zhanghailiang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.