diff mbox series

net/virtio: fix vectorized Rx queue stuck

Message ID 20210414042631.7041-1-xuemingl@nvidia.com (mailing list archive)
State Superseded, archived
Headers show
Series net/virtio: fix vectorized Rx queue stuck | expand

Checks

Context Check Description
ci/iol-testing fail Testing issues
ci/intel-Testing success Testing PASS
ci/github-robot success github build: passed
ci/travis-robot success travis build: passed
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Xueming(Steven) Li April 14, 2021, 4:26 a.m. UTC
When Rx burst size >= Rx queue size, all descriptors in used queue
consumed without rearm, the next Rx burst found no new packets and
returned directly without rearm as well.

This patch rearms available queue at once after rx_burst to avoid vq
hungry.

Fixes: fc3d66212fed ("virtio: add vector Rx")
Cc: huawei.xie@intel.com
Fixes: 2d7c37194ee4 ("net/virtio: add NEON based Rx handler")
Cc: jerin.jacob@caviumnetworks.com
Fixes: 52b5a707e6ca ("net/virtio: add Altivec Rx")
Cc: drc@linux.vnet.ibm.com
Cc: stable@dpdk.org

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 drivers/net/virtio/virtio_rxtx_simple_altivec.c | 12 ++++++------
 drivers/net/virtio/virtio_rxtx_simple_neon.c    | 12 ++++++------
 drivers/net/virtio/virtio_rxtx_simple_sse.c     | 12 ++++++------
 3 files changed, 18 insertions(+), 18 deletions(-)

Comments

Xueming(Steven) Li April 14, 2021, 6:11 a.m. UTC | #1
+@谢华伟(此时此刻) <huawei.xhw@alibaba-inc.com>

> -----Original Message-----
> From: Xueming Li <xuemingl@nvidia.com>
> Sent: Wednesday, April 14, 2021 12:27 PM
> Cc: dev@dpdk.org; Xueming(Steven) Li <xuemingl@nvidia.com>; huawei.xie@intel.com; jerin.jacob@caviumnetworks.com;
> drc@linux.vnet.ibm.com; stable@dpdk.org; Maxime Coquelin <maxime.coquelin@redhat.com>; Chenbo Xia <chenbo.xia@intel.com>;
> Jerin Jacob <jerinj@marvell.com>; Ruifeng Wang <ruifeng.wang@arm.com>; Bruce Richardson <bruce.richardson@intel.com>;
> Konstantin Ananyev <konstantin.ananyev@intel.com>; Jianfeng Tan <jianfeng.tan@intel.com>; Jianbo Liu <jianbo.liu@linaro.org>;
> Yuanhan Liu <yuanhan.liu@linux.intel.com>
> Subject: [PATCH] net/virtio: fix vectorized Rx queue stuck
> 
> When Rx burst size >= Rx queue size, all descriptors in used queue consumed without rearm, the next Rx burst found no new packets
> and returned directly without rearm as well.
> 
> This patch rearms available queue at once after rx_burst to avoid vq hungry.
> 
> Fixes: fc3d66212fed ("virtio: add vector Rx")
> Cc: huawei.xie@intel.com
> Fixes: 2d7c37194ee4 ("net/virtio: add NEON based Rx handler")
> Cc: jerin.jacob@caviumnetworks.com
> Fixes: 52b5a707e6ca ("net/virtio: add Altivec Rx")
> Cc: drc@linux.vnet.ibm.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> ---
>  drivers/net/virtio/virtio_rxtx_simple_altivec.c | 12 ++++++------
>  drivers/net/virtio/virtio_rxtx_simple_neon.c    | 12 ++++++------
>  drivers/net/virtio/virtio_rxtx_simple_sse.c     | 12 ++++++------
>  3 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_rxtx_simple_altivec.c b/drivers/net/virtio/virtio_rxtx_simple_altivec.c
> index 62e5100a48..1ffae234da 100644
> --- a/drivers/net/virtio/virtio_rxtx_simple_altivec.c
> +++ b/drivers/net/virtio/virtio_rxtx_simple_altivec.c
> @@ -102,12 +102,6 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
> 
>  	rte_prefetch0(rused);
> 
> -	if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
> -		virtio_rxq_rearm_vec(rxvq);
> -		if (unlikely(virtqueue_kick_prepare(vq)))
> -			virtqueue_notify(vq);
> -	}
> -
>  	nb_total = nb_used;
>  	ref_rx_pkts = rx_pkts;
>  	for (nb_pkts_received = 0;
> @@ -204,5 +198,11 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
>  	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++)
>  		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
> 
> +	if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
> +		virtio_rxq_rearm_vec(rxvq);
> +		if (unlikely(virtqueue_kick_prepare(vq)))
> +			virtqueue_notify(vq);
> +	}
> +
>  	return nb_pkts_received;
>  }
> diff --git a/drivers/net/virtio/virtio_rxtx_simple_neon.c b/drivers/net/virtio/virtio_rxtx_simple_neon.c
> index c8e4b13a02..341dedce41 100644
> --- a/drivers/net/virtio/virtio_rxtx_simple_neon.c
> +++ b/drivers/net/virtio/virtio_rxtx_simple_neon.c
> @@ -100,12 +100,6 @@ virtio_recv_pkts_vec(void *rx_queue,
> 
>  	rte_prefetch_non_temporal(rused);
> 
> -	if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
> -		virtio_rxq_rearm_vec(rxvq);
> -		if (unlikely(virtqueue_kick_prepare(vq)))
> -			virtqueue_notify(vq);
> -	}
> -
>  	nb_total = nb_used;
>  	ref_rx_pkts = rx_pkts;
>  	for (nb_pkts_received = 0;
> @@ -210,5 +204,11 @@ virtio_recv_pkts_vec(void *rx_queue,
>  	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++)
>  		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
> 
> +	if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
> +		virtio_rxq_rearm_vec(rxvq);
> +		if (unlikely(virtqueue_kick_prepare(vq)))
> +			virtqueue_notify(vq);
> +	}
> +
>  	return nb_pkts_received;
>  }
> diff --git a/drivers/net/virtio/virtio_rxtx_simple_sse.c b/drivers/net/virtio/virtio_rxtx_simple_sse.c
> index ff4eba33d6..2e17f9d1f2 100644
> --- a/drivers/net/virtio/virtio_rxtx_simple_sse.c
> +++ b/drivers/net/virtio/virtio_rxtx_simple_sse.c
> @@ -100,12 +100,6 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
> 
>  	rte_prefetch0(rused);
> 
> -	if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
> -		virtio_rxq_rearm_vec(rxvq);
> -		if (unlikely(virtqueue_kick_prepare(vq)))
> -			virtqueue_notify(vq);
> -	}
> -
>  	nb_total = nb_used;
>  	ref_rx_pkts = rx_pkts;
>  	for (nb_pkts_received = 0;
> @@ -194,5 +188,11 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
>  	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++)
>  		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
> 
> +	if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
> +		virtio_rxq_rearm_vec(rxvq);
> +		if (unlikely(virtqueue_kick_prepare(vq)))
> +			virtqueue_notify(vq);
> +	}
> +
>  	return nb_pkts_received;
>  }
> --
> 2.25.1
diff mbox series

