]> git.itanic.dy.fi Git - linux-stable/commitdiff
net/mlx5: DR, Fix 'stack frame size exceeds limit' error in dr_rule
authorYevgeny Kliteynik <kliteyn@nvidia.com>
Sat, 12 Nov 2022 22:04:17 +0000 (00:04 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Tue, 10 Jan 2023 06:08:33 +0000 (22:08 -0800)
If the kernel configuration asks the compiler to check frame limit of 1K,
dr_rule_create_rule_nic exceed this limit:
    "stack frame size (1184) exceeds limit (1024)"

Fixing this issue by checking configured frame limit and using the
optimization STE array only for cases with the usual 2K (or larger)
stack size warning.

Fixes: b9b81e1e9382 ("net/mlx5: DR, For short chains of STEs, avoid allocating ste_arr dynamically")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c

index 74cbe53ee9dbb1e042b1c5bb30f3acfd884f802c..b851141e03de3c67e1f422460d1d5cc571356066 100644 (file)
@@ -3,7 +3,12 @@
 
 #include "dr_types.h"
 
+#if defined(CONFIG_FRAME_WARN) && (CONFIG_FRAME_WARN < 2048)
+/* don't try to optimize STE allocation if the stack is too constaraining */
+#define DR_RULE_MAX_STES_OPTIMIZED 0
+#else
 #define DR_RULE_MAX_STES_OPTIMIZED 5
+#endif
 #define DR_RULE_MAX_STE_CHAIN_OPTIMIZED (DR_RULE_MAX_STES_OPTIMIZED + DR_ACTION_MAX_STES)
 
 static int dr_rule_append_to_miss_list(struct mlx5dr_domain *dmn,
@@ -1218,10 +1223,7 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
 
        mlx5dr_domain_nic_unlock(nic_dmn);
 
-       if (unlikely(!hw_ste_arr_is_opt))
-               kfree(hw_ste_arr);
-
-       return 0;
+       goto out;
 
 free_rule:
        dr_rule_clean_rule_members(rule, nic_rule);
@@ -1238,6 +1240,7 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
 free_hw_ste:
        mlx5dr_domain_nic_unlock(nic_dmn);
 
+out:
        if (unlikely(!hw_ste_arr_is_opt))
                kfree(hw_ste_arr);