[dpdk-dev,2/2] vhost: fix IOTLB on NUMA realloc

Message ID 20171012153850.21837-3-maxime.coquelin@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Yuanhan Liu
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Maxime Coquelin Oct. 12, 2017, 3:38 p.m. UTC
  In case of NUMA reallocation, virtqueue's iotlb list is broken,
has its head changes but first iotlb entry in the list still points
to the previous head pointer.

Also, in case of reallocation, we want the IOTLB cache mempool to be
on the new socket.

This patch perform a full re-init of the IOTLB cache when mempool
already exists, and calls the IOTLB cache init function in case
the virtqueue is being reallocated on a new socket.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/librte_vhost/iotlb.c      | 1 -
 lib/librte_vhost/vhost_user.c | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)
  

Comments

Jens Freimann Oct. 13, 2017, 11:23 a.m. UTC | #1
On Thu, Oct 12, 2017 at 03:38:50PM +0000, Maxime Coquelin wrote:
>In case of NUMA reallocation, virtqueue's iotlb list is broken,
>has its head changes but first iotlb entry in the list still points
>to the previous head pointer.
>
>Also, in case of reallocation, we want the IOTLB cache mempool to be
>on the new socket.
>
>This patch perform a full re-init of the IOTLB cache when mempool
>already exists, and calls the IOTLB cache init function in case
>the virtqueue is being reallocated on a new socket.
>
>Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>---
> lib/librte_vhost/iotlb.c      | 1 -
> lib/librte_vhost/vhost_user.c | 3 +++
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
>diff --git a/lib/librte_vhost/iotlb.c b/lib/librte_vhost/iotlb.c
>index 05c278040..b74cc6a78 100644
>--- a/lib/librte_vhost/iotlb.c
>+++ b/lib/librte_vhost/iotlb.c
>@@ -309,7 +309,6 @@ vhost_user_iotlb_init(struct virtio_net *dev, int vq_index)
> 		 */
> 		vhost_user_iotlb_cache_remove_all(vq);
> 		vhost_user_iotlb_pending_remove_all(vq);
>-		return 0;
> 	}
>
> #ifdef RTE_LIBRTE_VHOST_NUMA

Reviewed-by: Jens Freimann <jfreimann@redhat.com>
  

Patch

diff --git a/lib/librte_vhost/iotlb.c b/lib/librte_vhost/iotlb.c
index 05c278040..b74cc6a78 100644
--- a/lib/librte_vhost/iotlb.c
+++ b/lib/librte_vhost/iotlb.c
@@ -309,7 +309,6 @@  vhost_user_iotlb_init(struct virtio_net *dev, int vq_index)
 		 */
 		vhost_user_iotlb_cache_remove_all(vq);
 		vhost_user_iotlb_pending_remove_all(vq);
-		return 0;
 	}
 
 #ifdef RTE_LIBRTE_VHOST_NUMA
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 9acac6125..1dfb234ca 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -314,6 +314,9 @@  numa_realloc(struct virtio_net *dev, int index)
 	dev->virtqueue[index] = vq;
 	vhost_devices[dev->vid] = dev;
 
+	if (old_vq != vq)
+		vhost_user_iotlb_init(dev, index);
+
 	return dev;
 }
 #else