* [PATCH] net/mlx5: fix the counters resource leak
@ 2026-01-05 7:05 Bing Zhao
2026-01-06 13:14 ` Raslan Darawsheh
0 siblings, 1 reply; 2+ messages in thread
From: Bing Zhao @ 2026-01-05 7:05 UTC (permalink / raw)
To: viacheslavo, dev, rasland
Cc: orika, dsosnowski, suanmingm, matan, thomas, shperetz, stable
The counters that are used to record the dropped packets (including
hairpin) are created firstly. Then the counter objects are provided
to the command to create the Rx queues, and they are used for the
global drop and hairpin queues drop statistics. One counter can be
associated with more than one queue in hairpin case.
So the reference count of a counter will be increased once attached
to a queue. When closing the device, the queues and counters should
be destroyed in the reverse order. The queues should be destroyed
firstly in order to decrease the reference count of attached counter
properlly. Then the counter can be recycled successfully. Or else the
resource will be leaked before the application quits when doing port
attach / detach rerepeatedly.
Fixes: f0c0731b6d40 ("net/mlx5: add counters for hairpin drop")
Cc: shperetz@nvidia.com
Cc: stable@dpdk.org
Signed-off-by: Bing Zhao <bingz@nvidia.com>
Acked-by: Suanming Mou <suanmingm@nvidia.com>
---
drivers/net/mlx5/mlx5.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index decf540c51..bde4d01e48 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -2404,7 +2404,6 @@ mlx5_dev_close(struct rte_eth_dev *dev)
priv->ptype_rss_groups = NULL;
}
#endif
- mlx5_q_counters_destroy(dev);
if (priv->rxq_privs != NULL) {
/* XXX race condition if mlx5_rx_burst() is still running. */
rte_delay_us_sleep(1000);
@@ -2425,6 +2424,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
mlx5_proc_priv_uninit(dev);
if (priv->drop_queue.hrxq)
mlx5_drop_action_destroy(dev);
+ mlx5_q_counters_destroy(dev);
mlx5_mprq_free_mp(dev);
mlx5_os_free_shared_dr(priv);
#ifdef HAVE_MLX5_HWS_SUPPORT
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] net/mlx5: fix the counters resource leak
2026-01-05 7:05 [PATCH] net/mlx5: fix the counters resource leak Bing Zhao
@ 2026-01-06 13:14 ` Raslan Darawsheh
0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2026-01-06 13:14 UTC (permalink / raw)
To: Bing Zhao, viacheslavo, dev
Cc: orika, dsosnowski, suanmingm, matan, thomas, shperetz, stable
Hi,
On 05/01/2026 9:05 AM, Bing Zhao wrote:
> The counters that are used to record the dropped packets (including
> hairpin) are created firstly. Then the counter objects are provided
> to the command to create the Rx queues, and they are used for the
> global drop and hairpin queues drop statistics. One counter can be
> associated with more than one queue in hairpin case.
>
> So the reference count of a counter will be increased once attached
> to a queue. When closing the device, the queues and counters should
> be destroyed in the reverse order. The queues should be destroyed
> firstly in order to decrease the reference count of attached counter
> properlly. Then the counter can be recycled successfully. Or else the
> resource will be leaked before the application quits when doing port
> attach / detach rerepeatedly.
>
> Fixes: f0c0731b6d40 ("net/mlx5: add counters for hairpin drop")
> Cc: shperetz@nvidia.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Bing Zhao <bingz@nvidia.com>
> Acked-by: Suanming Mou <suanmingm@nvidia.com>
Patch applied to next-net-mlx,
Kindest regards
Raslan Darawsheh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-06 13:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-05 7:05 [PATCH] net/mlx5: fix the counters resource leak Bing Zhao
2026-01-06 13:14 ` Raslan Darawsheh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).