[1/3] vhost: do not realloc device and queues during running
diff mbox series

Message ID 20190819113457.15569-2-tiwei.bie@intel.com
State Accepted
Delegated to: Maxime Coquelin
Headers show
Series
  • Some fixes for vhost
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues
ci/iol-Compile-Testing success Compile Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Tiwei Bie Aug. 19, 2019, 11:34 a.m. UTC
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>
---
 lib/librte_vhost/vhost_user.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Maxime Coquelin Sept. 18, 2019, 1:30 p.m. UTC | #1
On 8/19/19 1:34 PM, Tiwei Bie wrote:
> 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>
> ---
>  lib/librte_vhost/vhost_user.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime

Patch
diff mbox series

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 0b72648a5..ea43ab139 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -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];