Skip to contentSkip to conversation

vhost: avoid iotlb mempool allocation while IOMMU disabled

PATCH Superseded Wan Junjie 3 participants 7 messages Feb 2, 2021 – May 13, 2021

lore
Share & tools
lore

Wan Junjie

author
#0 lore raw

PATCH v2 1/1 vhost: avoid iotlb mempool allocation while IOMMU disabled

If vhost device's IOMMU feature is disabled, iotlb mempool allocation is unnecessary.

---
 lib/librte_vhost/vhost.c      | 4 ++--
 lib/librte_vhost/vhost_user.c | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)
lib/librte_vhost/vhost.c +2 -2
index b83cf639e..e5341ab98 100644
@@ -352,7 +352,8 @@ free_vq(struct virtio_net *dev, struct vhost_virtqueue *vq)
 		vhost_free_async_mem(vq);
 	}
 	rte_free(vq->batch_copy_elems);
-	rte_mempool_free(vq->iotlb_pool);
+	if (vq->iotlb_pool)
+		rte_mempool_free(vq->iotlb_pool);
 	rte_free(vq);
 }
 
@@ -556,7 +557,6 @@ init_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
 	vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD;
 	vq->notif_enable = VIRTIO_UNINITIALIZED_NOTIF;
 
-	vhost_user_iotlb_init(dev, vring_idx);
 	/* Backends are set to -1 indicating an inactive device. */
 	vq->backend = -1;
 }
lib/librte_vhost/vhost_user.c +5 -1
index 45c8ac09d..81cbb9797 100644
@@ -470,6 +470,10 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
 		return RTE_VHOST_MSG_RESULT_ERR;
 	}
 
+	if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) {
+		if (vhost_user_iotlb_init(dev, msg->payload.state.index))
+			return RTE_VHOST_MSG_RESULT_ERR;
+	}
 	return RTE_VHOST_MSG_RESULT_OK;
 }
 
@@ -575,7 +579,7 @@ numa_realloc(struct virtio_net *dev, int index)
 	dev->virtqueue[index] = vq;
 	vhost_devices[dev->vid] = dev;
 
-	if (old_vq != vq)
+	if (old_vq != vq && (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)))
 		vhost_user_iotlb_init(dev, index);
 
 	return dev;
Signature · 1 line
2.11.0
#1 lore raw
Quoted 9 lines

-----Original Message-----
From: Wan Junjie <[email protected]>
Sent: Tuesday, February 2, 2021 4:15 PM
To: Xia, Chenbo <[email protected]>; Maxime Coquelin <[email protected]>
Cc: [email protected]; Wan Junjie <[email protected]>; Peng He <[email protected]>; Zhihong Wang <[email protected]>
Subject: [PATCH v2] vhost: avoid iotlb mempool allocation while IOMMU disabled

Quoted 8 lines

If vhost device's IOMMU feature is disabled, iotlb mempool allocation is unnecessary.

---
2.11.0

Patch applied to next-virtio/main with conflict resolved, Thanks

#2 lore raw
Quoted 13 lines · Chenbo
Quoted 13 lines

-----Original Message-----
From: Wan Junjie <[email protected]>
Sent: Tuesday, February 2, 2021 4:15 PM
To: Xia, Chenbo <[email protected]>; Maxime Coquelin <[email protected]>
Cc: [email protected]; Wan Junjie <[email protected]>; Peng He <[email protected]>; Zhihong Wang <[email protected]>
Subject: [PATCH v2] vhost: avoid iotlb mempool allocation while IOMMU disabled

If vhost device's IOMMU feature is disabled, iotlb mempool allocation is unnecessary.

Quoted 7 lines
Quoted 5 lines

---
2.11.0

Patch applied to next-virtio/main with conflict resolved, Thanks

This patch triggered a regression reported by Red Hat QE.
https://bugs.dpdk.org/show_bug.cgi?id=703

Reverting the patch is enough to fix the regression.

I'll let you guys decide on the next step for 21.05.

Signature · 1 line
David Marchand
#3 lore raw
Quoted 36 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, May 13, 2021 4:39 PM
To: Xia, Chenbo <[email protected]>; Maxime Coquelin <[email protected]>
Cc: Wan Junjie <[email protected]>; [email protected]; Peng He <[email protected]>; Zhihong Wang <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] vhost: avoid iotlb mempool allocation while IOMMU disabled

