From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Peter Zijlstra <peterz@infradead.org>,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
linux-kernel@vger.kernel.org, "4 . 13+" <stable@vger.kernel.org>
Subject: Re: [PATCH] printk/nmi: Prevent deadlock when serializing NMI backtraces
Date: Mon, 18 Jun 2018 19:07:18 +0900 [thread overview]
Message-ID: <20180618100718.GA555@jagdpanzerIV> (raw)
In-Reply-To: <20180618093917.qeaatnlqh5if6t3r@pathway.suse.cz>
On (06/18/18 11:39), Petr Mladek wrote:
[..]
> > > extern void printk_nmi_enter(void);
> > > extern void printk_nmi_exit(void);
> > > +extern void printk_nmi_direct_enter(void);
> > > +extern void printk_nmi_direct_exit(void);
> > > #else
> > > static inline void printk_nmi_enter(void) { }
> > > static inline void printk_nmi_exit(void) { }
> > > +static void printk_nmi_direct_enter(void) { }
> > > +static void printk_nmi_direct_exit(void) { }
> >
> > Can we have better names may be? Since direct printk_nmi is not
> > in fact always `direct'.
>
> What about printk_chatty_nmi_enter(), printk_large_nmi_enter()
> or something similar?
Hmm. Can't answer right now :)
> > > +#ifdef CONFIG_PRINTK_NMI
> > > +__printf(1, 0) int vprintk_nmi(const char *fmt, va_list args);
> > > +#else
> > > +__printf(1, 0) int vprintk_nmi(const char *fmt, va_list args) { return 0; }
> > > +#endif
> >
> > Hmm, printk_safe.c knows about printk.c, printk.c knows about
> > printk_safe.c.
>
> I am sorry but I do not understand the problem. The function is
> defined in printk_safe.c and we need to call it also from printk.c.
> It seems reasonable to declare it in kernel/printk/internal.h.
Just wanted to suggest to keep printk_safe/printk_nmi stuff in printk_safe.c.
We already have everything we need there, so let's just add the vprintk_nmi()
fallback, avoiding spreading printk_safe/printk_nmi logic and details across
printk.c and printk_safe.c
> > OK... Can we do this in vprintk_func()? The race window should be super
> > tiny [if matters at all], but in exchange we don't have to mix nmi, printk,
> > printk_mni, etc.
>
> You are right that it would still solve the main risk (NMI comes
> inside logbuf_lock critical section).
>
> In fact, the only real risk would be another lock serializing NMIs
> and printk() called with that lock. This patch removes one in
> nmi_backtrace() and I am not aware of any other.
>
> The less hairy code really might be worth the rather theoretical risk.
>
> > So over all I understand why you did it this way. May be I'd prefer to
> > have less universal but shorter solution (e.g. modify only nmi_backtrace
> > function and put there "printk_nmi_restricted_buffer"), but I won't really
> > object your patch [unless I see some real issues with it].
>
> Thanks in advance. I'll send v2 once we have a conclusion on
> the function names and includes.
Does this mean that we agreed to handle the printk_nmi per-CPU buffer
fallback in printk_safe.c?
-ss
next prev parent reply other threads:[~2018-06-18 10:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-17 14:39 [PATCH] printk/nmi: Prevent deadlock when serializing NMI backtraces Petr Mladek
2018-05-18 2:07 ` Sergey Senozhatsky
2018-05-18 6:38 ` Sergey Senozhatsky
2018-05-18 8:10 ` Petr Mladek
2018-05-22 21:43 ` Steven Rostedt
2018-05-23 2:01 ` Sergey Senozhatsky
2018-05-28 12:27 ` Petr Mladek
2018-06-05 12:47 ` Petr Mladek
2018-06-06 5:10 ` Sergey Senozhatsky
2018-06-06 10:33 ` Sergey Senozhatsky
2018-06-08 10:48 ` Petr Mladek
2018-06-18 6:37 ` Sergey Senozhatsky
2018-06-18 9:39 ` Petr Mladek
2018-06-18 10:07 ` Sergey Senozhatsky [this message]
2018-06-19 7:52 ` Petr Mladek
2018-06-19 8:27 ` Sergey Senozhatsky
2018-06-19 13:23 ` Steven Rostedt
2018-06-20 1:58 ` Sergey Senozhatsky
2018-06-20 2:32 ` Steven Rostedt
2018-06-20 4:17 ` Sergey Senozhatsky
2018-06-06 11:15 ` Petr Mladek
2018-06-07 5:40 ` Sergey Senozhatsky
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=20180618100718.GA555@jagdpanzerIV \
--to=sergey.senozhatsky.work@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=stable@vger.kernel.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).