Re: dyndbg: pr_fmt(fmt) with additional arguments?

From: jim . cromie

Date: Sun Mar 15 2026 - 19:31:19 EST


On Fri, Feb 27, 2026 at 4:12 AM Philipp Hahn <phahn-oss@xxxxxx> wrote:
>
> Hello Jason, hello Jim,
>
> I've been using the following in my modules to prefix all messages with
> the module and function name:
> #define pr_fmt(fmt) KBUILD_MODNAME ".%s ", __func__

Your example loses the fmt, so is not actually useful.

but that said, the compile err is real, I hit it once I changed

1 - the pr_debug("exited") call in test_dynamic_debug.c
to pr_debug_ratelimited.

2- the pr_fmt in same:
#if defined(TEST_DYNAMIC_DEBUG_SUBMOD)
- #define pr_fmt(fmt) "test_dd_submod: " fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME " test_dd_submod: %s" fmt, __func__

2 was my test-case, on my latest branch, yours (on master) will be different.

please add that test to your patch, and my
Acked-by: Jim Cromie <jim.cromie@xxxxxxxxx>

>
> This worked nicely until `pr_debug_ratelimit()` is used: The additional
> arguments breaks `DEFINE_DYNAMIC_DEBUG_METADATA_CLS`:
>
> #define pr_debug_ratelimited(fmt, ...) \
> DEFINE_DYNAMIC_DEBUG_METADATA(…, pr_fmt(fmt)); \
>
> #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
> DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, …, fmt)
>
> #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \
> static struct _ddebug __aligned(8) \
> __section("__dyndbg") name = { \
> … \
> .format = (fmt), \
>
> This could be fixed easily by adding an additional '...' to it to slurp
> any additional argument which `pr_fmt` might add.
>
> Would this be okay or do I miss something?
>
> For testing I have recompiled current 7.0.0-rc1 for x86_64 with no
> compile failures.
>
> Philipp Hahn

I tried this locally, it built and ran w/o errors.

Ackd-by: Jim Cromie <jim.cromie@xxxxxxxxx>