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 EE40345C9B for ; Tue, 12 Nov 2024 23:08:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E8E394069F; Tue, 12 Nov 2024 23:08:29 +0100 (CET) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mails.dpdk.org (Postfix) with ESMTP id 74FB14064C for ; Tue, 12 Nov 2024 23:08:28 +0100 (CET) Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-37d533b5412so4265703f8f.2 for ; Tue, 12 Nov 2024 14:08:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731449308; x=1732054108; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2r++MsUyP45Gpm7yGfg88yI2uSygXUFz43ThOvE6mpg=; b=E1KkvjxfWx8NkveRhQQw2bs0tbKulZlZ64LPTEg0nth6nLZAvekT4HwfOnkSJsNTHz HMwx8LbobWmsvCEUf0tQsiSp1oHlGEYU7XlRj0oqEYPUrp7hFu6rtsHfVSLpyhz1J7go 2GGSZQmTyqKS37yu0XqIOnA1N7TjfGLE6SzLGB+BxRKPjvoJqpoRQNWfF7mC4xHQmlGK fopNYacW9qbpDXX6KfefmwA91eZl76SFr5qTGX4HLJofBljN1KOHnKpde3fF9XZs9QI6 KXi99c6oe6igeVu7JPz8zdhkk9VW0b7DS7w6Xm8D4gkWBN5DX8DWG8QfFs6iP5nndqZM lXGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731449308; x=1732054108; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2r++MsUyP45Gpm7yGfg88yI2uSygXUFz43ThOvE6mpg=; b=fmmm/ANC/fK6k/oekFMh3X5ufFRbh0s1dXFfzHU9R2GHrTGU5QZhDsH2dgjrihQLLC fI2SETAO2WuwR2OB84t5Z9JgONyTujRT6z0sHBlLZl3cUynHTIUsXSqQV9In7EPEe0cb +p+c/2ec2hjJeJ8ZMl5jjLIqF4VXqQgiQ3miA+GLq704hjWuQ0NtlL0rxwBUJJ0JdDQR 3d7ZZQWBDjEDgVnCYDs+60F5za98hJBMxzywqTnkz3/fhsxwhiiA88eoXGLDrXnX8fgP BrjHYpMLMyxTDGGIKOSqZMIJPPi8+4R7YkfoJ58iUd5AhInguFFSXr7ijqQrGZwprYeE DJUg== X-Forwarded-Encrypted: i=1; AJvYcCV6bMBK/y7Yt9V7CHO0Le0KuUZSH8rX8e20AdRec2L+3ylOYISZgRGLYipiND9i4LHsQ3E7gvs=@dpdk.org X-Gm-Message-State: AOJu0YykYZJHyEKkHZ4DGF7BUQCBBl24lkKi+HE+KIPKWwbXEpWp8eUb 8YKmYL8W60Ue/F2bN9t63GA6vuPee576bBn2IJZLrG+GEhr6GZTe X-Google-Smtp-Source: AGHT+IHbq5jpuDJTM4Fj/m1CIe2hh1L6fBv/rRwu6ubnUThHlpyc0dcIYfGFItGmi2eVJger1z8upg== X-Received: by 2002:a05:6000:1866:b0:37c:c5be:1121 with SMTP id ffacd0b85a97d-381f18651cdmr15892237f8f.9.1731449307892; Tue, 12 Nov 2024 14:08:27 -0800 (PST) Received: from localhost ([2a01:4b00:d036:ae00:e89d:e9a1:da72:2f9d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432d55108f0sm928275e9.36.2024.11.12.14.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 14:08:27 -0800 (PST) From: luca.boccassi@gmail.com To: Shun Hao Cc: Bing Zhao , dpdk stable Subject: patch 'net/mlx5: fix memory leak in metering' has been queued to stable release 22.11.7 Date: Tue, 12 Nov 2024 22:07:20 +0000 Message-ID: <20241112220754.666489-10-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241112220754.666489-1-luca.boccassi@gmail.com> References: <20241023211704.1216956-79-luca.boccassi@gmail.com> <20241112220754.666489-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Hi, FYI, your patch has been queued to stable release 22.11.7 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/14/24. 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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/80a5d7368ba6b3ad236a507b7f975693fe722ecd Thanks. Luca Boccassi --- >From 80a5d7368ba6b3ad236a507b7f975693fe722ecd Mon Sep 17 00:00:00 2001 From: Shun Hao Date: Wed, 23 Oct 2024 09:22:15 +0300 Subject: [PATCH] net/mlx5: fix memory leak in metering [ upstream commit 4dd46d38820e0bf5e74f99b84f4b098d1b7220dd ] Avoid allocating memory for meter profile table when meter is not enabled. This memory was not being freed in the close process when meter was disabled, potentially causing a leak. Fixes: a295c69a8b24 ("net/mlx5: optimize meter profile lookup") Signed-off-by: Shun Hao Acked-by: Bing Zhao --- drivers/net/mlx5/linux/mlx5_os.c | 8 +++++--- drivers/net/mlx5/mlx5_flow_meter.c | 4 ++-- drivers/net/mlx5/windows/mlx5_os.c | 8 +++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index b88ae631d9..183b5e6a84 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1533,9 +1533,11 @@ err_secondary: priv->ctrl_flows = 0; rte_spinlock_init(&priv->flow_list_lock); TAILQ_INIT(&priv->flow_meters); - priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR); - if (!priv->mtr_profile_tbl) - goto error; + if (priv->mtr_en) { + priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR); + if (!priv->mtr_profile_tbl) + goto error; + } /* Bring Ethernet device up. */ DRV_LOG(DEBUG, "port %u forcing Ethernet interface up", eth_dev->data->port_id); diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index bcaf518227..1078d6497d 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -100,8 +100,8 @@ mlx5_flow_meter_profile_find(struct mlx5_priv *priv, uint32_t meter_profile_id) if (priv->mtr_profile_arr) return &priv->mtr_profile_arr[meter_profile_id]; - if (mlx5_l3t_get_entry(priv->mtr_profile_tbl, - meter_profile_id, &data) || !data.ptr) + if (!priv->mtr_profile_tbl || + mlx5_l3t_get_entry(priv->mtr_profile_tbl, meter_profile_id, &data) || !data.ptr) return NULL; fmp = data.ptr; /* Remove reference taken by the mlx5_l3t_get_entry. */ diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index f401264b61..d35b949b34 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -474,9 +474,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, claim_zero(mlx5_mac_addr_add(eth_dev, &mac, 0, 0)); priv->ctrl_flows = 0; TAILQ_INIT(&priv->flow_meters); - priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR); - if (!priv->mtr_profile_tbl) - goto error; + if (priv->mtr_en) { + priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR); + if (!priv->mtr_profile_tbl) + goto error; + } /* Bring Ethernet device up. */ DRV_LOG(DEBUG, "port %u forcing Ethernet interface up.", eth_dev->data->port_id); -- 2.45.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-11-12 22:06:59.016828692 +0000 +++ 0010-net-mlx5-fix-memory-leak-in-metering.patch 2024-11-12 22:06:58.643306826 +0000 @@ -1 +1 @@ -From 4dd46d38820e0bf5e74f99b84f4b098d1b7220dd Mon Sep 17 00:00:00 2001 +From 80a5d7368ba6b3ad236a507b7f975693fe722ecd Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 4dd46d38820e0bf5e74f99b84f4b098d1b7220dd ] + @@ -11 +12,0 @@ -Cc: stable@dpdk.org @@ -22 +23 @@ -index 7d0d4bf23b..69a80b9ddc 100644 +index b88ae631d9..183b5e6a84 100644 @@ -25 +26 @@ -@@ -1612,9 +1612,11 @@ err_secondary: +@@ -1533,9 +1533,11 @@ err_secondary: @@ -41 +42 @@ -index 19d8607070..98a61cbdd4 100644 +index bcaf518227..1078d6497d 100644 @@ -44 +45 @@ -@@ -378,8 +378,8 @@ mlx5_flow_meter_profile_find(struct mlx5_priv *priv, uint32_t meter_profile_id) +@@ -100,8 +100,8 @@ mlx5_flow_meter_profile_find(struct mlx5_priv *priv, uint32_t meter_profile_id) @@ -56 +57 @@ -index 80f1679388..268598f209 100644 +index f401264b61..d35b949b34 100644 @@ -59 +60 @@ -@@ -521,9 +521,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, +@@ -474,9 +474,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,