mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jim Cromie via B4 Relay <devnull+jim.cromie.gmail.com@kernel.org>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	 David Airlie <airlied@gmail.com>,
	Simona Vetter <simona@ffwll.ch>,  Jason Baron <jbaron@akamai.com>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	 Luca Coelho <luciano.coelho@intel.com>,
	Jani Nikula <jani.nikula@intel.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	 Jim Cromie <jim.cromie@gmail.com>
Subject: [PATCH v4 3/3] drm/print: fix drm_printer dynamic debug bit-test bypass
Date: Tue, 24 Nov 2026 16:38:35 -0700	[thread overview]
Message-ID: <20261124-rd-mostly-v4-3-26d60beb6666@gmail.com> (raw)
In-Reply-To: <20261124-rd-mostly-v4-0-26d60beb6666@gmail.com>

From: Jim Cromie <jim.cromie@gmail.com>

drm_debug_enabled() [$1] is the canonical bit-test for drm.debug.
Commit 6ce6fae84536 ("drm_print: optimize drm_debug_enabled for
jump-label") elaborated it into 4 names, controlled by
CONFIG_DRM_USE_DYNAMIC_DEBUG:

A- $1_raw() - rename of the original bit-test.
B- $1_instrumented() - like raw, but adds a pr_debug(), allowing us to
   count callsite frequency and consider optimizing them later.
C- __$1() - evaluates to 'true' when CONFIG_DRM_USE_DYNAMIC_DEBUG=y
   (avoiding the bit-test where callsites are already guarded by a
   dyndbg static-key), and forwards to A when =n.
D- $1() - forwards to B when CONFIG_DRM_USE_DYNAMIC_DEBUG=y, and to A
   when =n, for cases where an explicit bit-mask check is required.

Later, commit 9fd6f61a297e ("drm/print: add drm_dbg_printer() for drm
device specific printer") added a general-use __drm_printfn_dbg()
function, but used __$1() instead of $1(). When
CONFIG_DRM_USE_DYNAMIC_DEBUG=y, __$1() evaluates to 'true' and always
prints.  This went unnoticed because CONFIG_DRM_USE_DYNAMIC_DEBUG was
marked BROKEN.

With =y, this results in a flood of messages, and in CI-tests on slow
serial consoles, creates bottlenecks, as seen in DRM-CI on i915 CML
devices.  When IGT causes a mismatch in intel_pipe_config_compare(),
the resulting UART storm causes a hard timeout after 20 minutes.

NOTES:

Drop the single-use `category` local variable and pass p->category
directly (which previously also triggered an unused-variable warning
under the old __$1() bypass).

Because __drm_printfn_dbg() is a shared helper invoked via p->printfn
with a runtime p->category, the callsite cannot be guarded by a
static-key; we'd need a macro version and callsites where category is
a compile-time constant.

Replacing __$1() with $1() or $1_raw() would also work, but
$1_instrumented() adds the pr_debug() in both =y and =n configs; when
enabled it can provide call-freq data to inform further callsite
optimization choices.

Fixes: 9fd6f61a297e ("drm/print: add drm_dbg_printer() for drm device specific printer")
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 drivers/gpu/drm/drm_print.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
index 2e7685849f44..3d26483975f2 100644
--- a/drivers/gpu/drm/drm_print.c
+++ b/drivers/gpu/drm/drm_print.c
@@ -218,9 +218,8 @@ void __drm_printfn_dbg(struct drm_printer *p, struct va_format *vaf)
 {
 	const struct drm_device *drm = p->arg;
 	const struct device *dev = drm ? drm->dev : NULL;
-	enum drm_debug_category category = p->category;
 
-	if (!__drm_debug_enabled(category))
+	if (!drm_debug_enabled_instrumented(p->category))
 		return;
 
 	__drm_dev_vprintk(dev, KERN_DEBUG, p->origin, p->prefix, vaf);

-- 
2.56.1



      parent reply	other threads:[~2026-11-24 23:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 23:38 [PATCH v4 0/3] drm/print,dyndbg: __drm_debug __read_mostly, restore it to uint, printer fix Jim Cromie via B4 Relay
2026-11-24 23:38 ` [PATCH v4 1/3] drm/print: Mark __drm_debug as __read_mostly Jim Cromie via B4 Relay
2026-11-24 23:38 ` [PATCH v4 2/3] drm/print,dyndbg: restore __drm_debug to uint from ulong Jim Cromie via B4 Relay
2026-11-24 23:38 ` Jim Cromie via B4 Relay [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=20261124-rd-mostly-v4-3-26d60beb6666@gmail.com \
    --to=devnull+jim.cromie.gmail.com@kernel.org \
    --cc=airlied@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jani.nikula@intel.com \
    --cc=jbaron@akamai.com \
    --cc=jim.cromie@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luciano.coelho@intel.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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

all inboxes | Powered by JetHome®