mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Hahn <phahn-oss@avm.de>
To: Jason Baron <jbaron@akamai.com>,
	Jim Cromie <jim.cromie@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: dyndbg: pr_fmt(fmt) with additional arguments?
Date: Fri, 27 Feb 2026 12:12:28 +0100	[thread overview]
Message-ID: <aaF8HEzg0iqnHPoJ@mail-auth.avm.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 957 bytes --]

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__

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

[-- Attachment #2: 0001-dyndbg-Ignore-additional-arguments-from-pr_fmt.quilt --]
[-- Type: text/plain, Size: 2306 bytes --]

From 545173a75e3928ec000b1127bfc99439b7fa2f8b Mon Sep 17 00:00:00 2001
Message-ID: <545173a75e3928ec000b1127bfc99439b7fa2f8b.1772186702.git.p.hahn@avm.de>
From: Philipp Hahn <phahn-oss@avm.de>
Date: Fri, 27 Feb 2026 10:53:04 +0100
Subject: [PATCH] dyndbg: Ignore additional arguments from pr_fmt
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: FRITZ! Technology GmbH, Berlin, Germany

pr_fmt can be used to add a common prefix to any output from a module:
	#define pr_fmt(fmt) KBUILD_MODNAME ".%s ", __func__

But adding additional arguments breaks dynamic debug:
> error: macro "DEFINE_DYNAMIC_DEBUG_METADATA_CLS" passed 4 arguments, but takes just 3
> |         pr_debug_ratelimited("%s", "Hello world!");
> |                                                  ^
> note: macro "DEFINE_DYNAMIC_DEBUG_METADATA_CLS" defined here
> | #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt)       \
> |
> error: ‘DEFINE_DYNAMIC_DEBUG_METADATA_CLS’ undeclared (first use in this function)
> |         DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, _DPRINTK_CLASS_DFLT, fmt)
> |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> note: in expansion of macro ‘DEFINE_DYNAMIC_DEBUG_METADATA’
> |         DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, pr_fmt(fmt));         \
> |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> note: in expansion of macro ‘pr_debug_ratelimited’
> |         pr_debug_ratelimited("%s", "Hello world!");
> |         ^~~~~~~~~~~~~~~~~~~~

Add an additional ', ...' to DEFINE_DYNAMIC_DEBUG_METADATA_CLS to slurp
any additional argument, which `pr_fmt` might add.

Signed-off-by: Philipp Hahn <phahn-oss@avm.de>
---
 include/linux/dynamic_debug.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 05743900a1169..0ac0df04bac00 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -167,7 +167,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
 		dump_stack();					\
 }
 
-#define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt)	\
+#define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt, ...)	\
 	static struct _ddebug  __aligned(8)			\
 	__section("__dyndbg") name = {				\
 		.modname = KBUILD_MODNAME,			\
-- 
2.43.0


             reply	other threads:[~2026-02-27 11:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-27 11:12 Philipp Hahn [this message]
2026-03-13 12:55 ` Philipp Hahn
2026-03-15 23:30 ` jim.cromie
2026-03-17 20:41   ` Philipp Hahn
2026-03-17 20:39 ` [PATCH v2] dyndbg: Ignore additional arguments from pr_fmt Philipp Hahn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aaF8HEzg0iqnHPoJ@mail-auth.avm.de \
    --to=phahn-oss@avm.de \
    --cc=jbaron@akamai.com \
    --cc=jim.cromie@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome