net/mlx5: fix HWS meter ASO SQ leak on multi-port init
PATCH 1/1 net/mlx5: fix HWS meter ASO SQ leak on multi-port init
When multiple ports on the same device initialize HWS meters via rte_flow_configure(), mlx5_aso_mtr_queue_init() recreates the shared pools_mng ASO send queue without destroying the previous one. Each additional port with meters configured leaks one SQ/CQ pair until the shared device context is torn down.
This is observed as steady growth of hugepage allocations (dump socket_mem count alloc) when repeatedly attaching and detaching a device with multiple SF representors configured with meters in HWS mode.
Create pools_mng.sq only when its DevX object is missing. A send-queue id of zero is valid, so sqn cannot be used as the existence check.
Do not destroy that queue from mlx5_flow_meter_uninit(). It is shared by every port on the device, and releasing it when one port closes breaks meters still configured on the others. The queue is released with the shared context in mlx5_aso_flow_mtrs_mng_close().
--- drivers/net/mlx5/mlx5_flow_aso.c | 7 ++++++- drivers/net/mlx5/mlx5_flow_meter.c | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_flow_aso.c +6 -1
@@ -316,7 +316,12 @@ mlx5_aso_mtr_queue_init(struct mlx5_dev_ctx_shared *sh, } hws_pool->nb_sq = nb_queues; } -if (pool_mng) { +/* +* pools_mng->sq is shared by every port on the device. +* A send-queue id of zero is valid, so the DevX object pointer +* is the indicator that the queue was already created. +*/ +if (pool_mng !=NULL && pool_mng->sq.sq_obj.sq ==NULL ) {if (mlx5_aso_sq_create (cdev, &pool_mng->sq, sh->tx_uar.obj,MLX5_ASO_QUEUE_LOG_DESC ))
drivers/net/mlx5/mlx5_flow_meter.c +5 -1
@@ -60,7 +60,11 @@ mlx5_flow_meter_uninit(struct rte_eth_dev *dev)mlx5_free (priv->mtr_bulk.aso); priv->mtr_bulk.aso =NULL ; priv->mtr_bulk.size =0 ; -mlx5_aso_queue_uninit (priv->sh,ASO_OPC_MOD_POLICER ); +/* +* pools_mng->sq is shared by every port on this device. +* Destroying it here would break meters still in use on +* another port. It is released with the shared context. +*/ }if (priv->mtr_bulk.action) {mlx5dr_action_destroy (priv->mtr_bulk.action);
Signature · 1 line
2.21.0
Quoted 30 lines
-----Original Message-----
From: Maayan Kashani <[email protected]>
Sent: Sunday, October 18, 2026 10:55 AM
To: [email protected]
Cc: Maayan Kashani <[email protected]>; Raslan Darawsheh <[email protected]>; [email protected]; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Bing Zhao <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>; Alexander Kozyrev <[email protected]>
Subject: [PATCH] net/mlx5: fix HWS meter ASO SQ leak on multi-port initWhen multiple ports on the same device initialize HWS meters via
rte_flow_configure(),mlx5_aso_mtr_queue_init()recreates the sharedpools_mngASO send queue without destroying the previous one. Each additional port with meters configured leaks one SQ/CQ pair until the shared device context is torn down.This is observed as steady growth of hugepage allocations (dump
socket_memcount alloc) when repeatedly attaching and detaching a device with multiple SF representors configured with meters in HWS mode.Create pools_mng.sq only when its DevX object is missing. A send-queue id of zero is valid, so sqn cannot be used as the existence check.
Do not destroy that queue from
mlx5_flow_meter_uninit(). It is shared by every port on the device, and releasing it when one port closes breaks meters still configured on the others. The queue is released with the shared context inmlx5_aso_flow_mtrs_mng_close().
Quoted 4 lines
Fixes 24865366e495 ("net/mlx5: support flow meter action for HWS")Signed-off-by Maayan Kashani <[email protected]>
Best regards,
Dariusz Sosnowski
Patch applied to next-net-mlx.