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 AA0B0A0093 for ; Tue, 19 May 2020 15:12:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A11571D702; Tue, 19 May 2020 15:12:36 +0200 (CEST) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by dpdk.org (Postfix) with ESMTP id 4BFAE1D702 for ; Tue, 19 May 2020 15:12:35 +0200 (CEST) Received: by mail-wm1-f49.google.com with SMTP id g14so2422573wme.1 for ; Tue, 19 May 2020 06:12:35 -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=x3OTAPnH1UPXHwyfYMWB36U+tLMgFlsjHFWGzD7bccE=; b=Kx0ED1tusvUaLk9nhqKBDNEfgjDc5GW2v5u4cXh4SBD1Yh7deiCr6eYFpWM8e9rct+ uP1PnF49Pq7HQwjUA+Z8TT0yqaHCFkCQ5Y1FsGpSEK7O0Z+mQhCekYMOj94PraMYKuK0 Xawtxuddn7xUygKnpcszkNV97I94/PvZYtoIRCNP5wOMLIjaYIoyM5SvH5G7GXQbjmHl RX8ABTxq0tP8NSmeOwUa5G1V7tusxihYP3m/6vjlsVaQgJgsVn2XHBJbOin/hLuSgXFl dcfY3LVIOGmzqP8z/966DQcMlY1FqqgFvOempyxS1Yn1eb/1WtEOwbb1SKR46PazCxIY Lnsw== 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=x3OTAPnH1UPXHwyfYMWB36U+tLMgFlsjHFWGzD7bccE=; b=g7kWa47rZhtnCXig2UxDG1cGc8R8MrK5zRRCLn0/wxz+iR1PRcksY4K3wnWCKs1For 7VnCjGBgNwR66X7rC1HWrHvnar44zqYkRlph03Npqz4dTDTKgQf8CmFhIvFwAz8WB9hD 3/goZ6hdjgRQOLrK+nledUnJTIR4ETigRclaCnkHXuCGdqnkV7QPrLxBzxub1MGnfT0U qF2sci8v7C+PEg15YdL31lcI5dAaWOhEXjT1WufmDY7o0BAznjzp227Lot4w1R2WWXTq iFpM4yKZVeJW+N/5GqIRdriZj7c9vgiuP1zO2dx8XICA6u5OHvmtKU/+O6oEIPe1z/Eo U+rA== X-Gm-Message-State: AOAM533U8C3c0y3QIPaujYq7G2koibJD/9f/N1a2+u4AovQjhDfih81o S37FTvOu6aQGOYzm55lz+Jw= X-Google-Smtp-Source: ABdhPJw3u8KDrEObvWy0ABe23siBkeFbhwcaXvXhvhhtXKNGvPu//F7D3N2M/J04qtIIssUKIx0TCQ== X-Received: by 2002:a1c:e188:: with SMTP id y130mr5813290wmg.83.1589893954946; Tue, 19 May 2020 06:12:34 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id p17sm3946289wmi.3.2020.05.19.06.12.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 06:12:34 -0700 (PDT) From: luca.boccassi@gmail.com To: Rahul Gupta Cc: Somnath Kotur , Ajit Khaparde , dpdk stable Date: Tue, 19 May 2020 14:04:21 +0100 Message-Id: <20200519130549.112823-126-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519130549.112823-1-luca.boccassi@gmail.com> References: <20200519125804.104349-1-luca.boccassi@gmail.com> <20200519130549.112823-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/bnxt: fix memory leak during queue restart' has been queued to stable release 19.11.3 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.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/21/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 61c8f03fd45d0e5611714af7f3264d309e4c165c Mon Sep 17 00:00:00 2001 From: Rahul Gupta Date: Thu, 23 Apr 2020 20:32:23 +0530 Subject: [PATCH] net/bnxt: fix memory leak during queue restart [ upstream commit d256c73c11229c0a7eae32a7e0baaa7a457000e1 ] During port 0 rxq 1 start ie queue start, bnxt_free_hwrm_rx_ring() we are clearing the pointers to mbuf array. Due to this we overwrite the queue with fresh mbuf allocations causing previously allocated mbufs to leak. Add a check before allocating mbuf to replenish only empty mbuf slots in the RxQ. Fixes: 2eb53b134aae ("net/bnxt: add initial Rx code") Signed-off-by: Rahul Gupta Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_hwrm.c | 12 ---------- drivers/net/bnxt/bnxt_rxr.c | 44 ++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index b8d1d6322e..7de5b88f0c 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -2370,13 +2370,6 @@ void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index) if (BNXT_HAS_RING_GRPS(bp)) bp->grp_info[queue_index].rx_fw_ring_id = INVALID_HW_RING_ID; - memset(rxr->rx_desc_ring, 0, - rxr->rx_ring_struct->ring_size * - sizeof(*rxr->rx_desc_ring)); - memset(rxr->rx_buf_ring, 0, - rxr->rx_ring_struct->ring_size * - sizeof(*rxr->rx_buf_ring)); - rxr->rx_prod = 0; } ring = rxr->ag_ring_struct; if (ring->fw_ring_id != INVALID_HW_RING_ID) { @@ -2384,11 +2377,6 @@ void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index) BNXT_CHIP_THOR(bp) ? HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG : HWRM_RING_FREE_INPUT_RING_TYPE_RX); - ring->fw_ring_id = INVALID_HW_RING_ID; - memset(rxr->ag_buf_ring, 0, - rxr->ag_ring_struct->ring_size * - sizeof(*rxr->ag_buf_ring)); - rxr->ag_prod = 0; if (BNXT_HAS_RING_GRPS(bp)) bp->grp_info[queue_index].ag_fw_ring_id = INVALID_HW_RING_ID; diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c index 7338a81029..3ebc398375 100644 --- a/drivers/net/bnxt/bnxt_rxr.c +++ b/drivers/net/bnxt/bnxt_rxr.c @@ -853,14 +853,16 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq) prod = rxr->rx_prod; for (i = 0; i < ring->ring_size; i++) { - if (bnxt_alloc_rx_data(rxq, rxr, prod) != 0) { - PMD_DRV_LOG(WARNING, - "init'ed rx ring %d with %d/%d mbufs only\n", - rxq->queue_id, i, ring->ring_size); - break; + if (unlikely(!rxr->rx_buf_ring[i].mbuf)) { + if (bnxt_alloc_rx_data(rxq, rxr, prod) != 0) { + PMD_DRV_LOG(WARNING, + "init'ed rx ring %d with %d/%d mbufs only\n", + rxq->queue_id, i, ring->ring_size); + break; + } + rxr->rx_prod = prod; + prod = RING_NEXT(rxr->rx_ring_struct, prod); } - rxr->rx_prod = prod; - prod = RING_NEXT(rxr->rx_ring_struct, prod); } ring = rxr->ag_ring_struct; @@ -869,14 +871,16 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq) prod = rxr->ag_prod; for (i = 0; i < ring->ring_size; i++) { - if (bnxt_alloc_ag_data(rxq, rxr, prod) != 0) { - PMD_DRV_LOG(WARNING, - "init'ed AG ring %d with %d/%d mbufs only\n", - rxq->queue_id, i, ring->ring_size); - break; + if (unlikely(!rxr->ag_buf_ring[i].mbuf)) { + if (bnxt_alloc_ag_data(rxq, rxr, prod) != 0) { + PMD_DRV_LOG(WARNING, + "init'ed AG ring %d with %d/%d mbufs only\n", + rxq->queue_id, i, ring->ring_size); + break; + } + rxr->ag_prod = prod; + prod = RING_NEXT(rxr->ag_ring_struct, prod); } - rxr->ag_prod = prod; - prod = RING_NEXT(rxr->ag_ring_struct, prod); } PMD_DRV_LOG(DEBUG, "AGG Done!\n"); @@ -884,11 +888,13 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq) unsigned int max_aggs = BNXT_TPA_MAX_AGGS(rxq->bp); for (i = 0; i < max_aggs; i++) { - rxr->tpa_info[i].mbuf = - __bnxt_alloc_rx_data(rxq->mb_pool); - if (!rxr->tpa_info[i].mbuf) { - rte_atomic64_inc(&rxq->rx_mbuf_alloc_fail); - return -ENOMEM; + if (unlikely(!rxr->tpa_info[i].mbuf)) { + rxr->tpa_info[i].mbuf = + __bnxt_alloc_rx_data(rxq->mb_pool); + if (!rxr->tpa_info[i].mbuf) { + rte_atomic64_inc(&rxq->rx_mbuf_alloc_fail); + return -ENOMEM; + } } } } -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-05-19 14:04:49.615803560 +0100 +++ 0126-net-bnxt-fix-memory-leak-during-queue-restart.patch 2020-05-19 14:04:44.436652361 +0100 @@ -1,8 +1,10 @@ -From d256c73c11229c0a7eae32a7e0baaa7a457000e1 Mon Sep 17 00:00:00 2001 +From 61c8f03fd45d0e5611714af7f3264d309e4c165c Mon Sep 17 00:00:00 2001 From: Rahul Gupta Date: Thu, 23 Apr 2020 20:32:23 +0530 Subject: [PATCH] net/bnxt: fix memory leak during queue restart +[ upstream commit d256c73c11229c0a7eae32a7e0baaa7a457000e1 ] + During port 0 rxq 1 start ie queue start, bnxt_free_hwrm_rx_ring() we are clearing the pointers to mbuf array. Due to this we overwrite the queue with fresh mbuf allocations @@ -11,7 +13,6 @@ in the RxQ. Fixes: 2eb53b134aae ("net/bnxt: add initial Rx code") -Cc: stable@dpdk.org Signed-off-by: Rahul Gupta Reviewed-by: Somnath Kotur @@ -22,10 +23,10 @@ 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c -index ebf73e44c8..b0a783525e 100644 +index b8d1d6322e..7de5b88f0c 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c -@@ -2476,13 +2476,6 @@ void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index) +@@ -2370,13 +2370,6 @@ void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index) if (BNXT_HAS_RING_GRPS(bp)) bp->grp_info[queue_index].rx_fw_ring_id = INVALID_HW_RING_ID; @@ -39,7 +40,7 @@ } ring = rxr->ag_ring_struct; if (ring->fw_ring_id != INVALID_HW_RING_ID) { -@@ -2490,11 +2483,6 @@ void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index) +@@ -2384,11 +2377,6 @@ void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index) BNXT_CHIP_THOR(bp) ? HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG : HWRM_RING_FREE_INPUT_RING_TYPE_RX); @@ -52,10 +53,10 @@ bp->grp_info[queue_index].ag_fw_ring_id = INVALID_HW_RING_ID; diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c -index 40da2f2051..a657150d15 100644 +index 7338a81029..3ebc398375 100644 --- a/drivers/net/bnxt/bnxt_rxr.c +++ b/drivers/net/bnxt/bnxt_rxr.c -@@ -963,14 +963,16 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq) +@@ -853,14 +853,16 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq) prod = rxr->rx_prod; for (i = 0; i < ring->ring_size; i++) { @@ -79,7 +80,7 @@ } ring = rxr->ag_ring_struct; -@@ -979,14 +981,16 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq) +@@ -869,14 +871,16 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq) prod = rxr->ag_prod; for (i = 0; i < ring->ring_size; i++) { @@ -103,7 +104,7 @@ } PMD_DRV_LOG(DEBUG, "AGG Done!\n"); -@@ -994,11 +998,13 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq) +@@ -884,11 +888,13 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq) unsigned int max_aggs = BNXT_TPA_MAX_AGGS(rxq->bp); for (i = 0; i < max_aggs; i++) {