From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 62565A034F for ; Wed, 10 Nov 2021 07:44:16 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 503C1410EF; Wed, 10 Nov 2021 07:44:16 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2089.outbound.protection.outlook.com [40.107.237.89]) by mails.dpdk.org (Postfix) with ESMTP id F15AC4068B for ; Wed, 10 Nov 2021 07:44:14 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EIS5pobsSaiFC6d5eldDehD8peOY7LZ3v7AuI5I2GrByRWzwuqqrW2NXOi2/FF+fhFsPwcWAJfABxikqw3JTgixAYh9WZiIIzL72Qizl3uobAr/20mmnzzyvFIMVhB2Gi0RpprAc+AHJh2TacjttBSdVlgnql3DmC+lmeoqU8KC2m7a444CVida+dmYuTJCap7IIsBf8QW5GdE41/XfqQydWw+irw/LbeseWi+rX3Plw/JDDeB5iaE+7DAx/vTj3XoV5Sl7FK4noYuscHcOzMIYoyF341AtyxzuIsXrdwv2emBdr4VZdXyddgvBDBagfmt+vEioRL5c+lNVSwAbFBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=na617qcf9jhzrWhlSVMDluCTOiU8WAl1tn+OhnzFIjc=; b=hjyzIuLmcn1xgBkV3o8VMVx8+0kPBLqOVKsllNBhcUyAPPG/OoyB8g8hrT2wUH/ZtAZtjr/B1yXxsNhSVOrKbbxS/ztDoHi6AIjNZkHB8aSI8mwAMsltlS42wxeWowweGD3ef09FagO7ZAhvGmrcjbUvjOdn18B/pYbbO6hM1P0PnsXBisJ+e7yNlUigSGgb4b0uxbvxM2U/Ha9V9WFXRD+NdS3GhmGmyS+by27Bg102i/ktr7U0u4XoZd+Z38prA7mwe7R9So0FRNGaQorYW1o3k3VC3fY5+3kPu/HgfUCcOUYRIKWjtuGsgP1rPIllhgay82f37SjvTq1nB2jHkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=na617qcf9jhzrWhlSVMDluCTOiU8WAl1tn+OhnzFIjc=; b=EiJNP5ivm3BkNGwzOFhhqjVm3ijBwpzYB84Qe+jVqifWnqEWDU75GLKuzZc+xUrAgeCrugXvz/1Z9xpxLuz3RfpRW79C7GdFUkxz1Jikj9B5CCXpgv+UycQbdRcrVO0iNGStmtoKXoUju/ivUXPzhnGR2oVnIXNN4ZVXJzJK0wCO5FiR8MxGgi+t60YpaD/Qr9daGYRHc6Dj5UFfNX9oKltTA0kLk+QjMPRnlWYSV3JasyjapBZ8AzXJQEv6Nf6p/lc5ue+EkbTGVg2d26pnx21ghNvsevstmIasInywDOPPJ/38Sk29UfmiJHLNN4iKdvV+4E2WGTJ/Eos5MeLGUw== Received: from DM6PR13CA0041.namprd13.prod.outlook.com (2603:10b6:5:134::18) by MN2PR12MB4605.namprd12.prod.outlook.com (2603:10b6:208:3d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Wed, 10 Nov 2021 06:44:11 +0000 Received: from DM6NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:5:134:cafe::a7) by DM6PR13CA0041.outlook.office365.com (2603:10b6:5:134::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.8 via Frontend Transport; Wed, 10 Nov 2021 06:44:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT021.mail.protection.outlook.com (10.13.173.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4690.15 via Frontend Transport; Wed, 10 Nov 2021 06:44:10 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 10 Nov 2021 06:44:08 +0000 From: Xueming Li To: Yunjian Wang CC: Luca Boccassi , Haiyue Wang , dpdk stable Date: Wed, 10 Nov 2021 14:29:51 +0800 Message-ID: <20211110063216.2744012-108-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211110063216.2744012-1-xuemingl@nvidia.com> References: <20211110063216.2744012-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0c832b6a-3a87-46da-48d7-08d9a415807d X-MS-TrafficTypeDiagnostic: MN2PR12MB4605: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kJOJGKc1eX2SkIoMyOSVRVmfgFyAECN14MpTVT+lMwrcaN4+GqGYxBB1/WnIiI/F4gd9VlGR90G0Z732khp414FQ/v3tiR4B2ytLh0IZqyaCrS7cil08Fz6Bwk2axcojqaUXWN9sKRvnuSgB//qvsaiDPb0VkblM/oPlGZx9lVDVzDIFV4XKqoO4tKqF4GyZrH+YwEhinvRSHN94URLj5flbSgIM2zWcsijm/Zcj96cbH5LdA8k/L0aozoN533kcLNkIkw6/xYt9LJdLcsJwPGwuqMttlY/p0vHfZSW93wFV0tFSC1WpB+ecUxtpj1pDEnSHoALFmDqqqE/rFMpfqdYBsG4B0yWp10mLmY76YaUbKbVUxyMF6+7JimNw44yyWOavaTiKV3592/ZLwUdR50K1UTn4y6aFKbxCGux7C/jQYtagWcEJ5zmgWLpQVQkIVXaG2kIUfS7nanB2Pz9GEn4MoB7UVe0gGJXlYl2gIZYZzzYfab3Xst6zoHeFo4oo77URzY/ZwxgajMnChdDhz5Q4mZTcHL5t2bxDEn5PwA0aSeDELDWmauEpbQUj0P+McOgS4FW+OHkOBMH8m24XPeknqgKmqTdllZUwcZtm4yaTU7UXxdBfgRgHIjeob9UOEv+NB2EkNQ9Huzdw0xG8cGN9UAHJ3EKaQRYtYTJRARi0LQezgNfrfQ/SXUUBy+EPJktvOfA1CM1QN8h7optB0wyCKzWbeTwycINi6IJ7x/AScW1uH/hDsXFZJ/3jBt1dHn7SftJF6h6dkkl2aH9D1DE7y8a86i0DbOcrNS6PBJtHUhE5UeU/SRL8pMdtVm8IeYqjCiVzpGgejojwJtqpMw== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(6916009)(36860700001)(4001150100001)(70206006)(36756003)(1076003)(5660300002)(83380400001)(54906003)(426003)(2906002)(2616005)(356005)(7636003)(966005)(82310400003)(70586007)(6286002)(8936002)(4326008)(86362001)(6666004)(316002)(16526019)(186003)(53546011)(7696005)(8676002)(36906005)(508600001)(47076005)(26005)(336012)(55016002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 06:44:10.5519 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c832b6a-3a87-46da-48d7-08d9a415807d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4605 Subject: [dpdk-stable] patch 'net/e1000: fix memzone leak on queue re-configure' has been queued to stable release 20.11.4 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 20.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/12/21. 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. Queued patches are on a temporary branch at: https://github.com/steevenlee/dpdk This queued commit can be viewed at: https://github.com/steevenlee/dpdk/commit/b51d3a497044316f72fc87a1707ab2033a998ea4 Thanks. Xueming Li --- >From b51d3a497044316f72fc87a1707ab2033a998ea4 Mon Sep 17 00:00:00 2001 From: Yunjian Wang Date: Wed, 22 Sep 2021 21:28:20 +0800 Subject: [PATCH] net/e1000: fix memzone leak on queue re-configure Cc: Xueming Li [ upstream commit 09cbfa2da4268b4f789ffd34587365b51fa656b4 ] Normally when closing the device the queue memzone should be freed. But the memzone will be not freed, when device setup ops like: rte_eth_bond_slave_remove -->__eth_bond_slave_remove_lock_free ---->slave_remove ------>rte_eth_dev_internal_reset -------->rte_eth_dev_rx_queue_config ---------->eth_dev_rx_queue_config ------------>em_rx_queue_release rte_eth_dev_close -->eth_em_close ---->em_dev_free_queues ------>em_rx_queue_release (not been called due to nb_rx_queues and nb_tx_queues are 0) And when queue number is changed to small size, the BIG memzone queue index will be lost. This will lead to a memory leak. So we should release the memzone when releasing queues. Fixes: 460d1679586e ("drivers/net: delete HW rings while freeing queues") Signed-off-by: Yunjian Wang Acked-by: Haiyue Wang --- drivers/net/e1000/em_rxtx.c | 8 ++++++-- drivers/net/e1000/igb_rxtx.c | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c index 19e3bffd46..a7439c3aa7 100644 --- a/drivers/net/e1000/em_rxtx.c +++ b/drivers/net/e1000/em_rxtx.c @@ -104,6 +104,7 @@ struct em_rx_queue { uint8_t hthresh; /**< Host threshold register. */ uint8_t wthresh; /**< Write-back threshold register. */ uint8_t crc_len; /**< 0 if CRC stripped, 4 otherwise. */ + const struct rte_memzone *mz; }; /** @@ -173,6 +174,7 @@ struct em_tx_queue { struct em_ctx_info ctx_cache; /**< Hardware context history.*/ uint64_t offloads; /**< offloads of DEV_TX_OFFLOAD_* */ + const struct rte_memzone *mz; }; #if 1 @@ -1116,6 +1118,7 @@ em_tx_queue_release(struct em_tx_queue *txq) if (txq != NULL) { em_tx_queue_release_mbufs(txq); rte_free(txq->sw_ring); + rte_memzone_free(txq->mz); rte_free(txq); } } @@ -1286,6 +1289,7 @@ eth_em_tx_queue_setup(struct rte_eth_dev *dev, RTE_CACHE_LINE_SIZE)) == NULL) return -ENOMEM; + txq->mz = tz; /* Allocate software ring */ if ((txq->sw_ring = rte_zmalloc("txq->sw_ring", sizeof(txq->sw_ring[0]) * nb_desc, @@ -1338,6 +1342,7 @@ em_rx_queue_release(struct em_rx_queue *rxq) if (rxq != NULL) { em_rx_queue_release_mbufs(rxq); rte_free(rxq->sw_ring); + rte_memzone_free(rxq->mz); rte_free(rxq); } } @@ -1452,6 +1457,7 @@ eth_em_rx_queue_setup(struct rte_eth_dev *dev, RTE_CACHE_LINE_SIZE)) == NULL) return -ENOMEM; + rxq->mz = rz; /* Allocate software ring. */ if ((rxq->sw_ring = rte_zmalloc("rxq->sw_ring", sizeof (rxq->sw_ring[0]) * nb_desc, @@ -1611,14 +1617,12 @@ em_dev_free_queues(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_rx_queues; i++) { eth_em_rx_queue_release(dev->data->rx_queues[i]); dev->data->rx_queues[i] = NULL; - rte_eth_dma_zone_free(dev, "rx_ring", i); } dev->data->nb_rx_queues = 0; for (i = 0; i < dev->data->nb_tx_queues; i++) { eth_em_tx_queue_release(dev->data->tx_queues[i]); dev->data->tx_queues[i] = NULL; - rte_eth_dma_zone_free(dev, "tx_ring", i); } dev->data->nb_tx_queues = 0; } diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 3bf13d1420..620281232e 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -112,6 +112,7 @@ struct igb_rx_queue { uint8_t drop_en; /**< If not 0, set SRRCTL.Drop_En. */ uint32_t flags; /**< RX flags. */ uint64_t offloads; /**< offloads of DEV_RX_OFFLOAD_* */ + const struct rte_memzone *mz; }; /** @@ -186,6 +187,7 @@ struct igb_tx_queue { struct igb_advctx_info ctx_cache[IGB_CTX_NUM]; /**< Hardware context history.*/ uint64_t offloads; /**< offloads of DEV_TX_OFFLOAD_* */ + const struct rte_memzone *mz; }; #if 1 @@ -1276,6 +1278,7 @@ igb_tx_queue_release(struct igb_tx_queue *txq) if (txq != NULL) { igb_tx_queue_release_mbufs(txq); rte_free(txq->sw_ring); + rte_memzone_free(txq->mz); rte_free(txq); } } @@ -1545,6 +1548,7 @@ eth_igb_tx_queue_setup(struct rte_eth_dev *dev, return -ENOMEM; } + txq->mz = tz; txq->nb_tx_desc = nb_desc; txq->pthresh = tx_conf->tx_thresh.pthresh; txq->hthresh = tx_conf->tx_thresh.hthresh; @@ -1601,6 +1605,7 @@ igb_rx_queue_release(struct igb_rx_queue *rxq) if (rxq != NULL) { igb_rx_queue_release_mbufs(rxq); rte_free(rxq->sw_ring); + rte_memzone_free(rxq->mz); rte_free(rxq); } } @@ -1746,6 +1751,8 @@ eth_igb_rx_queue_setup(struct rte_eth_dev *dev, igb_rx_queue_release(rxq); return -ENOMEM; } + + rxq->mz = rz; rxq->rdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDT(rxq->reg_idx)); rxq->rdh_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDH(rxq->reg_idx)); rxq->rx_ring_phys_addr = rz->iova; @@ -1885,14 +1892,12 @@ igb_dev_free_queues(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_rx_queues; i++) { eth_igb_rx_queue_release(dev->data->rx_queues[i]); dev->data->rx_queues[i] = NULL; - rte_eth_dma_zone_free(dev, "rx_ring", i); } dev->data->nb_rx_queues = 0; for (i = 0; i < dev->data->nb_tx_queues; i++) { eth_igb_tx_queue_release(dev->data->tx_queues[i]); dev->data->tx_queues[i] = NULL; - rte_eth_dma_zone_free(dev, "tx_ring", i); } dev->data->nb_tx_queues = 0; } -- 2.33.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-11-10 14:17:06.740388092 +0800 +++ 0107-net-e1000-fix-memzone-leak-on-queue-re-configure.patch 2021-11-10 14:17:01.867412785 +0800 @@ -1 +1 @@ -From 09cbfa2da4268b4f789ffd34587365b51fa656b4 Mon Sep 17 00:00:00 2001 +From b51d3a497044316f72fc87a1707ab2033a998ea4 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 09cbfa2da4268b4f789ffd34587365b51fa656b4 ] @@ -28 +30,0 @@ -Cc: stable@dpdk.org @@ -38 +40 @@ -index 00a8af6d39..8542a15320 100644 +index 19e3bffd46..a7439c3aa7 100644 @@ -91 +93 @@ - eth_em_rx_queue_release(dev, i); + eth_em_rx_queue_release(dev->data->rx_queues[i]); @@ -98 +100 @@ - eth_em_tx_queue_release(dev, i); + eth_em_tx_queue_release(dev->data->tx_queues[i]); @@ -105 +107 @@ -index d97ca1a011..8d64d7397a 100644 +index 3bf13d1420..620281232e 100644 @@ -159 +161 @@ - eth_igb_rx_queue_release(dev, i); + eth_igb_rx_queue_release(dev->data->rx_queues[i]); @@ -166 +168 @@ - eth_igb_tx_queue_release(dev, i); + eth_igb_tx_queue_release(dev->data->tx_queues[i]);