Patch "net/mlx5e: Don't hold encap tbl lock if there is no encap action" has been added to the 6.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net/mlx5e: Don't hold encap tbl lock if there is no encap action

to the 6.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-mlx5e-don-t-hold-encap-tbl-lock-if-there-is-no-e.patch
and it can be found in the queue-6.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 6d1ce639479b13a9ff5e58f2c199016a66881bc5
Author: Chris Mi <cmi@xxxxxxxxxx>
Date:   Thu Jun 29 11:32:03 2023 +0300

    net/mlx5e: Don't hold encap tbl lock if there is no encap action
    
    [ Upstream commit 93a331939d1d1c6c3422bc09ec43cac658594b34 ]
    
    The cited commit holds encap tbl lock unconditionally when setting
    up dests. But it may cause the following deadlock:
    
     PID: 1063722  TASK: ffffa062ca5d0000  CPU: 13   COMMAND: "handler8"
      #0 [ffffb14de05b7368] __schedule at ffffffffa1d5aa91
      #1 [ffffb14de05b7410] schedule at ffffffffa1d5afdb
      #2 [ffffb14de05b7430] schedule_preempt_disabled at ffffffffa1d5b528
      #3 [ffffb14de05b7440] __mutex_lock at ffffffffa1d5d6cb
      #4 [ffffb14de05b74e8] mutex_lock_nested at ffffffffa1d5ddeb
      #5 [ffffb14de05b74f8] mlx5e_tc_tun_encap_dests_set at ffffffffc12f2096 [mlx5_core]
      #6 [ffffb14de05b7568] post_process_attr at ffffffffc12d9fc5 [mlx5_core]
      #7 [ffffb14de05b75a0] mlx5e_tc_add_fdb_flow at ffffffffc12de877 [mlx5_core]
      #8 [ffffb14de05b75f0] __mlx5e_add_fdb_flow at ffffffffc12e0eef [mlx5_core]
      #9 [ffffb14de05b7660] mlx5e_tc_add_flow at ffffffffc12e12f7 [mlx5_core]
     #10 [ffffb14de05b76b8] mlx5e_configure_flower at ffffffffc12e1686 [mlx5_core]
     #11 [ffffb14de05b7720] mlx5e_rep_indr_offload at ffffffffc12e3817 [mlx5_core]
     #12 [ffffb14de05b7730] mlx5e_rep_indr_setup_tc_cb at ffffffffc12e388a [mlx5_core]
     #13 [ffffb14de05b7740] tc_setup_cb_add at ffffffffa1ab2ba8
     #14 [ffffb14de05b77a0] fl_hw_replace_filter at ffffffffc0bdec2f [cls_flower]
     #15 [ffffb14de05b7868] fl_change at ffffffffc0be6caa [cls_flower]
     #16 [ffffb14de05b7908] tc_new_tfilter at ffffffffa1ab71f0
    
    [1031218.028143]  wait_for_completion+0x24/0x30
    [1031218.028589]  mlx5e_update_route_decap_flows+0x9a/0x1e0 [mlx5_core]
    [1031218.029256]  mlx5e_tc_fib_event_work+0x1ad/0x300 [mlx5_core]
    [1031218.029885]  process_one_work+0x24e/0x510
    
    Actually no need to hold encap tbl lock if there is no encap action.
    Fix it by checking if encap action exists or not before holding
    encap tbl lock.
    
    Fixes: 37c3b9fa7ccf ("net/mlx5e: Prevent encap offload when neigh update is running")
    Signed-off-by: Chris Mi <cmi@xxxxxxxxxx>
    Reviewed-by: Vlad Buslov <vladbu@xxxxxxxxxx>
    Signed-off-by: Saeed Mahameed <saeedm@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

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 f0c3464f037f4..0c88cf47af01b 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
@@ -1030,9 +1030,6 @@ int mlx5e_tc_tun_encap_dests_set(struct mlx5e_priv *priv,
 	int out_index;
 	int err = 0;
 
-	if (!mlx5e_is_eswitch_flow(flow))
-		return 0;
-
 	parse_attr = attr->parse_attr;
 	esw_attr = attr->esw_attr;
 	*vf_tun = false;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index ed05ac8ae1de5..e002f013fa015 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1725,6 +1725,19 @@ verify_attr_actions(u32 actions, struct netlink_ext_ack *extack)
 	return 0;
 }
 
+static bool
+has_encap_dests(struct mlx5_flow_attr *attr)
+{
+	struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;
+	int out_index;
+
+	for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++)
+		if (esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP)
+			return true;
+
+	return false;
+}
+
 static int
 post_process_attr(struct mlx5e_tc_flow *flow,
 		  struct mlx5_flow_attr *attr,
@@ -1737,9 +1750,11 @@ post_process_attr(struct mlx5e_tc_flow *flow,
 	if (err)
 		goto err_out;
 
-	err = mlx5e_tc_tun_encap_dests_set(flow->priv, flow, attr, extack, &vf_tun);
-	if (err)
-		goto err_out;
+	if (mlx5e_is_eswitch_flow(flow) && has_encap_dests(attr)) {
+		err = mlx5e_tc_tun_encap_dests_set(flow->priv, flow, attr, extack, &vf_tun);
+		if (err)
+			goto err_out;
+	}
 
 	if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) {
 		err = mlx5e_tc_attach_mod_hdr(flow->priv, flow, attr);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux