On 07/05/2017 12:07 PM, Jens Freimann wrote:
On Tue, Jul 04, 2017 at 11:49:04AM +0200, Maxime Coquelin wrote:
virtio_net device might be accessed while being reallocated
in case of NUMA awareness. This case might be theoretical,
but it will be needed anyway to protect vrings pages against
invalidation.

The virtio_net devs are now protected with a readers/writers
lock, so that before reallocating the device, it is ensured
that it is not being referenced by the processing threads.

Signed-off-by: Maxime Coquelin <maxime.coque...@redhat.com>
---
lib/librte_vhost/vhost.c | 223 +++++++++++++++++++++++++++++++++++-------
lib/librte_vhost/vhost.h      |   3 +-
lib/librte_vhost/vhost_user.c |  73 +++++---------
lib/librte_vhost/virtio_net.c |  17 +++-
4 files changed, 228 insertions(+), 88 deletions(-)
[...]
+int
+realloc_device(int vid, int vq_index, int node)
+{
+    struct virtio_net *dev, *old_dev;
+    struct vhost_virtqueue *vq;
+
+    dev = rte_malloc_socket(NULL, sizeof(*dev), 0, node);
+    if (!dev)
+        return -1;
+
+    vq = rte_malloc_socket(NULL, sizeof(*vq), 0, node);
+    if (!vq)
+        return -1;
+
+    old_dev = get_device_wr(vid);
+    if (!old_dev)
+        return -1;

Should we free vq and dev here?

Of course we should.
This will be fixed in next release.

Thanks,
Maxime

Reply via email to