Currently, iotlb cache name is comprised of vid and virtqueue index. For example, "iotlb_cache_0_0". Because vid is assigned per process, iotlb cache name is not unique among multi processes. For example a secondary process uses a vhost (ex. eth_vhost0,iface=/tmp/sock0) and another secondary process uses a vhost (ex. eth_vhost1,iface=/tmp/sock1), iotlb cache name of both vhost ("iotlb_cache_0_0") are same and as a result iotlb cache is broken.
This patch makes iotlb cache name unique among milti processes by adding process id to the iotlb cache name. The prefix of the name is shortend to "iotlb_" since the maximum length of pool name is 23 bytes (RTE_MEMPOOL_NAMESIZE is 24). Note that pid_t is 4 bytes (thus max 10 digits), vid is max 4 digits (MAX_VHOST_DEVICE is 1024) and vq_index is 1 digit. It is just 23 characters in maximum. Fixes: d012d1f293f4 (vhost: add IOTLB helper functions) Cc: sta...@dpdk.org Signed-off-by: Itsuro Oda <o...@valinux.co.jp> --- v2: * use the process id to make the iotlb cache name unique. lib/librte_vhost/iotlb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_vhost/iotlb.c b/lib/librte_vhost/iotlb.c index bc1758528..7af5b8c8d 100644 --- a/lib/librte_vhost/iotlb.c +++ b/lib/librte_vhost/iotlb.c @@ -308,8 +308,9 @@ vhost_user_iotlb_init(struct virtio_net *dev, int vq_index) TAILQ_INIT(&vq->iotlb_list); TAILQ_INIT(&vq->iotlb_pending_list); - snprintf(pool_name, sizeof(pool_name), "iotlb_cache_%d_%d", - dev->vid, vq_index); + snprintf(pool_name, sizeof(pool_name), "iotlb_%d_%d_%d", + getpid(), dev->vid, vq_index); + VHOST_LOG_CONFIG(DEBUG, "IOTLB cache name: %s\n", pool_name); /* If already created, free it and recreate */ vq->iotlb_pool = rte_mempool_lookup(pool_name); -- 2.17.0