The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: jim.cromie@gmail.com
Cc: John Ogness <john.ogness@linutronix.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Jason Baron <jbaron@akamai.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Jason A. Donenfeld" <Jason@zx2c4.com>,
	printk@lists.linux.dev, linux-kernel@vger.kernel.org,
	Philipp Hahn <phahn-oss@avm.de>
Subject: Re: [PATCH] printk.h: fix overzealous pr_fmt in pr_debug_ratelimited
Date: Thu, 26 Nov 2026 16:00:50 +0100	[thread overview]
Message-ID: <awhJooa6HkPoKqSH@pathway.suse.cz> (raw)
In-Reply-To: <20261125-pr-fmt-v1-1-3ff6832f5a50@gmail.com>

On Wed 2026-11-25 11:12:53, Jim Cromie via B4 Relay wrote:
> From: Jim Cromie <jim.cromie@gmail.com>
> 
> Historically, the CONFIG_DYNAMIC_DEBUG implementation of
> pr_debug_ratelimited() passed raw fmt to both metadata and runtime:
> 
>   DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);
>   if (unlikely(...) && __ratelimit(&_rs))
>      __dynamic_pr_debug(&descriptor, fmt, ##__VA_ARGS__);
> 
> While descriptor metadata was clean, emitted dmesg records lacked the
> pr_fmt prefix present in the !CONFIG_DYNAMIC_DEBUG fallbacks.
> 
> In 2015, commit 515a9adce0f0 ("include/linux/printk.h: include pr_fmt
> in pr_debug_ratelimited") fixed the missing prefix by wrapping fmt in
> __dynamic_pr_debug() with pr_fmt().  However, it also wrapped fmt in
> the metadata macro:
> 
>   DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, pr_fmt(fmt));
> 
> This causes two problems:
> 
>   1. Build failure when pr_fmt() expands to multiple arguments, e.g.:
>        #define pr_fmt(fmt) KBUILD_MODNAME ".%s " fmt, __func__
>      Passing pr_fmt(fmt) into DEFINE_DYNAMIC_DEBUG_METADATA() expands
>      across the comma in DEFINE_DYNAMIC_DEBUG_METADATA_CLS(), supplying
>      4 arguments where it takes 3.
> 
>   2. Metadata pollution even for single-argument pr_fmt(): baking the
>      prefix into .format breaks anchored queries such as:
>        echo format "^foo" > /proc/dynamic_debug/control
> 
> Drop the pr_fmt() wrapper from DEFINE_DYNAMIC_DEBUG_METADATA() in
> pr_debug_ratelimited(), restoring consistency with dynamic_pr_debug,
> dev_dbg_ratelimited, and net_dbg_ratelimited.  Update
> lib/test_dynamic_debug.c to exercise pr_fmt() with __func__ in
> pr_debug_ratelimited().
> 
> Reported-by: Philipp Hahn <phahn-oss@avm.de>
> Link: https://lore.kernel.org/lkml/a5e3c89fe5f4126873d58dd3472e66c56550ff91.1773779753.git.phahn-oss@avm.de/
> Fixes: 515a9adce0f0 ("include/linux/printk.h: include pr_fmt in pr_debug_ratelimited")
> Cc: Jason A. Donenfeld <Jason@zx2c4.com>
> Cc: Petr Mladek <pmladek@suse.com>
> Signed-off-by: Jim Cromie <jim.cromie@gmail.com>

Looks reasonable to me:

Reviewed-by: Petr Mladek <pmladek@suse.com>

Jim, should I take it via printk tree? Or would it be better to take
it via another three to avoid conflicts, please?

Best Regards,
Petr


      parent reply	other threads:[~2026-11-26 15:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 18:12 [PATCH] printk.h: fix overzealous pr_fmt in pr_debug_ratelimited Jim Cromie via B4 Relay
2026-11-26  9:17 ` John Ogness
2026-11-26 15:00 ` Petr Mladek [this message]

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=awhJooa6HkPoKqSH@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=Jason@zx2c4.com \
    --cc=akpm@linux-foundation.org \
    --cc=jbaron@akamai.com \
    --cc=jim.cromie@gmail.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phahn-oss@avm.de \
    --cc=printk@lists.linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.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