[v7,3/7] vhost: fix missing cache logging NUMA realloc

Message ID 20210629161133.79472-4-maxime.coquelin@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series vhost: Fix and improve NUMA reallocation |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Maxime Coquelin June 29, 2021, 4:11 p.m. UTC
  When the guest allocates virtqueues on a different NUMA node
than the one the Vhost metadata are allocated, both the Vhost
device struct and the virtqueues struct are reallocated.

However, reallocating the log cache on the new NUMA node was
not done. This patch fixes this by reallocating it if it has
been allocated already, which means a live-migration is
on-going.

Fixes: 1818a63147fb ("vhost: move dirty logging cache out of virtqueue")

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/vhost/vhost_user.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
  

Comments

Chenbo Xia June 30, 2021, 5:20 a.m. UTC | #1
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Wednesday, June 30, 2021 12:11 AM
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>;
> david.marchand@redhat.com
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH v7 3/7] vhost: fix missing cache logging NUMA realloc
> 
> When the guest allocates virtqueues on a different NUMA node
> than the one the Vhost metadata are allocated, both the Vhost
> device struct and the virtqueues struct are reallocated.
> 
> However, reallocating the log cache on the new NUMA node was
> not done. This patch fixes this by reallocating it if it has
> been allocated already, which means a live-migration is
> on-going.
> 
> Fixes: 1818a63147fb ("vhost: move dirty logging cache out of virtqueue")
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  lib/vhost/vhost_user.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 5fb055ea2e..82adf80fe5 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -545,6 +545,16 @@ numa_realloc(struct virtio_net *dev, int index)
>  			vq->batch_copy_elems = new_batch_copy_elems;
>  		}
> 
> +		if (vq->log_cache) {
> +			struct log_cache_entry *log_cache;
> +
> +			log_cache = rte_realloc_socket(vq->log_cache,
> +					sizeof(struct log_cache_entry) *
> VHOST_LOG_CACHE_NR,
> +					0, newnode);
> +			if (log_cache)
> +				vq->log_cache = log_cache;
> +		}
> +
>  		rte_free(old_vq);
>  	}
> 
> --
> 2.31.1

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  

Patch

diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 5fb055ea2e..82adf80fe5 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -545,6 +545,16 @@  numa_realloc(struct virtio_net *dev, int index)
 			vq->batch_copy_elems = new_batch_copy_elems;
 		}
 
+		if (vq->log_cache) {
+			struct log_cache_entry *log_cache;
+
+			log_cache = rte_realloc_socket(vq->log_cache,
+					sizeof(struct log_cache_entry) * VHOST_LOG_CACHE_NR,
+					0, newnode);
+			if (log_cache)
+				vq->log_cache = log_cache;
+		}
+
 		rte_free(old_vq);
 	}