mbox series

[v1,0/6] kunit: build kunit tests without structleak plugin

Message ID 20210917061104.2680133-1-brendanhiggins@google.com (mailing list archive)
Headers show
Series kunit: build kunit tests without structleak plugin | expand

Message

Brendan Higgins Sept. 17, 2021, 6:10 a.m. UTC
The structleak plugin causes the stack frame size to grow immensely when
used with KUnit; this is caused because KUnit allocates lots of
moderately sized structs on the stack as part of its assertion macro
implementation. For most tests with small to moderately sized tests
cases there are never enough KUnit assertions to be an issue at all;
even when a single test cases has many KUnit assertions, the compiler
should never put all these struct allocations on the stack at the same
time since the scope of the structs is so limited; however, the
structleak plugin does not seem to respect the compiler doing the right
thing and will still warn of excessive stack size in some cases.

These patches are not a permanent solution since new tests can be added
with huge test cases, but this serves as a stop gap to stop structleak
from being used on KUnit tests which will currently result in excessive
stack size.

Of the following patches, I think the thunderbolt patch may be
unnecessary since Linus already fixed that test. Additionally, I was not
able to reproduce the error on the sdhci-of-aspeed test. Nevertheless, I
included these tests cases for completeness. Please see my discussion
with Arnd for more context[1].

NOTE: Arnd did the legwork for most of these patches, but did not
actually share code for some of them, so I left his Signed-off-by off of
those patches as I don't want to misrepresent him. Arnd, please sign off
on those patches at your soonest convenience.

[1] https://lore.kernel.org/linux-arm-kernel/CAFd5g44udqkDiYBWh+VeDVJ=ELXeoXwunjv0f9frEN6HJODZng@mail.gmail.com/

Arnd Bergmann (1):
  bitfield: build kunit tests without structleak plugin

Brendan Higgins (5):
  gcc-plugins/structleak: add makefile var for disabling structleak
  iio/test-format: build kunit tests without structleak plugin
  device property: build kunit tests without structleak plugin
  thunderbolt: build kunit tests without structleak plugin
  mmc: sdhci-of-aspeed: build kunit tests without structleak plugin

 drivers/base/test/Makefile   | 2 +-
 drivers/iio/test/Makefile    | 1 +
 drivers/mmc/host/Makefile    | 1 +
 drivers/thunderbolt/Makefile | 1 +
 lib/Makefile                 | 2 +-
 scripts/Makefile.gcc-plugins | 4 ++++
 6 files changed, 9 insertions(+), 2 deletions(-)


base-commit: 316346243be6df12799c0b64b788e06bad97c30b

Comments

Arnd Bergmann Sept. 17, 2021, 7:38 a.m. UTC | #1
On Fri, Sep 17, 2021 at 8:10 AM Brendan Higgins
<brendanhiggins@google.com> wrote:
>
> The structleak plugin causes the stack frame size to grow immensely when
> used with KUnit; this is caused because KUnit allocates lots of
> moderately sized structs on the stack as part of its assertion macro
> implementation. For most tests with small to moderately sized tests
> cases there are never enough KUnit assertions to be an issue at all;
> even when a single test cases has many KUnit assertions, the compiler
> should never put all these struct allocations on the stack at the same
> time since the scope of the structs is so limited; however, the
> structleak plugin does not seem to respect the compiler doing the right
> thing and will still warn of excessive stack size in some cases.
>
> These patches are not a permanent solution since new tests can be added
> with huge test cases, but this serves as a stop gap to stop structleak
> from being used on KUnit tests which will currently result in excessive
> stack size.
>
> Of the following patches, I think the thunderbolt patch may be
> unnecessary since Linus already fixed that test. Additionally, I was not
> able to reproduce the error on the sdhci-of-aspeed test. Nevertheless, I
> included these tests cases for completeness. Please see my discussion
> with Arnd for more context[1].
>
> NOTE: Arnd did the legwork for most of these patches, but did not
> actually share code for some of them, so I left his Signed-off-by off of
> those patches as I don't want to misrepresent him. Arnd, please sign off
> on those patches at your soonest convenience.

Thanks a lot for picking up this work where I dropped the ball.

Patches 1-5 look good to me, and I replied on one remaining issue I see
with patch 6. I think you did more work on these that I did, by doing
a nice write-up and splitting them into separate patches with useful
changelogs, you should keep authorship, and just change my
S-o-b to Suggested-by.

If you prefer to keep me as the author, then the correct way would
be to commit them with --author= to ensure that the author and
first s-o-b match.

        Arnd
Brendan Higgins Sept. 29, 2021, 8:46 p.m. UTC | #2
On Fri, Sep 17, 2021 at 12:38 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Fri, Sep 17, 2021 at 8:10 AM Brendan Higgins
> <brendanhiggins@google.com> wrote:
> >
> > The structleak plugin causes the stack frame size to grow immensely when
> > used with KUnit; this is caused because KUnit allocates lots of
> > moderately sized structs on the stack as part of its assertion macro
> > implementation. For most tests with small to moderately sized tests
> > cases there are never enough KUnit assertions to be an issue at all;
> > even when a single test cases has many KUnit assertions, the compiler
> > should never put all these struct allocations on the stack at the same
> > time since the scope of the structs is so limited; however, the
> > structleak plugin does not seem to respect the compiler doing the right
> > thing and will still warn of excessive stack size in some cases.
> >
> > These patches are not a permanent solution since new tests can be added
> > with huge test cases, but this serves as a stop gap to stop structleak
> > from being used on KUnit tests which will currently result in excessive
> > stack size.
> >
> > Of the following patches, I think the thunderbolt patch may be
> > unnecessary since Linus already fixed that test. Additionally, I was not
> > able to reproduce the error on the sdhci-of-aspeed test. Nevertheless, I
> > included these tests cases for completeness. Please see my discussion
> > with Arnd for more context[1].
> >
> > NOTE: Arnd did the legwork for most of these patches, but did not
> > actually share code for some of them, so I left his Signed-off-by off of
> > those patches as I don't want to misrepresent him. Arnd, please sign off
> > on those patches at your soonest convenience.
>
> Thanks a lot for picking up this work where I dropped the ball.
>
> Patches 1-5 look good to me, and I replied on one remaining issue I see
> with patch 6. I think you did more work on these that I did, by doing
> a nice write-up and splitting them into separate patches with useful
> changelogs, you should keep authorship, and just change my
> S-o-b to Suggested-by.
>
> If you prefer to keep me as the author, then the correct way would
> be to commit them with --author= to ensure that the author and
> first s-o-b match.

Sounds good. I will keep the one that has you as the author since I
just rebased it, but I will move you to Suggested-by on the others.

Thanks!