Skip to content

Commit

Permalink
vhost: fix NUMA reallocation with multi-queue
Browse files Browse the repository at this point in the history
[ upstream commit 6305dfe ]

Since the Vhost-user device initialization has been reworked,
enabling the application to start using the device as soon as
the first queue pair is ready, NUMA reallocation no more
happened on queue pairs other than the first one since
numa_realloc() was returning early if the device was running.

This patch fixes this issue by reallocating the device metadata
only if the device is running. For the virtqueues, a vring state
change notification is sent to notify the application of its
disablement. Since the callback is supposed to be blocking, it
is safe to reallocate it afterwards.

Fixes: d0fcc38 ("vhost: improve device readiness notifications")

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  • Loading branch information
mcoquelin authored and bluca committed Jul 12, 2021
1 parent 62c6d22 commit aa1a815
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/librte_vhost/vhost_user.c
Expand Up @@ -489,12 +489,16 @@ 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];

/*
* If VQ is ready, it is too late to reallocate, it certainly already
* happened anyway on VHOST_USER_SET_VRING_ADRR.
*/
if (vq->ready)
return dev;

ret = get_mempolicy(&newnode, NULL, 0, old_vq->desc,
MPOL_F_NODE | MPOL_F_ADDR);

Expand Down Expand Up @@ -549,6 +553,9 @@ numa_realloc(struct virtio_net *dev, int index)
rte_free(old_vq);
}

if (dev->flags & VIRTIO_DEV_RUNNING)
goto out;

/* check if we need to reallocate dev */
ret = get_mempolicy(&oldnode, NULL, 0, old_dev,
MPOL_F_NODE | MPOL_F_ADDR);
Expand Down

0 comments on commit aa1a815

Please sign in to comment.