Quoted 9 lines · Chenbo
Quoted 9 lines

-----Original Message-----
From: Wan Junjie <[email protected]>
Sent: Tuesday, February 2, 2021 4:15 PM
To: Xia, Chenbo <[email protected]>; Maxime Coquelin <[email protected]>
Cc: [email protected]; Wan Junjie <[email protected]>; Peng He <[email protected]>; Zhihong Wang <[email protected]>
Subject: [PATCH v2] vhost: avoid iotlb mempool allocation while IOMMU

disabled

Quoted 11 lines
Quoted 9 lines

If vhost device's IOMMU feature is disabled, iotlb mempool allocation is unnecessary.

---
2.11.0

Patch applied to next-virtio/main with conflict resolved, Thanks

This patch triggered a regression reported by Red Hat QE.
https://bugs.dpdk.org/show_bug.cgi?id=703

Quoted 7 lines

Reverting the patch is enough to fix the regression.

I'll let you guys decide on the next step for 21.05.

--
David Marchand

I cannot reproduce this issue on my machine.

@Wan Junjie Could you reproduce this? I prefer to revert the patch if things are not very clear as it is only a minor optimization.

Thanks,
Chenbo

author
#4 lore raw
Quoted 47 lines · Chenbo
Quoted 39 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, May 13, 2021 4:39 PM
To: Xia, Chenbo <[email protected]>; Maxime Coquelin <[email protected]>
Cc: Wan Junjie <[email protected]>; [email protected]; Peng He <[email protected]>; Zhihong Wang <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] vhost: avoid iotlb mempool allocation while IOMMU disabled

Quoted 9 lines · Chenbo
Quoted 9 lines

-----Original Message-----
From: Wan Junjie <[email protected]>
Sent: Tuesday, February 2, 2021 4:15 PM
To: Xia, Chenbo <[email protected]>; Maxime Coquelin <[email protected]>
Cc: [email protected]; Wan Junjie <[email protected]>; Peng He <[email protected]>; Zhihong Wang <[email protected]>
Subject: [PATCH v2] vhost: avoid iotlb mempool allocation while IOMMU

disabled

Quoted 11 lines
Quoted 9 lines

If vhost device's IOMMU feature is disabled, iotlb mempool allocation is unnecessary.

---
2.11.0

Patch applied to next-virtio/main with conflict resolved, Thanks

This patch triggered a regression reported by Red Hat QE.
https://bugs.dpdk.org/show_bug.cgi?id=703

Quoted 7 lines

Reverting the patch is enough to fix the regression.

I'll let you guys decide on the next step for 21.05.

--
David Marchand

Quoted 9 lines

I cannot reproduce this issue on my machine.

@Wan Junjie Could you reproduce this? I prefer to revert the patch if things are not very clear as it is only a minor optimization.

Thanks,
Chenbo

Hi Chenbo,

I am not available for this now. Please revert it. Will dig it later.

Thanks,
Junjie

#5 lore raw
Quoted 71 lines

-----Original Message-----
From: Wan Junjie <[email protected]>
Sent: Thursday, May 13, 2021 6:52 PM
To: Xia, Chenbo <[email protected]>
Cc: David Marchand <[email protected]>; Maxime Coquelin <[email protected]>; [email protected]; Peng He <[email protected]>; Zhihong Wang <[email protected]>; Thomas Monjalon <[email protected]>
Subject: Re: [External] RE: [dpdk-dev] [PATCH v2] vhost: avoid iotlb mempool allocation while IOMMU disabled

Quoted 9 lines · Chenbo
Quoted 9 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, May 13, 2021 4:39 PM
To: Xia, Chenbo <[email protected]>; Maxime Coquelin <[email protected]>
Cc: Wan Junjie <[email protected]>; [email protected]; Peng He <[email protected]>; Zhihong Wang <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] vhost: avoid iotlb mempool allocation

while

Quoted 11 lines
Quoted 11 lines

IOMMU disabled

Quoted 8 lines · Chenbo
Quoted 8 lines

