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=1796135247; b=3dYvlI2khqvbDZzlmPZeE1Km7lD6StmHBjBgN4gCOMi4t7Xp60LAYEXokbMLb/6g0Tt5 mTsxWxQEnM7TlnUrupqupYHA0LAhKhag6QeZ1y0vRgHzvz1J7LbJQb8DR+ucDl21nKhi4 tBTksFCZNAFb5ze9lFCgDT0xPzEz3XCCU6c/9qAuj77WaOR9to2j2/QQEYFa/3x5ezq0t RZLWzsqP1SXlslrQkK/Kn0XcKXGfpL5gjYLL4MuGnETthBIvc/ecpGjE4QknulGPtMe5x 49wVIcVU9boCJg1B8swXWf3vEGJLP2qG+oCBOJ0WdMyChtSCBILMrJf+ql8Rejmfnwg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796135247; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=pLTnJzocCQhHimBbxOnNH6wURHHp3YttDYUy8FAVbFQ=; b=t9JWt3CojeoYlck8ULeoHVOt+7x1cm/EgAkYleEneqSjZr57jgj5f5na2ScNWRdp0viK nG2hDH16xBlWxLu9G65yUbkM6/cjxn1njmyrD2a9RKuMZfzjd9jxlwhQgJgxcS5ubtiVe nUznvf0HqZ3HIxon7C85jXZXx4FJJB2kblg0FdXAxfDp86oMyKqfIgNmjc/dhGqDk5l06 HbuvhCP3a+t6lfAcb1IbjkF7K0JziYQSUQauEgk+Vooz2KMh4GBC82IKvFYxX8Nf35gYO zeAlAi9i0Nbohi2yR0EbmUY/3onK/oWYjDyQBxt0ZQ369mopDl9OlwToHynkKd8eusQ== 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=UrgxE1yW; 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 C916E606A68D; Tue, 1 Dec 2026 14:27:27 +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=UrgxE1yW Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC03F1F008A0; Tue, 1 Dec 2026 14:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796135247; bh=pLTnJzocCQhHimBbxOnNH6wURHHp3YttDYUy8FAVbFQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=UrgxE1yWOKnh06eeJdxlDtUY6uMHS2PYLGQCA6Vt1ODN1tvUe+EQ+0dUEqax8tXZT hrkIVuapqTD05WpiWFmqunWKxJohDTW5JYHpx3MTmPPsXjBPmgmLnzZKgQEFX6+hUR 8f5AGqhJEbbWBv30rizqpZ9P/6rytHGDdomeqF7jCthSlt2bSxKJo10DV88aWVUHtN mdv77HHdGpp1lVk6xshEIaKnXDTOtDeAa5OmbXxskmir5sbGF3Xl/3N8Y0WWB/kahm GdSsNeBYJ82VW3Rpkn741qDr5RKpIdns792mKQjkScUOy4bqr2gNQq+X/ABj0H/af4 l14DvjXtr/eZA== Subject: Re: [PATCH net v3] net/mlx5e: Wait for flow setup outside encap_tbl_lock From: netdev-bot+sashiko@kernel.org To: ziyuzhang201@gmail.com Cc: saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, leon@kernel.org, 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 Date: Tue, 01 Dec 2026 14:27:26 +0000 Message-ID: <179613524627.3146.8229945560228350466@kernel.org> In-Reply-To: <20261130140215.66953-1-ziyuzhang201@gmail.com> References: <20261130140215.66953-1-ziyuzhang201@gmail.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider. Critical: 0 · High: 2 · Medium: 1 · Low: 1 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The flow's extra-split post-action rule (flow->extra_split_attr) keeps pointing at the encap entry's freed pkt_reformat, and the live-… - [High] Lost wakeup when the flow and the neighbour waiter use different eswitches: the neighbour worker can sleep forever in… - [Medium] The new waits only finish when every flow on the entry or route is ready at the same moment, and nothing guarantees that moment… - [Low] The commit combines three separate fixes under one Fixes: tag. -- net/mlx5e: Wait for flow setup outside encap_tbl_lock This patch replaces the per-flow init_done completion with a bool and a per-eswitch waitqueue. Neighbour and FIB updates now sleep with encap_tbl_lock dropped until every flow on the affected encap entry or route is ready. It also processes encap entries that have an empty flow list, and removes post-action rules (including the extra split rule) before signalling del_hw_done. > 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 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 == 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)); [Severity: High] Can this waiter end up sleeping on a different eswitch's waitqueue than the one the flow wakes? Here esw comes from priv. mlx5e_rep_neigh_update() derives priv from e->out_dev while it holds rtnl_lock: mlx5e_rep_neigh_update() rtnl_lock(); ... while ((e = mlx5e_get_next_init_encap(nhe, e)) != NULL) mlx5e_rep_update_flows(netdev_priv(e->out_dev), e, neigh_connected, ha); get_route_and_out_devs() can return a peer PF's uplink as out_dev. mlx5e_is_valid_eswitch_fwd_dev() accepts it through is_lag_dev() or is_multiport_eligible() in multipath/LAG or MPESW setups. The encap entry and its e->flows list, though, belong to flow->priv's eswitch. The flow side only wakes the waitqueue of its own eswitch: __mlx5e_add_fdb_flow() smp_store_release(&flow->init_done, true); wake_up_all(&priv->mdev->priv.eswitch->offloads.encap_flow_wait); mlx5e_tc_del_fdb_flow() if (!READ_ONCE(flow->init_done)) wake_up_all(&esw->offloads.encap_flow_wait); Suppose a flow on PF0 is still being set up, its out_dev is PF1's uplink, and a neighbour update for the tunnel nexthop arrives. Would the worker then stay in TASK_UNINTERRUPTIBLE with rtnl_lock held until some unrelated flow on PF1 happens to be added? The old per-flow completion did not depend on which eswitch the waiter used. The repeated mlx5e_encap_flows_ready() walk also runs under the peer eswitch's encap_tbl_lock, not the lock that protects e->flows. The existing list walk in this function already had that problem, but the rescan loop makes the window larger. > mlx5e_take_all_encap_flows(e, &flow_list); > > if ((e->flags & MLX5_ENCAP_ENTRY_VALID) && > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c > index 4f9f8beffbc8d..59fb5c15c875e 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c [ ... ] > @@ -1594,8 +1627,6 @@ static int mlx5e_update_route_encaps(struct mlx5e_priv *priv, > LIST_HEAD(encap_flows); > > mlx5e_take_all_encap_flows(e, &encap_flows); > - if (list_empty(&encap_flows)) > - continue; [Severity: Low] This isn't a bug, but the patch seems to put three separate changes under one Fixes: tag: - replacing the init_done completion with a bool plus a waitqueue - removing the list_empty() skip here - deleting the post-act and extra split handles before complete_all(&flow->del_hw_done) in mlx5e_tc_del_fdb_flow() The list_empty() skip came from 8914add2c9e5, and the extra_split_attr handling was added by 16bb8c613379. Neither comes from the cited 8300f225268b. The last two changes fix problems that occur even without an init_done waiter. Could they go into their own patches with matching Fixes: tags, so they can be backported, bisected and reverted separately? > > if (mlx5e_route_entry_valid(r)) > mlx5e_invalidate_encap(priv, e, &encap_flows); > @@ -1704,6 +1735,12 @@ static void mlx5e_tc_fib_event_work(struct work_struct *work) > if (!mlx5e_route_entry_valid(r) && !replace) > goto out; > > + /* Setup and error unwind both need encap_tbl_lock. Rescan the route > + * after waking, before changing any of its entries. > + */ > + wait_event_cmd(esw->offloads.encap_flow_wait, mlx5e_route_flows_ready(r), > + mutex_unlock(&esw->offloads.encap_tbl_lock), > + mutex_lock(&esw->offloads.encap_tbl_lock)); [Severity: Medium] What guarantees that this wait finishes while new flows keep attaching to the route? mlx5e_route_flows_ready() and mlx5e_encap_flows_ready() walk the live r->encap_entries, e->flows and r->decap_flows lists. While encap_tbl_lock is dropped, other __mlx5e_add_fdb_flow() callers can attach new flows with init_done == false through mlx5e_attach_encap() or mlx5e_attach_decap_route(). Flower offload on reps does not take rtnl. Each publish wakes the waiter, which can then find another unready flow and go back to sleep. Consider a steady stream of inserts that share one tunnel, for example OVS offloading many flows to the same VXLAN remote from several handler threads. Could this worker then hold rtnl_lock in TASK_UNINTERRUPTIBLE for as long as the stream lasts? The new wait in mlx5e_rep_update_flows() follows the same pattern. The old wait ran under encap_tbl_lock, so the set of flows it waited on was fixed. > err = mlx5e_update_route_encaps(priv, r, &flow_list, replace); > if (err) > mlx5_core_warn(priv->mdev, "Failed to update route encaps, %d\n", > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/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 [ ... ] > @@ -2079,6 +2089,11 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, > else > mlx5e_tc_unoffload_fdb_rules(esw, flow, attr); > } > + /* An encap update may free the reformat object once del_hw_done fires. */ > + list_for_each_entry(post_attr, &flow->attrs, list) > + mlx5e_del_post_act_handle(flow, post_attr); > + if (flow->extra_split_attr) > + mlx5e_del_post_act_handle(flow, flow->extra_split_attr); > complete_all(&flow->del_hw_done); [Severity: High] The commit message says the post-action rules, "including an extra split rule", are removed "before signalling del_hw_done so the update can release the reformat object safely". That covers flows being deleted. What about live flows with an extra split rule during an encap update? extra_split_attr_dests() struct-copies the dests after split_count into attr2, including pkt_reformat and the encap flags: for (i = split_count, j = 0; i < esw_attr->out_count; i++, j++) esw_attr2->dests[j] = esw_attr->dests[i]; attr2 is offloaded as its own post-act rule. It is stored only in flow->extra_split_attr and is not linked into flow->attrs. Both mlx5e_tc_unoffload_flow_post_acts() and mlx5e_tc_offload_flow_post_acts() only walk flow->attrs. On a neighbour down or MAC change, mlx5e_tc_encap_flows_del() calls mlx5_packet_reformat_dealloc() on e->pkt_reformat. mlx5e_invalidate_encap() does the same on a FIB event, and with this patch it also runs when the flow list is empty. At that point the extra split rule is still installed and still references the freed reformat. mlx5e_reoffload_encap() then updates only mlx5e_tc_get_encap_attr(flow)->esw_attr->dests[]. The extra split rule is never rebuilt with the new e->pkt_reformat. Take a rule with split_count > 0 (for example a vlan push) that has both a plain uplink and an encap mirred after the split. Would the mirrored copy then be sent through a released reformat object? In HWS/SWS modes another tunnel could reuse that object. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130140215.66953-1-ziyuzhang201%40gmail.com