Re: drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c:1170:1: warning: stack frame size (1168) exceeds limit (1024) in 'dr_ste_v0_build_eth_ipv6_l3_l4_tag'
From: Alexander Lobakin
Date: Fri Feb 17 2023 - 08:30:42 EST
From: Kernel Test Robot <lkp@xxxxxxxxx>
Date: Fri, 17 Feb 2023 13:26:53 +0800
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 3ac88fa4605ec98e545fb3ad0154f575fda2de5f
> commit: 7766c9b922febe18b4eb124eb731dd9a1ec71373 net/mlx5: DR, Add missing reserved fields to dr_match_param
> date: 1 year, 2 months ago
> config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20230217/202302171359.vvB4yivq-lkp@xxxxxxxxx/config)
> compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project db89896bbbd2251fff457699635acbbedeead27f)
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # install powerpc cross compiling tool for clang build
> # apt-get install binutils-powerpc-linux-gnu
> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7766c9b922febe18b4eb124eb731dd9a1ec71373
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout 7766c9b922febe18b4eb124eb731dd9a1ec71373
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc olddefconfig
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/net/ethernet/mellanox/ drivers/platform/ drivers/staging/
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Link: https://lore.kernel.org/oe-kbuild-all/202302171359.vvB4yivq-lkp@xxxxxxxxx/
>
> All warnings (new ones prefixed by >>):
>
>>> drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c:1170:1: warning: stack frame size (1168) exceeds limit (1024) in 'dr_ste_v0_build_eth_ipv6_l3_l4_tag' [-Wframe-larger-than]
> dr_ste_v0_build_eth_ipv6_l3_l4_tag(struct mlx5dr_match_param *value,
> ^
> 56/1168 (4.79%) spills, 1112/1168 (95.21%) variables
I wondered a bit regarding this warning, please see below.
> 1 warning generated.
>
>
> vim +/dr_ste_v0_build_eth_ipv6_l3_l4_tag +1170 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c
>
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1168
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1169 static int
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 @1170 dr_ste_v0_build_eth_ipv6_l3_l4_tag(struct mlx5dr_match_param *value,
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1171 struct mlx5dr_ste_build *sb,
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1172 u8 *tag)
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1173 {
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1174 struct mlx5dr_match_spec *spec = sb->inner ? &value->inner : &value->outer;
> 0733535d59e154 Yevgeny Kliteynik 2021-07-04 1175 struct mlx5dr_match_misc *misc = &value->misc;
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1176
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1177 DR_STE_SET_TAG(eth_l4, tag, dst_port, spec, tcp_dport);
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1178 DR_STE_SET_TAG(eth_l4, tag, src_port, spec, tcp_sport);
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1179 DR_STE_SET_TAG(eth_l4, tag, dst_port, spec, udp_dport);
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1180 DR_STE_SET_TAG(eth_l4, tag, src_port, spec, udp_sport);
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1181 DR_STE_SET_TAG(eth_l4, tag, protocol, spec, ip_protocol);
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1182 DR_STE_SET_TAG(eth_l4, tag, fragmented, spec, frag);
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1183 DR_STE_SET_TAG(eth_l4, tag, dscp, spec, ip_dscp);
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1184 DR_STE_SET_TAG(eth_l4, tag, ecn, spec, ip_ecn);
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1185 DR_STE_SET_TAG(eth_l4, tag, ipv6_hop_limit, spec, ttl_hoplimit);
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1186
> 0733535d59e154 Yevgeny Kliteynik 2021-07-04 1187 if (sb->inner)
> 0733535d59e154 Yevgeny Kliteynik 2021-07-04 1188 DR_STE_SET_TAG(eth_l4, tag, flow_label, misc, inner_ipv6_flow_label);
> 0733535d59e154 Yevgeny Kliteynik 2021-07-04 1189 else
> 0733535d59e154 Yevgeny Kliteynik 2021-07-04 1190 DR_STE_SET_TAG(eth_l4, tag, flow_label, misc, outer_ipv6_flow_label);
> 0733535d59e154 Yevgeny Kliteynik 2021-07-04 1191
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1192 if (spec->tcp_flags) {
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1193 DR_STE_SET_TCP_FLAGS(eth_l4, tag, spec);
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1194 spec->tcp_flags = 0;
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1195 }
So you have 11 _SET_TAG() here (each of them is MLX5_SET()) + one
_SET_TCP_FLAGS(), which in fact is 9 more MLX5_SET(). Total 20 and
MLX5_SET() hides a u32 inside. 20 * 4 = 80 bytes, so I still doesn't
fully understand how it becomes 1112 bytes. Probably each _SET() expands
to something more than just one integer (it has a lot of calculations
inside, however, all of them are compile-time constants, so dunno).
One proposal would be to move this block:
if (tcp_flags) {
SET_TCP_FLAGS();
tcp_flags = 0;
}
into a separate noinline function. Or to try to optimize MLX5_SET()
somehow :D
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1196
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1197 return 0;
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1198 }
> d65e841de80375 Yevgeny Kliteynik 2020-11-19 1199
>
> :::::: The code at line 1170 was first introduced by commit
> :::::: d65e841de80375372f9842ed71756d3b90d96dc4 net/mlx5: DR, Move HW STEv0 match logic to a separate file
>
> :::::: TO: Yevgeny Kliteynik <kliteyn@xxxxxxxxxx>
> :::::: CC: Saeed Mahameed <saeedm@xxxxxxxxxx>
>
Thanks,
Olek