linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] kunit: further reduce stack usage of asserts
@ 2022-01-25 21:00 Daniel Latypov
  2022-01-25 21:00 ` [PATCH 1/3] kunit: remove va_format from kunit_assert Daniel Latypov
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Daniel Latypov @ 2022-01-25 21:00 UTC (permalink / raw)
  To: brendanhiggins, davidgow
  Cc: linux-kernel, kunit-dev, linux-kselftest, skhan, Daniel Latypov

If the compiler doesn't optimize them away, each kunit assertion (use of
KUNIT_EXPECT_EQ, etc.) can use 88 bytes of stack space in the worst and
most common case. This has led to compiler warnings for certain configs
+ arches [1].

This series builds upon [2] which cut down kunit_assert from 48 => 24
bytes, but only reduced kunit_binary_assert (the most common one) from
88 => 48.

Now we have kunit_assert = 8 and kunit_binary_assert = 32.
The cost is we need to pass around another parameter to some functions
(struct va_format *), and we introduce a new type
(sturct kunit_binary_assert_text) for holding the textual representation
of the KUNIT_EXPECT_EQ arguments.

Note: it's possible to get kunit_assert = 0 and kunit_binary_assert =
24 by removing the `format` function pointer field from kunit_assert.
I think it's an improvement, but others might think that readability
suffers from doing so, so I'm leaving that off from this series.

Meta: this series applies on top of 5.17-rc1 + [2] and [3].
That should be available at in Shuah's kunit branch [4], but my version
of git is constantly segfaulting, so I can't try and rebase to verify.

[1] https://groups.google.com/g/kunit-dev/c/i3fZXgvBrfA/m/VULQg1z6BAAJ
[2] https://lore.kernel.org/linux-kselftest/20220113165931.451305-6-dlatypov@google.com/
[3] https://lore.kernel.org/linux-kselftest/20220118223506.1701553-1-dlatypov@google.com/
[4] https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/?h=kunit 

Daniel Latypov (3):
  kunit: remove va_format from kunit_assert
  kunit: consolidate KUNIT_INIT_BINARY_ASSERT_STRUCT macros
  kunit: factor out str constants from binary assertion structs

 include/kunit/assert.h | 152 ++++++++++++-----------------------------
 include/kunit/test.h   |  32 +++++----
 lib/kunit/assert.c     |  65 ++++++++++--------
 lib/kunit/test.c       |  12 ++--
 4 files changed, 104 insertions(+), 157 deletions(-)

-- 
2.35.0.rc2.247.g8bbb082509-goog


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-01-27 21:47 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25 21:00 [PATCH 0/3] kunit: further reduce stack usage of asserts Daniel Latypov
2022-01-25 21:00 ` [PATCH 1/3] kunit: remove va_format from kunit_assert Daniel Latypov
2022-01-27  3:34   ` David Gow
2022-01-27 21:22   ` Brendan Higgins
2022-01-25 21:00 ` [PATCH 2/3] kunit: consolidate KUNIT_INIT_BINARY_ASSERT_STRUCT macros Daniel Latypov
2022-01-27  3:36   ` David Gow
2022-01-27  3:37     ` David Gow
2022-01-27 21:31   ` Brendan Higgins
2022-01-25 21:00 ` [PATCH 3/3] kunit: factor out str constants from binary assertion structs Daniel Latypov
2022-01-27  3:39   ` David Gow
2022-01-27 20:21     ` Daniel Latypov
2022-01-27 20:27       ` Daniel Latypov
2022-01-27 21:47     ` Brendan Higgins
2022-01-27 21:46   ` Brendan Higgins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).