From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Jani Nikula <jani.nikula@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
intel-gfx@lists.freedesktop.org, Petr Mladek <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 01/12] drm/i915: Indicate which pipe failed the fastset check overall
Date: Tue, 27 Feb 2024 20:32:12 +0200 [thread overview]
Message-ID: <Zd4qrLVWcacza747@intel.com> (raw)
In-Reply-To: <1013ff2d-76b2-41f9-a5d4-39a567a3b0cc@rasmusvillemoes.dk>
On Tue, Feb 27, 2024 at 10:38:10AM +0100, Rasmus Villemoes wrote:
> On 26/02/2024 15.57, Jani Nikula wrote:
>
> > Personally I suck at remembering even the standard printf conversion
> > specifiers, let alone all the kernel extensions. I basically have to
> > look them up every time. I'd really love some %{name} format for named
> > pointer things. And indeed preferrably without the %p. Just %{name}.
>
> Sorry to spoil the fun, but that's a non-starter.
>
> foo.c: In function ‘foo’:
> foo.c:5:24: warning: unknown conversion type character ‘{’ in format
> [-Wformat=]
> 5 | printf("Hello %{function} World\n", &foo);
> | ^
>
> You can't start accepting stuff that -Wformat will warn about. We're not
> going to start building with Wno-format.
Are there any sensible looking characters we could use for
this? Ideally I'd like to have something to bracket the
outsides, and perhaps a namespace separator in the middle.
Or are we really forced into having essentially a random set
of characters following just a %p/etc.?
>
> > And then we could discuss adding support for drm specific things. I
> > guess one downside is that the functions to do this would have to be in
> > vsprintf.c instead of drm. Unless we add some code in drm for this
> > that's always built-in.
>
> If people can be trusted to write callbacks with the proper semantics
> for snprintf [1], we could do a generic
Yeah, I was at some point thinking that having a version of
register_printf_function() for printk() might be nice. The dangers
being that we get conflicts between subsystems (*), or that it gets
totally out of hand, or as you point out below people will start
to do questionable things in there.
(*) My earlier "include a subsystem namespace in the format"
idea was basically how I was thinking of avoiding conflicts.
>
> typedef char * (*printf_callback)(char *buf, char *end, void *ctx);
>
> struct printf_ext {
> printf_callback cb;
> void *ctx;
> };
>
> #define PRINTF_EXT(callback, context) &(struct printf_ext){ .cb =
> callback, .ctx = context }
>
> // in drm-land
>
> char* my_drm_gizmo_formatter(char *buf, char *end, void *ctx)
> {
> struct drm_gizmo *dg = ctx;
> ....
> return buf;
> }
> #define pX_gizmo(dg) PRINTF_EXT(my_drm_gizmo_formatter, dg)
>
> printk("error: gizmo %pX in wrong state!\n", pX_gizmo(dg));
>
> Then vsprintf.c doesn't need to know anything about any particular
> subsystem. And if a subsystem breaks snprintf semantics, they get to
> keep the pieces. With a little more macro magic, one might even be able
> to throw in some type safety checks.
>
> Rasmus
>
> [1] You can't sleep, you can't allocate memory, you probably can't even
> take any raw spinlocks, you must attempt to do the full formatting so
> you can tell how much room would be needed, but you must of course not
> write anything beyond end. Calling vsnprintf() to format various integer
> members is probably ok, but recursively using %pX to print full
> subobjects is likely a bad idea.
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2024-02-27 18:32 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 16:40 [PATCH 00/12] drm/i915: Use drm_printer more Ville Syrjala
2024-02-15 16:40 ` [PATCH 01/12] drm/i915: Indicate which pipe failed the fastset check overall Ville Syrjala
2024-02-22 21:46 ` Rodrigo Vivi
2024-02-23 19:47 ` Ville Syrjälä
2024-02-26 14:57 ` Jani Nikula
2024-02-26 15:10 ` Andy Shevchenko
2024-02-26 15:35 ` Jani Nikula
2024-02-26 16:30 ` Andy Shevchenko
2024-02-26 16:35 ` Ville Syrjälä
2024-02-27 9:38 ` Rasmus Villemoes
2024-02-27 18:32 ` Ville Syrjälä [this message]
2024-02-28 8:32 ` Rasmus Villemoes
2024-02-28 9:55 ` Petr Mladek
2024-02-15 16:40 ` [PATCH 02/12] drm/i915: Include CRTC info in infoframe mismatch prints Ville Syrjala
2024-02-22 21:47 ` Rodrigo Vivi
2024-02-23 19:50 ` Ville Syrjälä
2024-02-15 16:40 ` [PATCH 03/12] drm/i915: Include CRTC info in VSC SDP " Ville Syrjala
2024-02-22 21:48 ` Rodrigo Vivi
2024-02-15 16:40 ` [PATCH 04/12] drm/i915: Convert pipe_config_infoframe_mismatch() to drm_printer Ville Syrjala
2024-02-22 21:50 ` Rodrigo Vivi
2024-02-15 16:40 ` [PATCH 05/12] drm/i915: Convert pipe_config_buffer_mismatch() " Ville Syrjala
2024-02-22 21:51 ` Rodrigo Vivi
2024-02-15 16:40 ` [PATCH 06/12] drm/i915: Convert intel_dpll_dump_hw_state() " Ville Syrjala
2024-02-22 21:54 ` Rodrigo Vivi
2024-02-23 19:57 ` Ville Syrjälä
2024-02-29 18:40 ` [PATCH v2 " Ville Syrjala
2024-02-29 19:43 ` Jani Nikula
2024-02-15 16:40 ` [PATCH 07/12] drm/i915: Use drm_printer more extensively in intel_crtc_state_dump() Ville Syrjala
2024-02-22 21:57 ` Rodrigo Vivi
2024-02-23 19:59 ` Ville Syrjälä
2024-02-15 16:40 ` [PATCH 08/12] drm/i915: Convert the remaining state dump to drm_printer Ville Syrjala
2024-03-05 9:12 ` Jani Nikula
2024-02-15 16:40 ` [PATCH 09/12] drm/i915: Skip intel_crtc_state_dump() if debugs aren't enabled Ville Syrjala
2024-02-29 15:20 ` Jani Nikula
2024-02-29 15:21 ` Jani Nikula
2024-02-15 16:40 ` [PATCH 10/12] drm/i915: Relocate pipe_config_mismatch() Ville Syrjala
2024-02-29 15:21 ` Jani Nikula
2024-02-15 16:40 ` [PATCH 11/12] drm/i915: Reuse pipe_config_mismatch() more Ville Syrjala
2024-02-29 15:28 ` Jani Nikula
2024-02-29 18:42 ` [PATCH v2 " Ville Syrjala
2024-02-15 16:40 ` [PATCH 12/12] drm/i915: Create the printer only once in intel_pipe_config_compare() Ville Syrjala
2024-02-29 15:29 ` Jani Nikula
2024-02-29 18:42 ` [PATCH v2 " Ville Syrjala
2024-02-16 18:03 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use drm_printer more Patchwork
2024-02-16 18:03 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-02-16 18:15 ` ✓ Fi.CI.BAT: success " Patchwork
2024-02-17 7:24 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-02-29 12:08 ` [PATCH 00/12] " Jani Nikula
2024-02-29 23:02 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use drm_printer more (rev4) Patchwork
2024-02-29 23:02 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-02-29 23:19 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-03-05 21:28 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use drm_printer more (rev5) Patchwork
2024-03-05 21:28 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-03-05 21:46 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-03-06 12:07 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use drm_printer more (rev6) Patchwork
2024-03-06 12:07 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-03-06 12:13 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-03-08 8:37 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use drm_printer more (rev7) Patchwork
2024-03-08 8:37 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-03-08 8:52 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-03-13 19:41 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use drm_printer more (rev8) Patchwork
2024-03-13 19:41 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-03-13 19:54 ` ✓ Fi.CI.BAT: success " Patchwork
2024-03-14 2:49 ` ✗ Fi.CI.IGT: failure " Patchwork
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=Zd4qrLVWcacza747@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=pmladek@suse.com \
--cc=rodrigo.vivi@intel.com \
--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;
as well as URLs for NNTP newsgroup(s).