From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: "Rob Herring (Arm)" <robh@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Jonathan Corbet <corbet@lwn.net>,
Saravana Kannan <saravanak@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Zijun Hu <quic_zijuhu@quicinc.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: lock in vsprintf(): was: Re: [PATCH] of: Add printf '%pOFm' for generating modalias
Date: Thu, 19 Dec 2024 16:05:49 +0100 [thread overview]
Message-ID: <Z2Q2TcM6QPUIIyLC@pathway.suse.cz> (raw)
In-Reply-To: <84wmfxm6em.fsf@jogness.linutronix.de>
On Wed 2024-12-18 15:13:13, John Ogness wrote:
> On 2024-12-18, Petr Mladek <pmladek@suse.com> wrote:
> > My concern is taking a lock when processing a printf format, see
> > below for more details.
>
> Your concern is valid! printk() uses vsnprintf() to format records for
> the kernel log. printk() may be called from contexts where locking is
> forbidden (such as NMI). If vsnprintf() can take a lock, then either:
>
> vsnprintf() must be made to be lockless
>
> or
>
> printk() must take another approach to string formatting
There were the ideas to introduce a %pX[1] or %pf[2] formats. They would
allow to pass pointer to a custom callback and parameters which
then would be used by vsprintf(). This might allow to make it more
obvious that the given vsprintf()/printk() might do some locking.
> or
>
> we accept that printk() can deadlock for certain format types in certain
> contexts.
I see that %pOFm does not add any new locking dependency.
The same lock (devtree_lock) is already taken, for example,
by %pOFC format.
I do not want to revert everything now just because of theoretical
problems. It somehow works because people use these formats only
in dedicated subsystems. Also lockdep is able to catch a lot of
problems.
Well, it would be nice to document the lock dependency in
Documentation/core-api/printk-formats.rst
Best Regards,
Petr
next prev parent reply other threads:[~2024-12-19 15:05 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-17 18:37 [PATCH] of: Add printf '%pOFm' for generating modalias Rob Herring (Arm)
2024-12-18 2:21 ` quic_zijuhu
2024-12-18 10:16 ` Rasmus Villemoes
2024-12-18 15:28 ` Rob Herring
2024-12-18 11:35 ` ssize_t: was: " Petr Mladek
2024-12-18 17:10 ` Rob Herring
2024-12-19 14:44 ` Petr Mladek
2024-12-18 12:27 ` lock in vsprintf(): " Petr Mladek
2024-12-18 14:07 ` John Ogness
2024-12-19 15:05 ` Petr Mladek [this message]
2024-12-19 19:11 ` John Ogness
2024-12-20 8:01 ` Petr Mladek
2024-12-30 20:26 ` Rob Herring
2025-01-02 13:06 ` Petr Mladek
2025-01-02 14:02 ` John Ogness
2024-12-18 16:29 ` Rob Herring
2024-12-18 16:31 ` Steven Rostedt
2024-12-23 19:58 ` Andy Shevchenko
2024-12-30 20:52 ` Rob Herring
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=Z2Q2TcM6QPUIIyLC@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=john.ogness@linutronix.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=peterz@infradead.org \
--cc=quic_zijuhu@quicinc.com \
--cc=robh@kernel.org \
--cc=rostedt@goodmis.org \
--cc=saravanak@google.com \
--cc=senozhatsky@chromium.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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).