[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YjStnb7nNTC3kYw6@alley>
Date: Fri, 18 Mar 2022 17:04:45 +0100
From: Petr Mladek <pmladek@...e.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Miguel Ojeda <ojeda@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
Gary Guo <gary@...yguo.net>,
Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...gle.com>,
Steven Rostedt <rostedt@...dmis.org>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Rasmus Villemoes <linux@...musvillemoes.dk>
Subject: Re: [PATCH v5 12/20] vsprintf: add new `%pA` format specifier
On Fri 2022-03-18 16:07:31, Andy Shevchenko wrote:
> On Thu, Mar 17, 2022 at 07:10:00PM +0100, Miguel Ojeda wrote:
> > From: Gary Guo <gary@...yguo.net>
> >
> > This patch adds a format specifier `%pA` to `vsprintf` which formats
> > a pointer as `core::fmt::Arguments`. Doing so allows us to directly
> > format to the internal buffer of `printf`, so we do not have to use
> > a temporary buffer on the stack to pre-assemble the message on
> > the Rust side.
> >
> > This specifier is intended only to be used from Rust and not for C, so
> > `checkpatch.pl` is intentionally unchanged to catch any misuse.
>
> ...
>
> > + case 'A':
> > + if (!IS_ENABLED(CONFIG_RUST)) {
> > + WARN_ONCE(1, "Please remove %%pA from non-Rust code\n");
> > + return error_string(buf, end, "(%pA?)", spec);
> > + }
>
> I'm wondering if the Big Scary Banner as trace_printk() does would be better
> (in case we can tell that %pA is used in the code when RUST=n).
Good question!
The advantage of WARN_ONCE() is that it shows the stack so that it is
easier to locate the caller.
On the other hand, WARN_ONCE() is a bit misused here. It should be
used only in situations that might be potentially fatal. It might
even cause panic() with "panic_on_warn" kernel parameter.
Well, I am not sure if it is worth huge effort. WARN_ONCE() is
practical in this case because of the backtrace. We could always
create something better if people hit it more frequently and
it causes real life problems.
Best Regards,
Petr
Powered by blists - more mailing lists