From: Peter Zijlstra <peterz@infradead.org>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Petr Mladek <pmladek@suse.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Jan Kara <jack@suse.cz>, Tejun Heo <tj@kernel.org>,
Calvin Owens <calvinowens@fb.com>,
Thomas Gleixner <tglx@linutronix.de>,
Mel Gorman <mgorman@techsingularity.net>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] early_printk: Add simple serialization to early_vprintk()
Date: Tue, 18 Oct 2016 19:08:33 +0200 [thread overview]
Message-ID: <20161018171513.734367391@infradead.org> (raw)
In-Reply-To: <20161018170830.405990950@infradead.org>
[-- Attachment #1: peterz-early_printk-serialize.patch --]
[-- Type: text/plain, Size: 978 bytes --]
In order to avoid multiple CPUs banging on the serial port at the same
time, add simple serialization. This explicitly deals with nested
contexts (like IRQs etc.).
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/printk/printk.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -356,14 +356,28 @@ static int __init force_early_printk_set
}
early_param("force_early_printk", force_early_printk_setup);
+static int early_printk_cpu = -1;
+
static int early_vprintk(const char *fmt, va_list args)
{
+ int n, cpu, old;
char buf[512];
- int n;
+
+ cpu = get_cpu();
+ for (;;) {
+ old = cmpxchg(&early_printk_cpu, -1, cpu);
+ if (old == -1 || old == cpu)
+ break;
+
+ cpu_relax();
+ }
n = vscnprintf(buf, sizeof(buf), fmt, args);
early_console->write(early_console, buf, n);
+ smp_store_release(&early_printk_cpu, old);
+ put_cpu();
+
return n;
}
next prev parent reply other threads:[~2016-10-18 17:16 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-18 17:08 [PATCH 0/3] make printk work again Peter Zijlstra
2016-10-18 17:08 ` [PATCH 1/3] printk: Fix kdb_trap_printk placement Peter Zijlstra
2016-10-19 14:41 ` Petr Mladek
2016-10-19 15:18 ` Peter Zijlstra
2016-10-20 13:02 ` Sergey Senozhatsky
2016-11-29 13:54 ` Petr Mladek
2016-10-18 17:08 ` [PATCH 2/3] early_printk: Add force_early_printk kernel parameter Peter Zijlstra
2016-11-29 14:02 ` Petr Mladek
2016-10-18 17:08 ` Peter Zijlstra [this message]
2016-10-18 17:19 ` [PATCH 3/3] early_printk: Add simple serialization to early_vprintk() Steven Rostedt
2016-10-18 17:30 ` Peter Zijlstra
2016-10-18 17:53 ` Steven Rostedt
2016-11-29 14:10 ` Petr Mladek
2016-10-19 7:04 ` [PATCH 0/3] make printk work again Jan Kara
2016-10-19 9:24 ` Peter Zijlstra
2016-10-19 11:48 ` Sergey Senozhatsky
2016-10-19 12:21 ` Peter Zijlstra
2017-09-28 12:18 [PATCH 0/3] printk: Add force_early_printk boot param Peter Zijlstra
2017-09-28 12:18 ` [PATCH 3/3] early_printk: Add simple serialization to early_vprintk() Peter Zijlstra
2017-10-03 22:24 ` Steven Rostedt
2017-10-04 9:08 ` Peter Zijlstra
2017-10-04 13:04 ` Steven Rostedt
2017-10-04 13:08 ` Peter Zijlstra
2017-10-04 14:17 ` Paul E. McKenney
2017-10-04 14:43 ` Steven Rostedt
2017-10-04 14:52 ` Peter Zijlstra
2017-10-04 15:02 ` Steven Rostedt
2017-10-04 15:14 ` Paul E. McKenney
2017-10-04 15:24 ` Peter Zijlstra
2017-10-04 15:38 ` Paul E. McKenney
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=20161018171513.734367391@infradead.org \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=calvinowens@fb.com \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@techsingularity.net \
--cc=mingo@redhat.com \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=tglx@linutronix.de \
--cc=tj@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
Powered by JetHome