๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by netdev-bot+sashiko Fri, 27 Nov 2026 22:32
Re: [PATCH net 01/10] net/mlx5e: Initialize IPsec XArrays with XA_FLAGS_LOCK_BH
#23753
Author: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 22:32
88 lines
11507 bytes
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 overstates what the change to
  `ipsec_obj_id_map` fixes.

--

net/mlx5e: Initialize IPsec XArrays with XA_FLAGS_LOCK_BH

This commit adds XA_FLAGS_LOCK_BH when ipsec->sadb and
ipsec->ipsec_obj_id_map are initialized, because every mutation of
these arrays uses the _bh xarray accessors. The commit message says the
mismatch leaves bottom halves disabled while __xas_nomem() allocates a
node. It carries Fixes tags for both 403b383a3ce3 and 91bafc638ed4.

> Node insertion drops+reacquires the lock with the lock variants
> corresponding to the configured type. Using the wrong type therefore
> leaves bottom halves disabled during the allocation.

[ ... ]

> Fixes: 403b383a3ce3 ("net/mlx5e: Store all XFRM SAs in Xarray")
> Fixes: 91bafc638ed4 ("net/mlx5e: Handle IPsec offload for RX datapath in switchdev mode")

[ ... ]

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
> index 5c69e89b13a72..502d89a18f9ec 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
> @@ -2804,7 +2804,8 @@ int mlx5e_accel_ipsec_fs_init(struct mlx5e_ipsec *ipsec,
>  		mutex_init(&ipsec->tx_esw->ft.mutex);
>  		mutex_init(&ipsec->rx_esw->ft.mutex);
>  		ipsec->tx_esw->ns = ns_esw;
> -		xa_init_flags(&ipsec->ipsec_obj_id_map, XA_FLAGS_ALLOC1);
> +		xa_init_flags(&ipsec->ipsec_obj_id_map,
> +			      XA_FLAGS_ALLOC1 | XA_FLAGS_LOCK_BH);

[Severity: Low]
Is the Fixes: 91bafc638ed4 tag accurate for this hunk?

The description fits sadb. In mlx5e_xfrm_add_state(), xa_insert_bh() on
sadb is called with GFP_KERNEL, so __xas_nomem() drops and retakes the
lock using the configured lock type.

For ipsec_obj_id_map, the only call that allocates passes gfp == 0:

drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c:mlx5_esw_ipsec_rx_setup_modify_header() {
    ...
	err = xa_alloc_bh(&ipsec->ipsec_obj_id_map, &mapped_id,
			  xa_mk_value(sa_entry->ipsec_obj_id),
			  XA_LIMIT(1, ESW_IPSEC_RX_MAPPED_ID_MASK), 0);
    ...
}

With gfp == 0, gfpflags_allow_blocking() returns false. __xas_nomem()
then allocates with the lock still held and never calls
xas_unlock_type() or xas_lock_type():

lib/xarray.c:__xas_nomem() {
    ...
	if (gfpflags_allow_blocking(gfp)) {
		xas_unlock_type(xas, lock_type);
		xas->xa_alloc = kmem_cache_alloc_lru(radix_tree_node_cachep, xas->xa_lru, gfp);
		xas_lock_type(xas, lock_type);
	} else {
		xas->xa_alloc = kmem_cache_alloc_lru(radix_tree_node_cachep, xas->xa_lru, gfp);
	}
    ...
}

The other users of this array are xa_erase_bh() and xa_load(), and
neither of them allocates. The gfp was already 0 when 91bafc638ed4
added this code.

That would make this hunk a harmless consistency change rather than a
fix. Could the commit message say that the ipsec_obj_id_map change is
only for consistency? Alternatively, could the second Fixes tag be
dropped, so backporters don't assume 91bafc638ed4 had a live
sleep-in-atomic bug?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126215614.792598-1-tariqt%40nvidia.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads