From: Steven Rostedt <rostedt@goodmis.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Jiri Kosina <jkosina@suse.cz>, Petr Mladek <pmladek@suse.cz>
Subject: Re: [GIT PULL] tracing/NMI/printk: Use seq_buf for safe printing from NMI context
Date: Thu, 11 Dec 2014 06:33:07 -0500 [thread overview]
Message-ID: <20141211063307.6f429b78@gandalf.local.home> (raw)
In-Reply-To: <CA+55aFz5-_LKW4JHEBoWinN9_ouNcGRWAF2FUA35u46FRN-Kxw@mail.gmail.com>
On Wed, 10 Dec 2014 21:29:40 -0800
Linus Torvalds <torvalds@linux-foundation.org> wrote:
> On Wed, Dec 10, 2014 at 8:20 PM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > Would it perhaps be possible/reasonable to also use this to get rid of
> > the horrible "early_printk()" stuff [...]
>
> Another question: the "preempt_disable/enable()" around the use of the
> per-cpu vprintk_func thing seems dubious.
>
> Why do I say that? I think it cannot possibly make sense. Anybody who
> sets that function pointer to any per-cpu value has to disable
> preemption for that to make sense, so doing it inside the printk()
> paths seems dubious at best.
>
> No?
So you are saying that anytime the printk_func is not the default, the
caller had to have disable preemption? Even if the caller changes all
per cpu calls, it is probably still safe as other cpus will be either
using the default or the one that is going to be the "default" (I say
that as being global).
Thus something like this?
-- Steve
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 5af2b8bc88f0..9b896e7a50a9 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1859,10 +1859,16 @@ asmlinkage __visible int printk(const char *fmt, ...)
int r;
va_start(args, fmt);
- preempt_disable();
+
+ /*
+ * If a caller overrides the per_cpu printk_func, then it needs
+ * to disable preemption when calling printk(). Otherwise
+ * the printk_func should be set to the default. No need to
+ * disable preemption here.
+ */
vprintk_func = this_cpu_read(printk_func);
r = vprintk_func(fmt, args);
- preempt_enable();
+
va_end(args);
return r;
next prev parent reply other threads:[~2014-12-11 11:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-08 15:05 Steven Rostedt
2014-12-08 15:08 ` Steven Rostedt
2014-12-11 4:20 ` Linus Torvalds
2014-12-11 5:29 ` Linus Torvalds
2014-12-11 11:33 ` Steven Rostedt [this message]
2014-12-11 19:41 ` Linus Torvalds
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=20141211063307.6f429b78@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=pmladek@suse.cz \
--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
all inboxes | Powered by JetHome®