[dpdk-stable] patch 'vhost: fix missing memory table NUMA realloc' has been queued to stable release 20.11.3

luca.boccassi at gmail.com luca.boccassi at gmail.com
Mon Jul 12 15:04:47 CEST 2021


Hi,

FYI, your patch has been queued to stable release 20.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 07/14/21. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/a21845c789798d48b6b23754719e58b55439830f

Thanks.

Luca Boccassi

---
>From a21845c789798d48b6b23754719e58b55439830f Mon Sep 17 00:00:00 2001
From: Maxime Coquelin <maxime.coquelin at redhat.com>
Date: Tue, 29 Jun 2021 18:11:27 +0200
Subject: [PATCH] vhost: fix missing memory table NUMA realloc

[ upstream commit 8119ca9114b2ab2d42732e2a8b5cb31c47ed4eb3 ]

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 Vhost memory table was missing, which
likely causes at least one cross-NUMA accesses for every burst
of packets.

This patch reallocates this table on the same NUMA node as the
other metadata.

Fixes: 552e8fd3d2b4 ("vhost: simplify memory regions handling")

Reported-by: David Marchand <david.marchand at redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia at intel.com>
---
 lib/librte_vhost/vhost_user.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 78fb49b311..bef269298b 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -474,8 +474,8 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
 }
 
 /*
- * Reallocate virtio_dev and vhost_virtqueue data structure to make them on the
- * same numa node as the memory of vring descriptor.
+ * Reallocate virtio_dev, vhost_virtqueue and related data structures to
+ * make them on the same numa node as the memory of vring descriptor.
  */
 #ifdef RTE_LIBRTE_VHOST_NUMA
 static struct virtio_net*
@@ -558,6 +558,9 @@ numa_realloc(struct virtio_net *dev, int index)
 		goto out;
 	}
 	if (oldnode != newnode) {
+		struct rte_vhost_memory *old_mem;
+		ssize_t mem_size;
+
 		VHOST_LOG_CONFIG(INFO,
 			"reallocate dev from %d to %d node\n",
 			oldnode, newnode);
@@ -569,6 +572,18 @@ numa_realloc(struct virtio_net *dev, int index)
 
 		memcpy(dev, old_dev, sizeof(*dev));
 		rte_free(old_dev);
+
+		mem_size = sizeof(struct rte_vhost_memory) +
+			sizeof(struct rte_vhost_mem_region) * dev->mem->nregions;
+		old_mem = dev->mem;
+		dev->mem = rte_malloc_socket(NULL, mem_size, 0, newnode);
+		if (!dev->mem) {
+			dev->mem = old_mem;
+			goto out;
+		}
+
+		memcpy(dev->mem, old_mem, mem_size);
+		rte_free(old_mem);
 	}
 
 out:
-- 
2.30.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-07-12 13:41:39.371492516 +0100
+++ 0052-vhost-fix-missing-memory-table-NUMA-realloc.patch	2021-07-12 13:41:36.434121444 +0100
@@ -1 +1 @@
-From 8119ca9114b2ab2d42732e2a8b5cb31c47ed4eb3 Mon Sep 17 00:00:00 2001
+From a21845c789798d48b6b23754719e58b55439830f Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 8119ca9114b2ab2d42732e2a8b5cb31c47ed4eb3 ]
+
@@ -18 +19,0 @@
-Cc: stable at dpdk.org
@@ -24 +25 @@
- lib/vhost/vhost_user.c | 19 +++++++++++++++++--
+ lib/librte_vhost/vhost_user.c | 19 +++++++++++++++++--
@@ -27,5 +28,5 @@
-diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
-index 8f0eba6412..b5a84f3dcd 100644
---- a/lib/vhost/vhost_user.c
-+++ b/lib/vhost/vhost_user.c
-@@ -473,8 +473,8 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
+diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
+index 78fb49b311..bef269298b 100644
+--- a/lib/librte_vhost/vhost_user.c
++++ b/lib/librte_vhost/vhost_user.c
+@@ -474,8 +474,8 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
@@ -42 +43 @@
-@@ -557,6 +557,9 @@ numa_realloc(struct virtio_net *dev, int index)
+@@ -558,6 +558,9 @@ numa_realloc(struct virtio_net *dev, int index)
@@ -52 +53 @@
-@@ -568,6 +571,18 @@ numa_realloc(struct virtio_net *dev, int index)
+@@ -569,6 +572,18 @@ numa_realloc(struct virtio_net *dev, int index)


More information about the stable mailing list