[V2] net/af_xdp: avoid deadlock due to empty fill queue

Message ID 1600428751-30105-1-git-send-email-lirongqing@baidu.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [V2] net/af_xdp: avoid deadlock due to empty fill queue |

Checks

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

Commit Message

Li RongQing Sept. 18, 2020, 11:32 a.m. UTC
  when receive packets, it is possible to fail to reserve
fill queue, since buffer ring is shared between tx and rx,
and maybe not available temporary. at last, both fill
queue and rx queue are empty.

then kernel side will be unable to receive packets due to
empty fill queue, and dpdk will be unable to reserve fill
queue because dpdk has not pakcets to receive, at last
deadlock will happen

so move reserve fill queue before xsk_ring_cons__peek
to fix it

Acked-by: Ciara Loftus <ciara.loftus@intel.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: Dongsheng Rong <rongdongsheng@baidu.com>
Cc: stable@dpdk.org
---
  

Comments

Ferruh Yigit Sept. 22, 2020, 1:04 p.m. UTC | #1
On 9/18/2020 12:32 PM, Li RongQing wrote:
> when receive packets, it is possible to fail to reserve
> fill queue, since buffer ring is shared between tx and rx,
> and maybe not available temporary. at last, both fill
> queue and rx queue are empty.
> 
> then kernel side will be unable to receive packets due to
> empty fill queue, and dpdk will be unable to reserve fill
> queue because dpdk has not pakcets to receive, at last
> deadlock will happen
> 
> so move reserve fill queue before xsk_ring_cons__peek
> to fix it
 >
 > Cc: stable@dpdk.org
> 
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> Signed-off-by: Dongsheng Rong <rongdongsheng@baidu.com>
> Acked-by: Ciara Loftus <ciara.loftus@intel.com>

Applied to dpdk-next-net/main, thanks.
  

Patch

diff with v1: 

cc stable@dpdk.org
change af_xdp: as net/af_xdp

 drivers/net/af_xdp/rte_eth_af_xdp.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 7ce4ad04a..2dc9cab27 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -304,6 +304,10 @@  af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	uint32_t free_thresh = fq->size >> 1;
 	struct rte_mbuf *mbufs[ETH_AF_XDP_RX_BATCH_SIZE];
 
+	if (xsk_prod_nb_free(fq, free_thresh) >= free_thresh)
+		(void)reserve_fill_queue(umem, ETH_AF_XDP_RX_BATCH_SIZE, NULL);
+
+
 	if (unlikely(rte_pktmbuf_alloc_bulk(rxq->mb_pool, mbufs, nb_pkts) != 0))
 		return 0;
 
@@ -317,9 +321,6 @@  af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 		goto out;
 	}
 
-	if (xsk_prod_nb_free(fq, free_thresh) >= free_thresh)
-		(void)reserve_fill_queue(umem, ETH_AF_XDP_RX_BATCH_SIZE, NULL);
-
 	for (i = 0; i < rcvd; i++) {
 		const struct xdp_desc *desc;
 		uint64_t addr;