Patch

diff --git a/drivers/net/virtio/virtio_rxtx_simple_altivec.c b/drivers/net/virtio/virtio_rxtx_simple_altivec.c
index 62e5100a48..1ffae234da 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_altivec.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_altivec.c
@@ -102,12 +102,6 @@  virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 	rte_prefetch0(rused);
 
-	if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
-		virtio_rxq_rearm_vec(rxvq);
-		if (unlikely(virtqueue_kick_prepare(vq)))
-			virtqueue_notify(vq);
-	}
-
 	nb_total = nb_used;
 	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
@@ -204,5 +198,11 @@  virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++)
 		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
 
+	if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
+		virtio_rxq_rearm_vec(rxvq);
+		if (unlikely(virtqueue_kick_prepare(vq)))
+			virtqueue_notify(vq);
+	}
+
 	return nb_pkts_received;
 }
diff --git a/drivers/net/virtio/virtio_rxtx_simple_neon.c b/drivers/net/virtio/virtio_rxtx_simple_neon.c
index c8e4b13a02..341dedce41 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_neon.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_neon.c
@@ -100,12 +100,6 @@  virtio_recv_pkts_vec(void *rx_queue,
 
 	rte_prefetch_non_temporal(rused);
 
-	if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
-		virtio_rxq_rearm_vec(rxvq);
-		if (unlikely(virtqueue_kick_prepare(vq)))
-			virtqueue_notify(vq);
-	}
-
 	nb_total = nb_used;
 	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
@@ -210,5 +204,11 @@  virtio_recv_pkts_vec(void *rx_queue,
 	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++)
 		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
 
+	if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
+		virtio_rxq_rearm_vec(rxvq);
+		if (unlikely(virtqueue_kick_prepare(vq)))
+			virtqueue_notify(vq);
+	}
+
 	return nb_pkts_received;
 }
diff --git a/drivers/net/virtio/virtio_rxtx_simple_sse.c b/drivers/net/virtio/virtio_rxtx_simple_sse.c
index ff4eba33d6..2e17f9d1f2 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_sse.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_sse.c
@@ -100,12 +100,6 @@  virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 	rte_prefetch0(rused);
 
-	if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
-		virtio_rxq_rearm_vec(rxvq);
-		if (unlikely(virtqueue_kick_prepare(vq)))
-			virtqueue_notify(vq);
-	}
-
 	nb_total = nb_used;
 	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
@@ -194,5 +188,11 @@  virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++)
 		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
 
+	if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
+		virtio_rxq_rearm_vec(rxvq);
+		if (unlikely(virtqueue_kick_prepare(vq)))
+			virtqueue_notify(vq);
+	}
+
 	return nb_pkts_received;
 }