mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tariq Toukan <tariqt@nvidia.com>
To: Ziyu Zhang <ziyuzhang201@gmail.com>,
	saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com,
	leon@kernel.org
Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, roid@nvidia.com, baijiaju1990@gmail.com
Subject: Re: [PATCH net v3] net/mlx5e: Wait for flow setup outside encap_tbl_lock
Date: Tue, 1 Dec 2026 19:14:28 +0200	[thread overview]
Message-ID: <740d9273-5005-4562-9a84-7d56aeac7fe9@nvidia.com> (raw)
In-Reply-To: <20261130140215.66953-1-ziyuzhang201@gmail.com>



On 30/11/2026 16:02, Ziyu Zhang wrote:
> A post action can attach an FDB flow to an encap entry before flow
> setup finishes. A neighbour or FIB update can then take encap_tbl_lock
> and wait for init_done. For a TUN_RX flow the add path still needs the
> same mutex in mlx5e_attach_decap_route(), so even a successful add can
> block indefinitely. Parse error cleanup also needs the mutex to detach
> the flow.
> 
> Wait on the eswitch until all flows attached to the affected entry or
> route are ready. Drop encap_tbl_lock while sleeping and rescan the lists
> under the mutex before applying the update. A waiter holds no reference
> to a partially initialized flow. Failed adds can therefore tear it down
> and wake the waiter after detach. Successful adds publish their state
> before waking waiters, as do flows retained for multipath retry.
> 
> Process the encap entry even if no flow reference could be taken. A new
> flow can reuse that entry before the deleting flow detaches, so the FIB
> event must invalidate or rebuild its cached header.

unrelated change?

>Remove post-action
> rules, including an extra split rule, before signalling del_hw_done so
> the update can release the reformat object safely.
> 

unrelated change?

> This possible bug was found by our experimental static analysis tool,
> which analyzes lock usage and completion-based synchronization to detect
> potential deadlock patterns.
> 
> Fixes: 8300f225268b ("net/mlx5e: Create new flow attr for multi table actions")
> Signed-off-by: Ziyu Zhang <ziyuzhang201@gmail.com>
> ---
> Changes in v3:
> - Drop encap_tbl_lock while waiting for flow setup in both the neighbour
>    and FIB update paths. Rescan after wakeup so failed adds can detach.
> - Update the encap entry even with an empty flow list and retire
>    post-action rules before signalling del_hw_done.
> 
> v2: https://lore.kernel.org/r/20261126084216.26436-1-ziyuzhang201@gmail.com
> 
>   .../ethernet/mellanox/mlx5/core/en/rep/tc.c   |  3 ++
>   .../ethernet/mellanox/mlx5/core/en/tc_priv.h  |  2 +-
>   .../mellanox/mlx5/core/en/tc_tun_encap.c      | 43 +++++++++++++++++--
>   .../net/ethernet/mellanox/mlx5/core/en_tc.c   | 27 ++++++++++--
>   .../net/ethernet/mellanox/mlx5/core/en_tc.h   |  1 +
>   .../net/ethernet/mellanox/mlx5/core/eswitch.c |  1 +
>   .../net/ethernet/mellanox/mlx5/core/eswitch.h |  1 +
>   7 files changed, 70 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
> index e1ebc9b2d061..1522458213bf 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
> @@ -103,6 +103,9 @@ void mlx5e_rep_update_flows(struct mlx5e_priv *priv,
>   	if (encap_connected == neigh_connected && ether_addr_equal(e->h_dest, ha))
>   		goto unlock;
>   
> +	wait_event_cmd(esw->offloads.encap_flow_wait, mlx5e_encap_flows_ready(e),
> +		       mutex_unlock(&esw->offloads.encap_tbl_lock),
> +		       mutex_lock(&esw->offloads.encap_tbl_lock));

How do you bound this wait?

Today the update keeps encap_tbl_lock while it waits, so no new flow
can attach, and it only waits for the flows that are already in setup.

Thanks,
Tariq

      parent reply	other threads:[~2026-12-01 17:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 14:02 Ziyu Zhang
2026-11-30 14:03 ` netdev-bot+sinfo
2026-12-01 14:27 ` netdev-bot+sashiko
2026-12-01 17:14 ` Tariq Toukan [this message]

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=740d9273-5005-4562-9a84-7d56aeac7fe9@nvidia.com \
    --to=tariqt@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=baijiaju1990@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --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=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=roid@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=ziyuzhang201@gmail.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

all inboxes | Powered by JetHome®