diff mbox series

vhost: fix zmbuf buffer id invalid

Message ID 20200224145025.84899-1-yong.liu@intel.com (mailing list archive)
State Superseded, archived
Headers show
Series vhost: fix zmbuf buffer id invalid | expand

Checks

Context Check Description
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/checkpatch success coding style OK

Commit Message

Liu, Yong Feb. 24, 2020, 2:50 p.m. UTC
zc mbufs should record available buffer id when doing dequeue zcopy.
There's no guarantee that local queue avail index equal to buffer index.

Fixes: d1eafb532268 ("vhost: add packed ring zcopy batch and single dequeue")
Cc: stable@dpdk.org

Signed-off-by: Marvin Liu <yong.liu@intel.com>
Reported-by: Yinan Wang <yinan.wang@intel.com>

Comments

Xiaolong Ye Feb. 24, 2020, 7:25 a.m. UTC | #1
For the subject, what about:

vhost: fix invalid zmbuf buffer id

On 02/24, Marvin Liu wrote:
>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

>
>Fixes: d1eafb532268 ("vhost: add packed ring zcopy batch and single dequeue")
>Cc: stable@dpdk.org
>
>Signed-off-by: Marvin Liu <yong.liu@intel.com>
>Reported-by: Yinan Wang <yinan.wang@intel.com>
>
>diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
>index 37c47c7dc..210415904 100644
>--- a/lib/librte_vhost/virtio_net.c
>+++ b/lib/librte_vhost/virtio_net.c
>@@ -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);
>-- 
>2.17.1
>

Apart from above,

Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
Maxime Coquelin Feb. 24, 2020, 7:27 a.m. UTC | #2
I would make the title a bit more generic, e.g.:

vhost: fix packed ring zero-copy

On 2/24/20 3:50 PM, Marvin Liu wrote:
> 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.

> There's no guarantee that local queue avail index equal to buffer index.
> 
> Fixes: d1eafb532268 ("vhost: add packed ring zcopy batch and single dequeue")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Marvin Liu <yong.liu@intel.com>
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> 
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index 37c47c7dc..210415904 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -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);
> 

With the commit message fixed:
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
Liu, Yong Feb. 24, 2020, 7:39 a.m. UTC | #3
Thanks, xiaolong & maxime. Commits log has been fixed in v2.

> -----Original Message-----
> From: Ye, Xiaolong <xiaolong.ye@intel.com>
> Sent: Monday, February 24, 2020 3:26 PM
> To: Liu, Yong <yong.liu@intel.com>
> Cc: maxime.coquelin@redhat.com; dev@dpdk.org; Bie, Tiwei
> <tiwei.bie@intel.com>; Wang, Zhihong <zhihong.wang@intel.com>;
> stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] vhost: fix zmbuf buffer id invalid
> 
> For the subject, what about:
> 
> vhost: fix invalid zmbuf buffer id
> 
> On 02/24, Marvin Liu wrote:
> >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
> 
> >
> >Fixes: d1eafb532268 ("vhost: add packed ring zcopy batch and single
> dequeue")
> >Cc: stable@dpdk.org
> >
> >Signed-off-by: Marvin Liu <yong.liu@intel.com>
> >Reported-by: Yinan Wang <yinan.wang@intel.com>
> >
> >diff --git a/lib/librte_vhost/virtio_net.c
> b/lib/librte_vhost/virtio_net.c
> >index 37c47c7dc..210415904 100644
> >--- a/lib/librte_vhost/virtio_net.c
> >+++ b/lib/librte_vhost/virtio_net.c
> >@@ -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);
> >--
> >2.17.1
> >
> 
> Apart from above,
> 
> Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
diff mbox series

Patch

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 37c47c7dc..210415904 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -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);