-
Notifications
You must be signed in to change notification settings - Fork 15
-Wframe-larger-than in sound/soc/intel/avs/path.c #1642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I wonder why memcmp has so many local variables? Also looks like there's tons of |
I see |
I finally got around to looking into this further. It can be reproduced with this minimal set of configs on top of
It is because of The It seems like this is just caused by excessive inlining plus KASAN not reusing stack slots? I am leaning towards sending this diff, which drastically reduces the stack usage, as can be seen by adding $ git diff
diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c
index 3d46dd5e5bc4..ec2aa0001f91 100644
--- a/sound/soc/intel/avs/path.c
+++ b/sound/soc/intel/avs/path.c
@@ -449,7 +449,8 @@ static int avs_modext_create(struct avs_dev *adev, struct avs_path_module *mod)
return ret;
}
-static int avs_path_module_type_create(struct avs_dev *adev, struct avs_path_module *mod)
+static noinline_for_stack int avs_path_module_type_create(struct avs_dev *adev,
+ struct avs_path_module *mod)
{
const guid_t *type = &mod->template->cfg_ext->type;
$ make -skj"$(nproc)" ARCH=arm64 KCONFIG_ALLCONFIG=1 LLVM=1 mrproper allnoconfig sound/soc/intel/avs/path.o
sound/soc/intel/avs/path.c:816:18: warning: stack frame size (192) exceeds limit (128) in 'avs_path_create' [-Wframe-larger-than]
struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id,
^
sound/soc/intel/avs/path.c:874:5: warning: stack frame size (256) exceeds limit (128) in 'avs_path_bind' [-Wframe-larger-than]
int avs_path_bind(struct avs_path *path)
^
sound/soc/intel/avs/path.c:452:31: warning: stack frame size (352) exceeds limit (128) in 'avs_path_module_type_create' [-Wframe-larger-than]
static noinline_for_stack int avs_path_module_type_create(struct avs_dev *adev,
^
sound/soc/intel/avs/path.c:344:12: warning: stack frame size (160) exceeds limit (128) in 'avs_mux_create' [-Wframe-larger-than]
static int avs_mux_create(struct avs_dev *adev, struct avs_path_module *mod)
^
sound/soc/intel/avs/path.c:267:12: warning: stack frame size (160) exceeds limit (128) in 'avs_updown_mix_create' [-Wframe-larger-than]
static int avs_updown_mix_create(struct avs_dev *adev, struct avs_path_module *mod)
^
sound/soc/intel/avs/path.c:325:12: warning: stack frame size (160) exceeds limit (128) in 'avs_aec_create' [-Wframe-larger-than]
static int avs_aec_create(struct avs_dev *adev, struct avs_path_module *mod)
^
6 warnings generated. |
I have sent the above diff for review: https://lore.kernel.org/[email protected]/ |
When building ARCH=arm64 allmodconfig with clang, there is a warning about high stack usage in avs_path_create(), which breaks the build due to CONFIG_WERROR=y: sound/soc/intel/avs/path.c:815:18: error: stack frame size (2176) exceeds limit (2048) in 'avs_path_create' [-Werror,-Wframe-larger-than] struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id, ^ 1 error generated. This warning is also visible with allmodconfig on other architectures. The minimum set of configs that triggers this on top of ARCH=arm64 allnoconfig: CONFIG_COMPILE_TEST=y CONFIG_FORTIFY_SOURCE=y CONFIG_KASAN=y CONFIG_PCI=y CONFIG_SOUND=y CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_SOC_INTEL_AVS=y When CONFIG_FORTIFY_SOURCE is enabled, memcmp() (called from guid_equal()) becomes a wrapper to do compile time checking, which interacts poorly with inlining plus CONFIG_KASAN=y. With ARCH=arm64 allmodconfig + CONFIG_KASAN=n + CONFIG_FRAME_WARN=128, the stack usage is much better: sound/soc/intel/avs/path.c:815:18: warning: stack frame size (624) exceeds limit (128) in 'avs_path_create' [-Wframe-larger-than] struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id, ^ sound/soc/intel/avs/path.c:873:5: warning: stack frame size (144) exceeds limit (128) in 'avs_path_bind' [-Wframe-larger-than] int avs_path_bind(struct avs_path *path) ^ 2 warnings generated. To avoid this warning, mark avs_path_module_type_create() as noinline_for_stack, which redistributes the stack usage across multiple functions, regardless of CONFIG_KASAN. With ARCH=arm64 allmodconfig + CONFIG_FRAME_WARN=128, the warnings show: avs_path_create(): 192 avs_path_bind(): 272 avs_path_module_type_create(): 416 avs_mux_create(): 160 avs_updown_mix_create(): 160 avs_aec_create(): 176 avs_asrc_create(): 144 With ARCH=arm64 allmodconfig + CONFIG_FRAME_WARN=128 + CONFIG_KASAN=n, the warnings show: avs_path_create(): 192 avs_path_bind(): 144 avs_path_module_type_create(): 416 avs_mux_create(): 176 avs_updown_mix_create(): 176 avs_src_create(): 144 avs_aec_create(): 192 avs_asrc_create(): 144 avs_wov_create(): 144 Link: ClangBuiltLinux#1642 Signed-off-by: Nathan Chancellor <[email protected]>
As reported by Nathan, when building avs driver using clang with: CONFIG_COMPILE_TEST=y CONFIG_FORTIFY_SOURCE=y CONFIG_KASAN=y CONFIG_PCI=y CONFIG_SOUND=y CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_SOC_INTEL_AVS=y there are reports of too big stack use, like: sound/soc/intel/avs/path.c:815:18: error: stack frame size (2176) exceeds limit (2048) in 'avs_path_create' [-Werror,-Wframe-larger-than] struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id, ^ 1 error generated. This is apparently caused by inlining many calls to guid_equal which inlines fortified memcpy, using 2 size_t variables. Instead of hardcoding many calls to guid_equal, use lookup table with one call, this improves stack usage. Link: https://lore.kernel.org/alsa-devel/[email protected]/T/ Link: ClangBuiltLinux#1642 Signed-off-by: Amadeusz Sławiński <[email protected]> Reported-by: Nathan Chancellor <[email protected]> Build-tested-by: Nathan Chancellor <[email protected]>
Alternative patch submitted: https://lore.kernel.org/[email protected]/ |
As reported by Nathan, when building avs driver using clang with: CONFIG_COMPILE_TEST=y CONFIG_FORTIFY_SOURCE=y CONFIG_KASAN=y CONFIG_PCI=y CONFIG_SOUND=y CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_SOC_INTEL_AVS=y there are reports of too big stack use, like: sound/soc/intel/avs/path.c:815:18: error: stack frame size (2176) exceeds limit (2048) in 'avs_path_create' [-Werror,-Wframe-larger-than] struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id, ^ 1 error generated. This is apparently caused by inlining many calls to guid_equal which inlines fortified memcpy, using 2 size_t variables. Instead of hardcoding many calls to guid_equal, use lookup table with one call, this improves stack usage. Link: https://lore.kernel.org/alsa-devel/[email protected]/T/ Link: ClangBuiltLinux/linux#1642 Signed-off-by: Amadeusz Sławiński <[email protected]> Reported-by: Nathan Chancellor <[email protected]> Build-tested-by: Nathan Chancellor <[email protected]> Reviewed-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
commit 1e74435 upstream. As reported by Nathan, when building avs driver using clang with: CONFIG_COMPILE_TEST=y CONFIG_FORTIFY_SOURCE=y CONFIG_KASAN=y CONFIG_PCI=y CONFIG_SOUND=y CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_SOC_INTEL_AVS=y there are reports of too big stack use, like: sound/soc/intel/avs/path.c:815:18: error: stack frame size (2176) exceeds limit (2048) in 'avs_path_create' [-Werror,-Wframe-larger-than] struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id, ^ 1 error generated. This is apparently caused by inlining many calls to guid_equal which inlines fortified memcpy, using 2 size_t variables. Instead of hardcoding many calls to guid_equal, use lookup table with one call, this improves stack usage. Link: https://lore.kernel.org/alsa-devel/[email protected]/T/ Link: ClangBuiltLinux#1642 Signed-off-by: Amadeusz Sławiński <[email protected]> Reported-by: Nathan Chancellor <[email protected]> Build-tested-by: Nathan Chancellor <[email protected]> Reviewed-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]> Cc: Naresh Kamboju <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 1e74435 upstream. As reported by Nathan, when building avs driver using clang with: CONFIG_COMPILE_TEST=y CONFIG_FORTIFY_SOURCE=y CONFIG_KASAN=y CONFIG_PCI=y CONFIG_SOUND=y CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_SOC_INTEL_AVS=y there are reports of too big stack use, like: sound/soc/intel/avs/path.c:815:18: error: stack frame size (2176) exceeds limit (2048) in 'avs_path_create' [-Werror,-Wframe-larger-than] struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id, ^ 1 error generated. This is apparently caused by inlining many calls to guid_equal which inlines fortified memcpy, using 2 size_t variables. Instead of hardcoding many calls to guid_equal, use lookup table with one call, this improves stack usage. Link: https://lore.kernel.org/alsa-devel/[email protected]/T/ Link: ClangBuiltLinux#1642 Signed-off-by: Amadeusz Sławiński <[email protected]> Reported-by: Nathan Chancellor <[email protected]> Build-tested-by: Nathan Chancellor <[email protected]> Reviewed-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]> Cc: Naresh Kamboju <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 1e74435 upstream. As reported by Nathan, when building avs driver using clang with: CONFIG_COMPILE_TEST=y CONFIG_FORTIFY_SOURCE=y CONFIG_KASAN=y CONFIG_PCI=y CONFIG_SOUND=y CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_SOC_INTEL_AVS=y there are reports of too big stack use, like: sound/soc/intel/avs/path.c:815:18: error: stack frame size (2176) exceeds limit (2048) in 'avs_path_create' [-Werror,-Wframe-larger-than] struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id, ^ 1 error generated. This is apparently caused by inlining many calls to guid_equal which inlines fortified memcpy, using 2 size_t variables. Instead of hardcoding many calls to guid_equal, use lookup table with one call, this improves stack usage. Link: https://lore.kernel.org/alsa-devel/[email protected]/T/ Link: ClangBuiltLinux/linux#1642 Signed-off-by: Amadeusz Sławiński <[email protected]> Reported-by: Nathan Chancellor <[email protected]> Build-tested-by: Nathan Chancellor <[email protected]> Reviewed-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]> Cc: Naresh Kamboju <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 1e74435 upstream. As reported by Nathan, when building avs driver using clang with: CONFIG_COMPILE_TEST=y CONFIG_FORTIFY_SOURCE=y CONFIG_KASAN=y CONFIG_PCI=y CONFIG_SOUND=y CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_SOC_INTEL_AVS=y there are reports of too big stack use, like: sound/soc/intel/avs/path.c:815:18: error: stack frame size (2176) exceeds limit (2048) in 'avs_path_create' [-Werror,-Wframe-larger-than] struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id, ^ 1 error generated. This is apparently caused by inlining many calls to guid_equal which inlines fortified memcpy, using 2 size_t variables. Instead of hardcoding many calls to guid_equal, use lookup table with one call, this improves stack usage. Link: https://lore.kernel.org/alsa-devel/[email protected]/T/ Link: ClangBuiltLinux/linux#1642 Signed-off-by: Amadeusz Sławiński <[email protected]> Reported-by: Nathan Chancellor <[email protected]> Build-tested-by: Nathan Chancellor <[email protected]> Reviewed-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]> Cc: Naresh Kamboju <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
As reported by Nathan, when building avs driver using clang with: CONFIG_COMPILE_TEST=y CONFIG_FORTIFY_SOURCE=y CONFIG_KASAN=y CONFIG_PCI=y CONFIG_SOUND=y CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_SOC_INTEL_AVS=y there are reports of too big stack use, like: sound/soc/intel/avs/path.c:815:18: error: stack frame size (2176) exceeds limit (2048) in 'avs_path_create' [-Werror,-Wframe-larger-than] struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id, ^ 1 error generated. This is apparently caused by inlining many calls to guid_equal which inlines fortified memcpy, using 2 size_t variables. Instead of hardcoding many calls to guid_equal, use lookup table with one call, this improves stack usage. Link: https://lore.kernel.org/alsa-devel/[email protected]/T/ Link: ClangBuiltLinux/linux#1642 Signed-off-by: Amadeusz Sławiński <[email protected]> Reported-by: Nathan Chancellor <[email protected]> Build-tested-by: Nathan Chancellor <[email protected]> Reviewed-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]> Change-Id: Idd81cf2a4c8a91009b7561008246144bc7b70584 (cherry picked from commit 1e744351bcb9c4cee81300de5a6097100d835386) Signed-off-by: Cezary Rojewski <[email protected]>
Initially reported by KernelCI: https://lore.kernel.org/[email protected]/
On arm64 allmodconfig:
I don't see any particularly large objects on the stack with
frame_larger_than.py
, could just be an inlining issue?frame_larger_than.py
outputIt seems like something might be going on with
avs_path_module_type_create()
based on that output?The text was updated successfully, but these errors were encountered: