From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796133783; b=Kge5YHuve2DQlrgImTEOcd/iIDIQ3RzQSOFl+3WJABoHyeB8nVrYMtbiYoKjquZ6apVJ 3nCCGH+LWq5QKkFr1gxV35l3kdIA8dGIVnw2ItXPVpwK/SWd6ElPsKuICln3jO1BxqcUX wFuT8+tU7QLkKY1fhbOCttKTm38kO5UjYvxcWQoaoihTfiuShHWOlyph8oN5nhS13IeNK 0rW47CXLLp/xPZoHXjjFt5NQ/EVhNIF7RquGsXmH8bj8eG41eP+v1n4VB/n5Dspzcx4me cjKEVNH2ulJ+zo/SNvPyDlJARGWFN5w2WKUgw2SvTcJzveuf8Uf5AfPgtZgNWTRpE2A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796133783; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=XWSuoOW6v0u+xjkAD4Xm/68pUAOicT4KRFphLLaHSZE=; b=Onb3Jei9ZIVQZlHCS2++1SrG/PmRm1YKUb1PF1QCFwqlIyCvAxgmXPoE+PSb+wa5+27R c3M2gZNkuot9sk7hmx6j7C0T0YljQrfdG5CxceiZfCoxT/4S+0sdYf9lgZJF8EaJgtiWk pzwlkBDjgYRo7hohaKhtNzrberoQwRaE3k7bH+MhUmbF0HiXW3HlUdhe/9wh829n2R/SQ Y03eQrvN6paZ92pXcOhWCeaFXDi1qmuBJbYjn8tKLyC+q7/Zw0PImY8/c4CaIVxjl3cj+ gDb22b2HEfW8Kys/MGnkLlt5Jfs/mBwknzWRjs39kKRblQVub+UcubyeEFJQQAMPkig== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PWjMxhtm; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1E93606A32D for ; Tue, 1 Dec 2026 14:03:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PWjMxhtm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FA251F000C1; Tue, 1 Dec 2026 14:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796133782; bh=XWSuoOW6v0u+xjkAD4Xm/68pUAOicT4KRFphLLaHSZE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=PWjMxhtmwV5sHzWeI7Hu7qLD8pBR2btq8YaczGNkdZh+BK2kk6Pb7Lx9j3DvKdbwA 4PI6d8hEeiRPZz3+0YIG16G6MG5TVkRVZX1rLsd1tFNCh6f3sp86bmNIMLjhLn4Rd9 fAKAIP7NVbtV+ImkDpZ3akqjf+rWqA4nX6I1oz3fPqUm5BkbiPOn0yAIE+aFrE6JgD Ri4NNdLUMze+dhgvF4pMx3awPs4KRVWhgr/pTD8XEZ8ZghXsDzqXdCjij2dgik2/zu nDDQqul987oTMKCX6pIHqb8DxwUiBQ46OWTeebsDcr0zMLpLHs10yaHKvYac+hWCvB rs2UhbUeH0VEg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net v3] net/mlx5e: Wait for flow setup outside encap_tbl_lock Reply-To: sashiko-reviews@lists.linux.dev To: "Ziyu Zhang" Cc: linux-rdma@vger.kernel.org In-Reply-To: <20261130140215.66953-1-ziyuzhang201@gmail.com> References: <20261130140215.66953-1-ziyuzhang201@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 14:03:02 +0000 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] net/mlx5e: mismatched eswitch encap_flow_wait waitqueue across peer eswitches - [Medium] net/mlx5e: premature flow->init_done publication on multipath retry -- commit b29fecbbd509d028a51eb87566d082bb9f3fbba8 Author: Ziyu Zhang net/mlx5e: Wait for flow setup outside encap_tbl_lock This commit replaces the per-flow init_done completion with a boolean flag and a per-eswitch waitqueue so neighbour and FIB updates drop encap_tbl_lock while waiting for in-flight flow setup to finish. It also retires post-action rules before signalling del_hw_done and processes encap entries during FIB updates even when no flow reference is taken. > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c b/driver= s/net/ethernet/mellanox/mlx5/core/en/rep/tc.c > index e1ebc9b2d061d..1522458213bff 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 =3D=3D neigh_connected && ether_addr_equal(e->h_des= t, ha)) > goto unlock; > =20 > + 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)); > mlx5e_take_all_encap_flows(e, &flow_list); > =20 > if ((e->flags & MLX5_ENCAP_ENTRY_VALID) && [Severity: High] Can waiting on esw->offloads.encap_flow_wait miss wakeups when the flow and the encap or route entry belong to different eswitch instances? In mlx5e_rep_neigh_update(), mlx5e_rep_update_flows() is called with netdev_priv(e->out_dev), so it sleeps on the encap output device's esw->offloads.encap_flow_wait while holding rtnl_lock(). In multiport eswitch or LAG setups, get_route_and_out_devs() allows e->out_dev to be a peer eswitch uplink representor, and mlx5e_tc_fib_event_work() similarly sleeps on the uplink device's eswitch waitqueue. However, __mlx5e_add_fdb_flow() and mlx5e_tc_del_fdb_flow() only wake flow->priv->mdev->priv.eswitch->offloads.encap_flow_wait. If a flow added on one eswitch attaches to an encap or route entry owned by the peer eswitch (for example, in alloc_flow_post_acts()) and a neighbour or FIB update sees flow->init_done =3D=3D false, the wakeup fires= on the originating eswitch waitqueue and leaves the waiter hung in TASK_UNINTERRUPTIBLE with rtnl_lock() held: CPU0 CPU1 (neigh/FIB update) __mlx5e_add_fdb_flow() [esw0] parse_tc_fdb_actions() alloc_flow_post_acts() mlx5e_attach_encap() /* attaches to e on esw1 */ rtnl_lock() mlx5e_rep_update_flows() [esw1] wait_event_cmd( esw1->offloads.encap_flow_wait, mlx5e_encap_flows_ready(e), ...) /* setup fails or finishes */ wake_up_all( &esw0->offloads.encap_flow_wait) <-- never woken; hangs with RTNL > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/ne= t/ethernet/mellanox/mlx5/core/en_tc.c > index 011741553f5b9..1688f8951581e 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c [ ... ] > @@ -4584,7 +4601,6 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv, > goto err_free; > =20 > err =3D mlx5e_tc_add_fdb_flow(priv, flow, extack); > - complete_all(&flow->init_done); > if (err) { > if (!(err =3D=3D -ENETUNREACH && mlx5_lag_is_multipath(in_mdev))) > goto err_free; > @@ -4592,6 +4608,9 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv, > add_unready_flow(flow); > } > =20 > + /* Publish the initialized attributes to neighbour and FIB updates. */ > + smp_store_release(&flow->init_done, true); > + wake_up_all(&priv->mdev->priv.eswitch->offloads.encap_flow_wait); > return flow; > =20 > err_free: [Severity: Medium] Does setting flow->init_done =3D true when mlx5e_tc_add_fdb_flow() fails with -ENETUNREACH under multipath LAG expose an uninitialized flow to concurrent neighbour and FIB updates? When a flow with a multi-table post-action encap hits -ENETUNREACH and is queued via add_unready_flow(), alloc_flow_post_acts() has already attached the flow to e->flows and offloaded the post-action rule using e->pkt_reformat, while MLX5E_TC_FLOW_FLAG_OFFLOADED remains clear. Because flow->init_done is published anyway, a concurrent mlx5e_tc_encap_flows_del() or mlx5e_invalidate_encap() does not wait, sees !mlx5e_is_offloaded_flow(flow), skips mlx5e_tc_unoffload_flow_post_acts(), and frees e->pkt_reformat via mlx5_packet_reformat_dealloc() while the post-action rule in hardware still references it. In addition, when mlx5e_tc_reoffload_flows_work() later retries mlx5e_tc_add_fdb_flow() on the unready flow, flow->init_done is already true, so concurrent neighbour or FIB updates bypass wait_event_cmd() and race with the retry while it modifies flow->attr. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130140215.6695= 3-1-ziyuzhang201@gmail.com?part=3D1