From: netdev-bot+sashiko@kernel.org
To: tariqt@nvidia.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com,
cjubran@nvidia.com, cratiu@nvidia.com, gal@nvidia.com,
leon@kernel.org, linux-kernel@vger.kernel.org,
linux-rdma@vger.kernel.org, mbloch@nvidia.com, moshe@nvidia.com,
ohartoov@nvidia.com, phaddad@nvidia.com, saeedm@nvidia.com,
shayd@nvidia.com, udar@nvidia.com
Subject: Re: [PATCH net-next V2 06/10] net/mlx5: LAG, rename PF naming to fn
Date: Wed, 18 Nov 2026 10:31:56 +0000 [thread overview]
Message-ID: <179499791613.3136.14627741130373185414@kernel.org> (raw)
In-Reply-To: <20261116103010.1129666-7-tariqt@nvidia.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message misstates what this patch renames.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but it is still
present at the end of the series.
--
net/mlx5: LAG, rename PF naming to fn
This commit renames the LAG member bookkeeping from PF naming to fn. The
ldev->pfs xarray becomes ldev->fns, the mlx5_lag_pf*() helpers become
mlx5_lag_fn*(), and the pf locals become fn. The rename prepares for virt
LAG, where LAG members will not always be physical functions.
> Rename the xarray to ldev->fns, the helpers to mlx5_lag_fn*(), and the
> locals to fn, so the naming matches struct lag_fn.
[Severity: Low]
Is this description accurate? struct lag_fn doesn't exist before this
patch. The patch creates it by renaming the struct in lag.h:
-struct lag_func {
+struct lag_fn {
It also renames a field of struct mlx5_lag:
- u8 max_funcs;
+ u8 max_fns;
The commit message mentions neither rename.
The patch also makes a few small changes that are not renames:
- a new esw local in mlx5_lag_drop_rule_cleanup()
- dev0/dev1 moved above the switch in mlx5_lag_set_port_affinity()
- new mdev/affinity locals in mlx5_lag_create_port_sel_table() and
__mlx5_lag_modify_definers_destinations()
Could the commit message mention these as well?
A few spots look like they were missed by the rename. The pf_idx and
pf_mdev locals remain in mlx5_lag_get_devices_oper_speed(),
mlx5_lag_get_devices_max_speed(), mlx5_lag_set_vports_agg_speed() and
mlx5_lag_reset_vports_speed():
mlx5_ldev_for_each(pf_idx, 0, ldev) {
...
pf_mdev = fn->dev;
mlx5_get_next_lag_func() and mlx5_get_pre_lag_func() walk the renamed fns
xarray but keep their old names.
In mlx5_lag_mpesw_port_change_event(), the local now has the same name as
the struct tag. The container_of() continuation lines are still aligned for
the old, longer name:
struct lag_fn *lag_fn = container_of(mlx5_nb,
struct lag_fn,
port_change_nb);
Was that intended?
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
> index cbef6ab1e38a8..74e7e7161c95d 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
[ ... ]
> @@ -2390,24 +2392,24 @@ int mlx5_ldev_add_mdev(struct mlx5_lag *ldev,
> void mlx5_ldev_remove_mdev(struct mlx5_lag *ldev,
> struct mlx5_core_dev *dev)
> {
[ ... ]
> - pf->dev = NULL;
> + fn->dev = NULL;
> dev->priv.lag = NULL;
> - xa_erase(&ldev->pfs, pf->idx);
> - kfree(pf);
> + xa_erase(&ldev->fns, fn->idx);
> + kfree(fn);
> }
[Severity: High]
This is a pre-existing issue and was not introduced by this patch. Since
this code is being touched: is it safe to free the lag_fn here while
readers holding only lag_lock may still be using it?
mlx5_ldev_remove_mdev() runs with only ldev->lock held. It is called from:
- mlx5_unload()->mlx5_lag_remove_mdev()
- sd_lag_cleanup()
- the error path of sd_lag_init()
It erases the entry and frees it right away with kfree(). There is no RCU
grace period, and lag_lock is not taken.
Several exported helpers walk the same ldev->fns xarray while holding only
lag_lock, without ldev->lock. For example:
mlx5_lag_get_next_peer_mdev() {
spin_lock_irqsave(&lag_lock, flags);
...
mlx5_lag_for_each(idx, *i, ldev, mlx5_lag_get_filter(ldev, dev)) {
fn = mlx5_lag_fn(ldev, idx);
if (fn->dev != dev)
break;
}
...
fn = mlx5_lag_fn(ldev, idx);
peer_dev = fn->dev;
...
}
mlx5_lag_is_master(), mlx5_lag_is_shared_fdb() and mlx5_lag_is_sd() read
fn->dev, fn->group_id and fn->sd_fdb_active through mlx5_lag_get_filter()
and mlx5_lag_fn_by_dev(). mlx5_lag_get_slave_port() and
mlx5_lag_active_backup_get_netdev() also dereference entries while holding
only lag_lock.
Can this interleaving happen between two devices in the same ldev?
CPU0 (peer device A) CPU1 (device B unload)
mlx5_esw_is_owner()
mlx5_lag_is_master()
spin_lock_irqsave(&lag_lock)
mlx5_lag_get_filter()
mlx5_lag_fn_by_dev()
xa_for_each() loads fn
mlx5_lag_remove_mdev()
mutex_lock(&ldev->lock)
mlx5_ldev_remove_mdev()
xa_erase(&ldev->fns, fn->idx)
kfree(fn)
fn->dev == dev <- reads freed memory
If mlx5_lag_get_next_peer_mdev() hits the same window, it returns the stale
fn->dev to its caller as a peer mlx5_core_dev pointer.
The baseline already has the same xa_erase() and kfree() in
mlx5_ldev_remove_mdev(), and nothing later in the series changes this.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116103010.1129666-1-tariqt%40nvidia.com
next prev parent reply other threads:[~2026-11-18 10:31 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 10:30 [PATCH net-next V2 00/10] net/mlx5: LAG, preparations for LAG over VFs/SFs Tariq Toukan
2026-11-16 10:30 ` [PATCH net-next V2 01/10] net/mlx5: Distinguish VFs/SFs in the SW system image GUID for LAG grouping Tariq Toukan
2026-11-17 10:36 ` sashiko-bot
2026-11-18 10:31 ` netdev-bot+sashiko
2026-11-16 10:30 ` [PATCH net-next V2 02/10] net/mlx5: LAG, select the MPESW master from the live member snapshot Tariq Toukan
2026-11-17 10:36 ` sashiko-bot
2026-11-16 10:30 ` [PATCH net-next V2 03/10] net/mlx5: LAG, skip phys LAG prerequisites for a virt LAG Tariq Toukan
2026-11-17 10:36 ` sashiko-bot
2026-11-16 10:30 ` [PATCH net-next V2 04/10] net/mlx5: LAG, treat virt LAG as a software managed LAG Tariq Toukan
2026-11-17 10:36 ` sashiko-bot
2026-11-16 10:30 ` [PATCH net-next V2 05/10] net/mlx5: LAG, decouple iteration end-of-walk from MLX5_MAX_PORTS Tariq Toukan
2026-11-17 10:36 ` sashiko-bot
2026-11-18 10:31 ` netdev-bot+sashiko
2026-11-16 10:30 ` [PATCH net-next V2 06/10] net/mlx5: LAG, rename PF naming to fn Tariq Toukan
2026-11-17 10:36 ` sashiko-bot
2026-11-18 10:31 ` netdev-bot+sashiko [this message]
2026-11-16 10:30 ` [PATCH net-next V2 07/10] net/mlx5: LAG, resolve affinity indices only in queue-affinity mode Tariq Toukan
2026-11-17 10:36 ` sashiko-bot
2026-11-16 10:30 ` [PATCH net-next V2 08/10] net/mlx5: LAG: replace fixed MLX5_MAX_PORTS arrays with dynamic allocation Tariq Toukan
2026-11-17 10:36 ` sashiko-bot
2026-11-18 10:31 ` netdev-bot+sashiko
2026-11-16 10:30 ` [PATCH net-next V2 09/10] net/mlx5: LAG, drop MLX5_MAX_PORTS scratch array from device rescan Tariq Toukan
2026-11-17 10:36 ` sashiko-bot
2026-11-18 10:31 ` netdev-bot+sashiko
2026-11-16 10:30 ` [PATCH net-next V2 10/10] net/mlx5: LAG, do not add a device to an already-active virt LAG Tariq Toukan
2026-11-17 10:36 ` sashiko-bot
2026-11-18 10:32 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179499791613.3136.14627741130373185414@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=cjubran@nvidia.com \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gal@nvidia.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=ohartoov@nvidia.com \
--cc=pabeni@redhat.com \
--cc=phaddad@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=shayd@nvidia.com \
--cc=tariqt@nvidia.com \
--cc=udar@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox