lib: kunit: Suppress a compilation warning of frame size
PATCH 1/1 lib: kunit: Suppress a compilation warning of frame size
lib/bitfield_kunit.c: In function ‘test_bitfields_constants’:lib/bitfield_kunit.c:93:1: warning: the frame size of 7456 bytes is larger than 2048 bytes [-Wframe-larger-than=]
}
^
As the description of BITFIELD_KUNIT in lib/Kconfig.debug, it "Only useful for kernel devs running the KUnit test harness, and not intended for inclusion into a production build". Therefore, it is not worth modifying variable 'test_bitfields_constants' to clear this warning. Just suppress it.
--- lib/Makefile | 1 + 1 file changed, 1 insertion(+)
lib/Makefile +1 -0
@@ -348,6 +348,7 @@ obj-$(CONFIG_OBJAGG) += objagg.o obj-$(CONFIG_PLDMFW) += pldmfw/ # KUnit tests +CFLAGS_bitfield_kunit.o := $(call cc-option,-Wframe-larger-than=10240) obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o
Signature · 1 line
2.26.0.106.g9fadedd
Andrew Morton
maintainerQuoted 10 lines · On Tue, 18 May 2021 17:45:33 +0800 Zhen Lei <[email protected]> wrote:
lib/bitfield_kunit.c: In function ‘test_bitfields_constants’:lib/bitfield_kunit.c:93:1: warning: the frame size of 7456 bytes is larger than 2048 bytes [-Wframe-larger-than=]
}
^As the description of
BITFIELD_KUNITinlib/Kconfig.debug, it "Only useful for kernel devs running the KUnit test harness, and not intended for inclusion into a production build". Therefore, it is not worth modifying variable 'test_bitfields_constants' to clear this warning. Just suppress it.
Well, it would be better to fix this rather than hiding it. The warning is there for a reason!
Firstly, why is this happening? Do those macros end up generating a vast number of `kunit_assert' instances and gcc dumbly fails to reuse the same stack slots?
It would be trivial to split test_bitfields_constants() into four functions. Probably those should use noinline_for_stack to prevent gcc from just inlining everything into the caller.
Also, what's up with this?
/*
* NOTE
* This whole function compiles (or at least should, if everything
* is going according to plan) to nothing after optimisation. */
If that's the case then why did the function use all this stack?
Quoted 12 lines
lib/Makefile +1
-0@@ -348,6 +348,7 @@ obj-$(CONFIG_OBJAGG) += objagg.o obj-$(CONFIG_PLDMFW) += pldmfw/ # KUnit tests +CFLAGS_bitfield_kunit.o := $(call cc-option,-Wframe-larger-than=10240) obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o