[PATCH v4 16/18] migration/rdma: add rdma_channel into Migrationstate field

Chuan Zheng posted 18 patches 5 years ago
Maintainers: "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Juan Quintela <quintela@redhat.com>
[PATCH v4 16/18] migration/rdma: add rdma_channel into Migrationstate field
Posted by Chuan Zheng 5 years ago
Multifd RDMA is need to poll when we send data, record it.

Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
---
 migration/migration.c |  1 +
 migration/migration.h |  1 +
 migration/rdma.c      | 14 ++++++++++++++
 3 files changed, 16 insertions(+)

diff --git a/migration/migration.c b/migration/migration.c
index b8f4844..47bd11d 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1926,6 +1926,7 @@ void migrate_init(MigrationState *s)
     s->migration_thread_running = false;
     s->enabled_rdma_migration = false;
     s->host_port = NULL;
+    s->rdma_channel = 0;
     error_free(s->error);
     s->error = NULL;
     s->hostname = NULL;
diff --git a/migration/migration.h b/migration/migration.h
index 537ee09..5ff46e6 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -288,6 +288,7 @@ struct MigrationState {
 
     /* Need by Multi-RDMA */
     char *host_port;
+    int rdma_channel;
 };
 
 void migrate_set_state(int *state, int old_state, int new_state);
diff --git a/migration/rdma.c b/migration/rdma.c
index f5eb563..2097839 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -183,6 +183,20 @@ typedef struct {
 } RDMAWorkRequestData;
 
 /*
+ * Get the multifd RDMA channel used to send data.
+ */
+static int get_multifd_RDMA_channel(void)
+{
+    int thread_count = migrate_multifd_channels();
+    MigrationState *s = migrate_get_current();
+
+    s->rdma_channel++;
+    s->rdma_channel %= thread_count;
+
+    return s->rdma_channel;
+}
+
+/*
  * Negotiate RDMA capabilities during connection-setup time.
  */
 typedef struct {
-- 
1.8.3.1


Re: [PATCH v4 16/18] migration/rdma: add rdma_channel into Migrationstate field
Posted by Dr. David Alan Gilbert 5 years ago
* Chuan Zheng (zhengchuan@huawei.com) wrote:
> Multifd RDMA is need to poll when we send data, record it.

This looks like it's trying to be the equivalent of the 'static int
next_channel' in multifd_send_pages.

If so, why not mkae this 'multifd_channel' and make the function
'multifd_next_channel' and replace the code in multifd_send_pages to use
this as well, rather than make it a special for rdma.

Dave

> Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
> ---
>  migration/migration.c |  1 +
>  migration/migration.h |  1 +
>  migration/rdma.c      | 14 ++++++++++++++
>  3 files changed, 16 insertions(+)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index b8f4844..47bd11d 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -1926,6 +1926,7 @@ void migrate_init(MigrationState *s)
>      s->migration_thread_running = false;
>      s->enabled_rdma_migration = false;
>      s->host_port = NULL;
> +    s->rdma_channel = 0;
>      error_free(s->error);
>      s->error = NULL;
>      s->hostname = NULL;
> diff --git a/migration/migration.h b/migration/migration.h
> index 537ee09..5ff46e6 100644
> --- a/migration/migration.h
> +++ b/migration/migration.h
> @@ -288,6 +288,7 @@ struct MigrationState {
>  
>      /* Need by Multi-RDMA */
>      char *host_port;
> +    int rdma_channel;
>  };
>  
>  void migrate_set_state(int *state, int old_state, int new_state);
> diff --git a/migration/rdma.c b/migration/rdma.c
> index f5eb563..2097839 100644
> --- a/migration/rdma.c
> +++ b/migration/rdma.c
> @@ -183,6 +183,20 @@ typedef struct {
>  } RDMAWorkRequestData;
>  
>  /*
> + * Get the multifd RDMA channel used to send data.
> + */
> +static int get_multifd_RDMA_channel(void)
> +{
> +    int thread_count = migrate_multifd_channels();
> +    MigrationState *s = migrate_get_current();
> +
> +    s->rdma_channel++;
> +    s->rdma_channel %= thread_count;
> +
> +    return s->rdma_channel;
> +}
> +
> +/*
>   * Negotiate RDMA capabilities during connection-setup time.
>   */
>  typedef struct {
> -- 
> 1.8.3.1
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


Re: [PATCH v4 16/18] migration/rdma: add rdma_channel into Migrationstate field
Posted by Zheng Chuan 4 years, 11 months ago

On 2021/2/4 4:19, Dr. David Alan Gilbert wrote:
> * Chuan Zheng (zhengchuan@huawei.com) wrote:
>> Multifd RDMA is need to poll when we send data, record it.
> 
> This looks like it's trying to be the equivalent of the 'static int
> next_channel' in multifd_send_pages.
> 
> If so, why not mkae this 'multifd_channel' and make the function
> 'multifd_next_channel' and replace the code in multifd_send_pages to use
> this as well, rather than make it a special for rdma.
> 
> Dave
> 
Yes, that's a good suggestion. I'll do it in V5.

>> Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
>> ---
>>  migration/migration.c |  1 +
>>  migration/migration.h |  1 +
>>  migration/rdma.c      | 14 ++++++++++++++
>>  3 files changed, 16 insertions(+)
>>
>> diff --git a/migration/migration.c b/migration/migration.c
>> index b8f4844..47bd11d 100644
>> --- a/migration/migration.c
>> +++ b/migration/migration.c
>> @@ -1926,6 +1926,7 @@ void migrate_init(MigrationState *s)
>>      s->migration_thread_running = false;
>>      s->enabled_rdma_migration = false;
>>      s->host_port = NULL;
>> +    s->rdma_channel = 0;
>>      error_free(s->error);
>>      s->error = NULL;
>>      s->hostname = NULL;
>> diff --git a/migration/migration.h b/migration/migration.h
>> index 537ee09..5ff46e6 100644
>> --- a/migration/migration.h
>> +++ b/migration/migration.h
>> @@ -288,6 +288,7 @@ struct MigrationState {
>>  
>>      /* Need by Multi-RDMA */
>>      char *host_port;
>> +    int rdma_channel;
>>  };
>>  
>>  void migrate_set_state(int *state, int old_state, int new_state);
>> diff --git a/migration/rdma.c b/migration/rdma.c
>> index f5eb563..2097839 100644
>> --- a/migration/rdma.c
>> +++ b/migration/rdma.c
>> @@ -183,6 +183,20 @@ typedef struct {
>>  } RDMAWorkRequestData;
>>  
>>  /*
>> + * Get the multifd RDMA channel used to send data.
>> + */
>> +static int get_multifd_RDMA_channel(void)
>> +{
>> +    int thread_count = migrate_multifd_channels();
>> +    MigrationState *s = migrate_get_current();
>> +
>> +    s->rdma_channel++;
>> +    s->rdma_channel %= thread_count;
>> +
>> +    return s->rdma_channel;
>> +}
>> +
>> +/*
>>   * Negotiate RDMA capabilities during connection-setup time.
>>   */
>>  typedef struct {
>> -- 
>> 1.8.3.1
>>

-- 
Regards.
Chuan