vhost: fix zmbuf buffer id invalid
PATCH 1/1 vhost: fix zmbuf buffer id invalid
zc mbufs should record available buffer id when doing dequeue zcopy. There's no guarantee that local queue avail index equal to buffer index.
lib/librte_vhost/virtio_net.c +2 -2
@@ -2004,7 +2004,7 @@ virtio_dev_tx_batch_packed_zmbuf(struct virtio_net *dev,vhost_for_each_try_unroll (i,0 ,PACKED_BATCH_SIZE ) { zmbufs[i]->mbuf = pkts[i]; - zmbufs[i]->desc_idx = avail_idx + i; + zmbufs[i]->desc_idx = ids[i]; zmbufs[i]->desc_count =1 ; }
@@ -2045,7 +2045,7 @@ virtio_dev_tx_single_packed_zmbuf(struct virtio_net *dev,return -1 ; } zmbuf->mbuf = *pkts; - zmbuf->desc_idx = vq->last_avail_idx; + zmbuf->desc_idx = buf_id; zmbuf->desc_count = desc_count;rte_mbuf_refcnt_update (*pkts,1 );
Signature · 1 line
2.17.1
I would make the title a bit more generic, e.g.:
vhost: fix packed ring zero-copy
Quoted 1 line · Marvin Liu
zc mbufs should record available buffer id when doing dequeue zcopy.
Available buffer ID should be stored in the mbuf in the packed-ring dequeue path.
Quoted 23 lines
There's no guarantee that local queue avail index equal to buffer index.
Fixes d1eafb532268 ("vhost: add packed ring zcopy batch and single dequeue")Signed-off-by Marvin Liu <[email protected]>Reported-by Yinan Wang <[email protected]>lib/librte_vhost/virtio_net.c +1
-1@@ -2004,7 +2004,7 @@ virtio_dev_tx_batch_packed_zmbuf(struct virtio_net *dev,vhost_for_each_try_unroll (i,0 ,PACKED_BATCH_SIZE ) { zmbufs[i]->mbuf = pkts[i]; - zmbufs[i]->desc_idx = avail_idx + i; + zmbufs[i]->desc_idx = ids[i]; zmbufs[i]->desc_count =1 ; }
lib/librte_vhost/virtio_net.c virtio_dev_tx_single_packed_zmbuf(struct virtio_net *dev, · line 2051
Quoted 8 lines
lib/librte_vhost/virtio_net.c +1
-1@@ -2045,7 +2045,7 @@ virtio_dev_tx_single_packed_zmbuf(struct virtio_net *dev,return -1 ; } zmbuf->mbuf = *pkts; - zmbuf->desc_idx = vq->last_avail_idx; + zmbuf->desc_idx = buf_id; zmbuf->desc_count = desc_count;rte_mbuf_refcnt_update (*pkts,1 );
With the commit message fixed:
Thanks,
Maxime
For the subject, what about:
vhost: fix invalid zmbuf buffer id
Quoted 2 lines · Marvin Liu
zc mbufs should record available buffer id when doing dequeue zcopy. There's no guarantee that local queue avail index equal to buffer index.
s/equal to/is equal to
Quoted 32 lines
Fixes d1eafb532268 ("vhost: add packed ring zcopy batch and single dequeue")Signed-off-by Marvin Liu <[email protected]>Reported-by Yinan Wang <[email protected]>lib/librte_vhost/virtio_net.c +2
-2@@ -2004,7 +2004,7 @@ virtio_dev_tx_batch_packed_zmbuf(struct virtio_net *dev,vhost_for_each_try_unroll (i,0 ,PACKED_BATCH_SIZE ) { zmbufs[i]->mbuf = pkts[i]; - zmbufs[i]->desc_idx = avail_idx + i; + zmbufs[i]->desc_idx = ids[i]; zmbufs[i]->desc_count =1 ; }@@ -2045,7 +2045,7 @@ virtio_dev_tx_single_packed_zmbuf(struct virtio_net *dev,return -1 ; } zmbuf->mbuf = *pkts; - zmbuf->desc_idx = vq->last_avail_idx; + zmbuf->desc_idx = buf_id; zmbuf->desc_count = desc_count;rte_mbuf_refcnt_update (*pkts,1 );Signature · 1 line
2.17.1
Apart from above,
Thanks, xiaolong & maxime. Commits log has been fixed in v2.
Quoted 59 lines
-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Monday, February 24, 2020 3:26 PM
To: Liu, Yong <[email protected]>
Cc: [email protected]; [email protected]; Bie, Tiwei <[email protected]>; Wang, Zhihong <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH] vhost: fix zmbuf buffer id invalidFor the subject, what about:
vhost: fix invalid zmbuf buffer id
Quoted 2 lines · Marvin Liu
zc mbufs should record available buffer id when doing dequeue zcopy. There's no guarantee that local queue avail index equal to buffer index.
s/equal to/is equal to
Quoted 2 lines
Fixes d1eafb532268 ("vhost: add packed ring zcopy batch and singledequeue")
Review
Quoted 6 lines
Signed-off-by Marvin Liu <[email protected]>Reported-by Yinan Wang <[email protected]>(quoted diff) +0
-0
b/lib/librte_vhost/virtio_net.clib/librte_vhost/virtio_net.c virtio_dev_tx_batch_packed_zmbuf(struct virtio_net
Quoted 4 lines
index 37c47c7dc..210415904 100644
lib/librte_vhost/virtio_net.c +0
-0@@ -2004,7 +2004,7 @@ virtio_dev_tx_batch_packed_zmbuf(struct virtio_net*dev,
lib/librte_vhost/virtio_net.c virtio_dev_tx_single_packed_zmbuf(struct
Quoted 9 lines
lib/librte_vhost/virtio_net.c +1
-1vhost_for_each_try_unroll (i,0 ,PACKED_BATCH_SIZE ) { zmbufs[i]->mbuf = pkts[i]; - zmbufs[i]->desc_idx = avail_idx + i; + zmbufs[i]->desc_idx = ids[i]; zmbufs[i]->desc_count =1 ; }@@ -2045,7 +2045,7 @@ virtio_dev_tx_single_packed_zmbuf(struct
virtio_net*dev,Quoted 11 lines
lib/librte_vhost/virtio_net.c +1
-2return -1 ; } zmbuf->mbuf = *pkts; - zmbuf->desc_idx = vq->last_avail_idx; + zmbuf->desc_idx = buf_id; zmbuf->desc_count = desc_count;rte_mbuf_refcnt_update (*pkts,1 ); --2.17.1
Apart from above,
Reviewed-by Xiaolong Ye <[email protected]>
PATCH v2 1/1 vhost: fix packed ring zero-copy
In reply to Marvin LiuAvailable buffer ID should be stored in the zmbuf in the packed-ring dequeue path. There's no guarantee that local queue avail index is equal to buffer ID.
lib/librte_vhost/virtio_net.c +2 -2
@@ -2004,7 +2004,7 @@ virtio_dev_tx_batch_packed_zmbuf(struct virtio_net *dev,vhost_for_each_try_unroll (i,0 ,PACKED_BATCH_SIZE ) { zmbufs[i]->mbuf = pkts[i]; - zmbufs[i]->desc_idx = avail_idx + i; + zmbufs[i]->desc_idx = ids[i]; zmbufs[i]->desc_count =1 ; }
@@ -2045,7 +2045,7 @@ virtio_dev_tx_single_packed_zmbuf(struct virtio_net *dev,return -1 ; } zmbuf->mbuf = *pkts; - zmbuf->desc_idx = vq->last_avail_idx; + zmbuf->desc_idx = buf_id; zmbuf->desc_count = desc_count;rte_mbuf_refcnt_update (*pkts,1 );
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v2] vhost: fix packed ring zero-copy
Hi David & Thomas,
Quoted 11 lines · Marvin Liu
Available buffer ID should be stored in the zmbuf in the packed-ring dequeue path. There's no guarantee that local queue avail index is equal to buffer ID.
Fixes d1eafb532268 ("vhost: add packed ring zcopy batch and single dequeue")Signed-off-by Marvin Liu <[email protected]>Reported-by Yinan Wang <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>
If it is not too late, I think we should pick this patch for v20.02. It is fixing a regression introduced in DPDK v19.11.
The risk of this patch causing a regression is very low, as it is touching only the zero-copy packed ring dequeue path, which wihtout this patch is anyway broken.
Thanks,
Maxime
Re: [dpdk-dev] [PATCH v2] vhost: fix packed ring zero-copy
Quoted 11 lines · Maxime Coquelin
Hi David & Thomas,
Quoted 7 lines · Marvin Liu
Available buffer ID should be stored in the zmbuf in the packed-ring dequeue path. There's no guarantee that local queue avail index is equal to buffer ID.
Fixes d1eafb532268 ("vhost: add packed ring zcopy batch and single dequeue")
Quoted 7 lines
Quoted 4 lines
Signed-off-by Marvin Liu <[email protected]>Reported-by Yinan Wang <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>If it is not too late, I think we should pick this patch for v20.02. It is fixing a regression introduced in DPDK v19.11.
I might have cold feet, but taking this fix right now feels risky. If the problem has been there since 19.11, it can wait 20.05 and it will go to 19.11 after proper validation.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v2] vhost: fix packed ring zero-copy
Quoted 18 lines · David Marchand
Quoted 16 lines · Maxime Coquelin
Hi David & Thomas,
Quoted 11 lines · Marvin Liu
Available buffer ID should be stored in the zmbuf in the packed-ring dequeue path. There's no guarantee that local queue avail index is equal to buffer ID.
Fixes d1eafb532268 ("vhost: add packed ring zcopy batch and single dequeue")Signed-off-by Marvin Liu <[email protected]>Reported-by Yinan Wang <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>
Quoted 6 lines
Quoted 2 lines
If it is not too late, I think we should pick this patch for v20.02. It is fixing a regression introduced in DPDK v19.11.
I might have cold feet, but taking this fix right now feels risky. If the problem has been there since 19.11, it can wait 20.05 and it will go to 19.11 after proper validation.
Ok, I get your point and it's your call. Now, this fix is really isolated to zero-copy packed ring, so the only risk IMO is to break something that is already not working.
Thanks,
Maxime