From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D0C99A04DD for ; Wed, 28 Oct 2020 11:49:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C937AC9D6; Wed, 28 Oct 2020 11:49:45 +0100 (CET) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id E3906C9D6 for ; Wed, 28 Oct 2020 11:49:44 +0100 (CET) Received: by mail-wr1-f65.google.com with SMTP id g12so5122376wrp.10 for ; Wed, 28 Oct 2020 03:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I2gr53KMgbtq/y9HU8I9txRU5ZVofsm9SnVvhgfy3/k=; b=PUrJ76vOWqMBZjiF675ReGdv0sqyXFQXs/ElMlcmlnxsdrYFzCKzpmhGLOQEL2R6v1 fzxA2aX6oug1ylpHfsGX2MjrleNFtVcuGM74SvPhSU3iKRQJi0rIODafrQ0rhJYhoh3a LKRqJAyKQx+DxOVBlk189mpH6zBEtJSWpxmSIfJD26KsF3Tn5n9NjyovH0jMBzacefXo g3WJsqBp+TD3gwmAh6LreL6MJ6RSe80/ZbrOAu4XK24FaAq8L8z6gXmP++FudcVpu5Hk SAHsaTyYzsBhq24E835qs9tqkdhgdB+FvXG1a/Ij+VvLnOv6aMpMukst3Rpub3fwrvmR aNsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I2gr53KMgbtq/y9HU8I9txRU5ZVofsm9SnVvhgfy3/k=; b=aK+rL7Cpqr8D/QzpNKgxWojZNYAujZAm2nJjfRhIC13V/ipCj9ABjm4acm7340dsdJ qpUZSYVmx/fgB+unPWKhQKZ2twQetBVLjuBABNwiSucA9ut6MdZAf2KvzVa2g3mW7jWO q/YlQlp3/zMiz73W14H58EWdMf8aLKzP27g9eF10mAIq41/h6CF8GIVWfrnHmEpMHjjM yaDBWb9AmkdVTR4E85eyoSFq6FJ8xO7nd21C+Ynv6SEFIrK5d/U3SLC9pJ8kzDOZy39y Bin4elhMh+0+Q8HsszJwVxPft78YrKn/qDAmwh5hjJNCWuW7oUkL541TqVoTt5iSicDR NPUQ== X-Gm-Message-State: AOAM530SCHXHMMF1JDQbaVFk7y2Kwp6kMb8i3xasQALFF2xDFQ1O31Ma i3uS6ne5pygAqe3khL5VOVE= X-Google-Smtp-Source: ABdhPJzWaW4mGb5khVfspqFQpxqtMs6XqyzwPkEsKMGlXZIUjAW8ClhsT90DvBtQ0O58nNZeeJGW9A== X-Received: by 2002:adf:fe4b:: with SMTP id m11mr7613914wrs.98.1603882183673; Wed, 28 Oct 2020 03:49:43 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id m9sm5759332wmc.31.2020.10.28.03.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 03:49:43 -0700 (PDT) From: luca.boccassi@gmail.com To: RongQing Li Cc: Dongsheng Rong , Ciara Loftus , dpdk stable Date: Wed, 28 Oct 2020 10:43:47 +0000 Message-Id: <20201028104606.3504127-68-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028104606.3504127-1-luca.boccassi@gmail.com> References: <20201028104606.3504127-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/af_xdp: avoid deadlock due to empty fill queue' has been queued to stable release 19.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 10/30/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From d412170b226f6f5de3d6799697fd242e28f5b7b6 Mon Sep 17 00:00:00 2001 From: RongQing Li Date: Fri, 18 Sep 2020 19:32:31 +0800 Subject: [PATCH] net/af_xdp: avoid deadlock due to empty fill queue [ upstream commit ab7ed23a2f3e74f1341de76b19256842c4cdc7f2 ] While receiving packets, it is possible to fail to reserve fill queue, since buffer ring is shared between tx and rx, and maybe not available temporary. As a result both fill queue and Rx queue will be empty. Then kernel side will not be able to receive packets due to empty fill queue, and dpdk will not be able to reserve fill queue because dpdk doesn't have packets to receive, finally deadlock will happen. So move reserve fill queue before xsk_ring_cons__peek to fix it. Signed-off-by: RongQing Li Signed-off-by: Dongsheng Rong Acked-by: Ciara Loftus --- drivers/net/af_xdp/rte_eth_af_xdp.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index fbc95e5483..c5c906ff96 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -305,22 +305,23 @@ 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 (unlikely(rte_pktmbuf_alloc_bulk(rxq->mb_pool, mbufs, nb_pkts) != 0)) - return 0; - - rcvd = xsk_ring_cons__peek(rx, nb_pkts, &idx_rx); - if (rcvd == 0) { -#if defined(XDP_USE_NEED_WAKEUP) - if (xsk_ring_prod__needs_wakeup(fq)) - (void)poll(rxq->fds, 1, 1000); -#endif - - goto out; - } - 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; + + rcvd = xsk_ring_cons__peek(rx, nb_pkts, &idx_rx); + if (rcvd == 0) { +#if defined(XDP_USE_NEED_WAKEUP) + if (xsk_ring_prod__needs_wakeup(fq)) + (void)poll(rxq->fds, 1, 1000); +#endif + + goto out; + } + for (i = 0; i < rcvd; i++) { const struct xdp_desc *desc; uint64_t addr; -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-10-28 10:35:13.876590801 +0000 +++ 0068-net-af_xdp-avoid-deadlock-due-to-empty-fill-queue.patch 2020-10-28 10:35:11.540830553 +0000 @@ -1,8 +1,10 @@ -From ab7ed23a2f3e74f1341de76b19256842c4cdc7f2 Mon Sep 17 00:00:00 2001 +From d412170b226f6f5de3d6799697fd242e28f5b7b6 Mon Sep 17 00:00:00 2001 From: RongQing Li Date: Fri, 18 Sep 2020 19:32:31 +0800 Subject: [PATCH] net/af_xdp: avoid deadlock due to empty fill queue +[ upstream commit ab7ed23a2f3e74f1341de76b19256842c4cdc7f2 ] + While receiving packets, it is possible to fail to reserve fill queue, since buffer ring is shared between tx and rx, and maybe not available temporary. As a result both fill @@ -15,8 +17,6 @@ So move reserve fill queue before xsk_ring_cons__peek to fix it. -Cc: stable@dpdk.org - Signed-off-by: RongQing Li Signed-off-by: Dongsheng Rong Acked-by: Ciara Loftus @@ -25,10 +25,10 @@ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c -index b65ee449fc..00de671841 100644 +index fbc95e5483..c5c906ff96 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c -@@ -304,22 +304,23 @@ af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) +@@ -305,22 +305,23 @@ 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];