vhost: forbid reallocation when running
authorTiwei Bie <tiwei.bie@intel.com>
Mon, 19 Aug 2019 11:34:55 +0000 (19:34 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 7 Oct 2019 13:00:57 +0000 (15:00 +0200)
When the device has been started, don't do the reallocation anymore.
Otherwise the pointers used in application threads can be invalidated
without proper protection. Instead of introducing a global lock to
protect the change of device pointers which will hurt the performance,
let's just do the reallocation during setup.

Fixes: af295ad4698c ("vhost: realloc device and queues to same numa node as vring desc")
Cc: stable@dpdk.org
Reported-by: Yinan Wang <yinan.wang@intel.com>
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/librte_vhost/vhost_user.c

index f468436..e4ae027 100644 (file)
@@ -410,6 +410,9 @@ numa_realloc(struct virtio_net *dev, int index)
        struct batch_copy_elem *new_batch_copy_elems;
        int ret;
 
+       if (dev->flags & VIRTIO_DEV_RUNNING)
+               return dev;
+
        old_dev = dev;
        vq = old_vq = dev->virtqueue[index];