Re: [PATCH v4 02/14] kunit: bug: Count suppressed warning backtraces

David Gow <[email protected]>
Newsgroups gmane.linux.ports.ppc64.devel,gmane.comp.video.dri.devel,gmane.linux.kernel.cross-arch,gmane.linux.ports.arm.kernel,gmane.linux.documentation,gmane.linux.kernel,gmane.linux.ports.parisc,gmane.linux.ports.riscv,gmane.linux.ports.sh.devel
Message-ID <CABVgOS=zNx18SJK1oQkZOpN14-H8QsH=08rsAWjwgRizuwaz8w@mail.gmail.com>
On Thu, 13 Mar 2025 at 19:44, Alessandro Carminati <[email protected]> wrote:
>
> From: Guenter Roeck <[email protected]>
>
> Count suppressed warning backtraces to enable code which suppresses
> warning backtraces to check if the expected backtrace(s) have been
> observed.
>
> Using atomics for the backtrace count resulted in build errors on some
> architectures due to include file recursion, so use a plain integer
> for now.
>
> Acked-by: Dan Carpenter <[email protected]>
> Reviewed-by: Kees Cook <[email protected]>
> Tested-by: Linux Kernel Functional Testing <[email protected]>
> Signed-off-by: Guenter Roeck <[email protected]>
> Reviewed-by: David Gow <[email protected]>
> Signed-off-by: Alessandro Carminati <[email protected]>
> ---

Looks good. I'd definitely prefer the atomics to work one day, but I
doubt we're likely to have backtraces from multiple threads happening
in a KUnit test, so it's definitely not urgent.

Reviewed-by: David Gow <[email protected]>

Cheers,
-- David


>  include/kunit/bug.h | 7 ++++++-
>  lib/kunit/bug.c     | 4 +++-
>  2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/include/kunit/bug.h b/include/kunit/bug.h
> index 0a8e62c1fcaf..44efa7d5c902 100644
> --- a/include/kunit/bug.h
> +++ b/include/kunit/bug.h
> @@ -20,6 +20,7 @@
>  struct __suppressed_warning {
>         struct list_head node;
>         const char *function;
> +       int counter;
>  };
>
>  void __kunit_start_suppress_warning(struct __suppressed_warning *warning);
> @@ -28,7 +29,7 @@ bool __kunit_is_suppressed_warning(const char *function);
>
>  #define DEFINE_SUPPRESSED_WARNING(func)        \
>         struct __suppressed_warning __kunit_suppress_##func = \
> -               { .function = __stringify(func) }
> +               { .function = __stringify(func), .counter = 0 }
>
>  #define KUNIT_START_SUPPRESSED_WARNING(func) \
>         __kunit_start_suppress_warning(&__kunit_suppress_##func)
> @@ -39,12 +40,16 @@ bool __kunit_is_suppressed_warning(const char *function);
>  #define KUNIT_IS_SUPPRESSED_WARNING(func) \
>         __kunit_is_suppressed_warning(func)
>
> +#define SUPPRESSED_WARNING_COUNT(func) \
> +       (__kunit_suppress_##func.counter)
> +
>  #else /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */
>
>  #define DEFINE_SUPPRESSED_WARNING(func)
>  #define KUNIT_START_SUPPRESSED_WARNING(func)
>  #define KUNIT_END_SUPPRESSED_WARNING(func)
>  #define KUNIT_IS_SUPPRESSED_WARNING(func) (false)
> +#define SUPPRESSED_WARNING_COUNT(func) (0)
>
>  #endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */
>  #endif /* __ASSEMBLY__ */
> diff --git a/lib/kunit/bug.c b/lib/kunit/bug.c
> index 351f9a595a71..84c05b1a9e8b 100644
> --- a/lib/kunit/bug.c
> +++ b/lib/kunit/bug.c
> @@ -32,8 +32,10 @@ bool __kunit_is_suppressed_warning(const char *function)
>                 return false;
>
>         list_for_each_entry(warning, &suppressed_warnings, node) {
> -               if (!strcmp(function, warning->function))
> +               if (!strcmp(function, warning->function)) {
> +                       warning->counter++;
>                         return true;
> +               }
>         }
>         return false;
>  }
> --
> 2.34.1
>
smime.p7s (application/pkcs7-signature, 5.2 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.