-----Original Message-----
From: Wan Junjie <[email protected]>
Sent: Tuesday, February 2, 2021 4:15 PM
To: Xia, Chenbo <[email protected]>; Maxime Coquelin <[email protected]>
Cc: [email protected]; Wan Junjie <[email protected]>; Peng He <[email protected]>; Zhihong Wang

<[email protected]>

Quoted 27 lines
Quoted 19 lines
Quoted 1 line
Quoted 1 line

Subject: [PATCH v2] vhost: avoid iotlb mempool allocation while IOMMU

disabled

Quoted 11 lines
Quoted 9 lines

If vhost device's IOMMU feature is disabled, iotlb mempool allocation is unnecessary.

---
2.11.0

Patch applied to next-virtio/main with conflict resolved, Thanks

This patch triggered a regression reported by Red Hat QE.
https://bugs.dpdk.org/show_bug.cgi?id=703

Quoted 7 lines

Reverting the patch is enough to fix the regression.

I'll let you guys decide on the next step for 21.05.

--
David Marchand

Quoted 9 lines

I cannot reproduce this issue on my machine.

@Wan Junjie Could you reproduce this? I prefer to revert the patch if things are not very clear as it is only a minor optimization.

Thanks,
Chenbo

Quoted 7 lines

Hi Chenbo,

I am not available for this now. Please revert it. Will dig it later.

Thanks,
Junjie

Luckily I can reproduce now. I will take a look.

Chenbo

#6 lore raw
In reply to Wan Junjie

Hi,

Quoted 71 lines

-----Original Message-----
From: Wan Junjie <[email protected]>
Sent: Thursday, May 13, 2021 6:52 PM
To: Xia, Chenbo <[email protected]>
Cc: David Marchand <[email protected]>; Maxime Coquelin <[email protected]>; [email protected]; Peng He <[email protected]>; Zhihong Wang <[email protected]>; Thomas Monjalon <[email protected]>
Subject: Re: [External] RE: [dpdk-dev] [PATCH v2] vhost: avoid iotlb mempool allocation while IOMMU disabled

Quoted 9 lines · Chenbo
Quoted 9 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, May 13, 2021 4:39 PM
To: Xia, Chenbo <[email protected]>; Maxime Coquelin <[email protected]>
Cc: Wan Junjie <[email protected]>; [email protected]; Peng He <[email protected]>; Zhihong Wang <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] vhost: avoid iotlb mempool allocation

while

Quoted 11 lines
Quoted 11 lines

IOMMU disabled

Quoted 8 lines · Chenbo
Quoted 8 lines

-----Original Message-----
From: Wan Junjie <[email protected]>
Sent: Tuesday, February 2, 2021 4:15 PM
To: Xia, Chenbo <[email protected]>; Maxime Coquelin <[email protected]>
Cc: [email protected]; Wan Junjie <[email protected]>; Peng He <[email protected]>; Zhihong Wang

<[email protected]>

Quoted 27 lines
Quoted 19 lines
Quoted 1 line
Quoted 1 line

Subject: [PATCH v2] vhost: avoid iotlb mempool allocation while IOMMU

disabled

Quoted 11 lines
Quoted 9 lines

If vhost device's IOMMU feature is disabled, iotlb mempool allocation is unnecessary.

---
2.11.0

Patch applied to next-virtio/main with conflict resolved, Thanks

This patch triggered a regression reported by Red Hat QE.
https://bugs.dpdk.org/show_bug.cgi?id=703

Quoted 7 lines

Reverting the patch is enough to fix the regression.

I'll let you guys decide on the next step for 21.05.

--
David Marchand

Quoted 9 lines

I cannot reproduce this issue on my machine.

@Wan Junjie Could you reproduce this? I prefer to revert the patch if things are not very clear as it is only a minor optimization.

Thanks,
Chenbo

Quoted 7 lines

Hi Chenbo,

I am not available for this now. Please revert it. Will dig it later.

Thanks,
Junjie

I know the root cause, it is because when multi-queue is on, qemu only enable the first queue pair and does not 'VHOST_USER_SET_VRING_NUM' for other queue pairs, which leads to disabled queue pairs' iotlb_pool not init-ed. Then comes the iotlb message that operate on all queue pairs iotlb pool.

A fix is coming.

Thanks,
Chenbo