From: Petr Mladek <pmladek@suse.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org,
Geert Uytterhoeven <geert@linux-m68k.org>,
Arnd Bergmann <arnd@arndb.de>,
jkosina@suse.com
Subject: Re: [PATCH v4 0/4] Cleaning printk stuff in NMI context
Date: Fri, 11 Dec 2015 14:31:51 +0100 [thread overview]
Message-ID: <20151211133151.GA15602@pathway.suse.cz> (raw)
In-Reply-To: <1449840052-10491-1-git-send-email-pmladek@suse.com>
On Fri 2015-12-11 14:20:48, Petr Mladek wrote:
> Hi Andrew,
>
> this is just a quick respin of the previous version. It changes
> the few details as you suggested. Also it fixes the build problem
> on ARM as reported by Geert and Arnd.
>
> I rather send the whole patch set because there is the renamed header.
> Also the extra blank space affects two patches. I hope that it will
> safe you some work. Please, let me know if you would prefer
> incremental patches.
>
>
> Changes against v3:
>
> + used size_t for "len" and "size"
>
> + replaced WARN() with pr_err()
>
> + renamed kernel/printk/printk.h -> internal.h
>
> + fixed build on ARM (undefined NMI_LOG_BUF_SHIFT)
Please, find below the diff between the two branches based on v3 and
v4 of the patch set. I hope that it might help.
diff --git a/init/Kconfig b/init/Kconfig
index efcff25a112d..61cfd96a3c96 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -870,7 +870,7 @@ config NMI_LOG_BUF_SHIFT
int "Temporary per-CPU NMI log buffer size (12 => 4KB, 13 => 8KB)"
range 10 21
default 13
- depends on PRINTK && HAVE_NMI
+ depends on PRINTK_NMI
help
Select the size of a per-CPU buffer where NMI messages are temporary
stored. They are copied to the main log buffer in a safe context
diff --git a/kernel/printk/printk.h b/kernel/printk/internal.h
similarity index 97%
rename from kernel/printk/printk.h
rename to kernel/printk/internal.h
index 7f778b609492..341bedccc065 100644
--- a/kernel/printk/printk.h
+++ b/kernel/printk/internal.h
@@ -1,5 +1,5 @@
/*
- * printk.h - printk internal definitions
+ * internal.h - printk internal definitions
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
diff --git a/kernel/printk/nmi.c b/kernel/printk/nmi.c
index 78c07d441b4e..92c61e960c4a 100644
--- a/kernel/printk/nmi.c
+++ b/kernel/printk/nmi.c
@@ -22,7 +22,7 @@
#include <linux/irq_work.h>
#include <linux/printk.h>
-#include "printk.h"
+#include "internal.h"
/*
* printk() could not take logbuf_lock in NMI context. Instead,
@@ -60,12 +60,13 @@ static DEFINE_PER_CPU(struct nmi_seq_buf, nmi_print_seq);
static int vprintk_nmi(const char *fmt, va_list args)
{
struct nmi_seq_buf *s = this_cpu_ptr(&nmi_print_seq);
- int add = 0, len;
+ int add = 0;
+ size_t len;
again:
len = atomic_read(&s->len);
- if (len >= sizeof(s->buffer)) {
+ if (len >= sizeof(s->buffer)) {
atomic_inc(&nmi_message_lost);
return 0;
}
@@ -117,7 +118,8 @@ static void __printk_nmi_flush(struct irq_work *work)
static raw_spinlock_t read_lock =
__RAW_SPIN_LOCK_INITIALIZER(read_lock);
struct nmi_seq_buf *s = container_of(work, struct nmi_seq_buf, work);
- int len, size, i, last_i;
+ size_t len, size;
+ int i, last_i;
/*
* The lock has two functions. First, one reader has to flush all
@@ -137,7 +139,9 @@ more:
* the buffer an unexpected way. If we printed something then
* @len must only increase.
*/
- WARN_ON(i && i >= len);
+ if (i && i >= len)
+ pr_err("printk_nmi_flush: internal error: i=%d >= len=%lu\n",
+ i, len);
if (!len)
goto out; /* Someone else has already flushed the buffer. */
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index a6bb0b0838f3..71183a308b9e 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -54,7 +54,7 @@
#include "console_cmdline.h"
#include "braille.h"
-#include "printk.h"
+#include "internal.h"
int console_printk[4] = {
CONSOLE_LOGLEVEL_DEFAULT, /* console_loglevel */
next prev parent reply other threads:[~2015-12-11 13:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-11 13:20 Petr Mladek
2015-12-11 13:20 ` [PATCH v4 1/4] printk/nmi: Generic solution for safe printk in NMI Petr Mladek
2015-12-11 13:20 ` [PATCH v4 2/4] printk/nmi: Use IRQ work only when ready Petr Mladek
2015-12-11 13:20 ` [PATCH v4 3/4] printk/nmi: Warn when some message has been lost in NMI context Petr Mladek
2015-12-11 13:20 ` [PATCH v4 4/4] printk/nmi: Increase the size of NMI buffer and make it configurable Petr Mladek
2015-12-11 13:31 ` Petr Mladek [this message]
2016-01-20 21:17 ` [PATCH v4 0/4] Cleaning printk stuff in NMI context Andrew Morton
2016-01-21 11:30 ` Petr Mladek
2016-02-08 16:38 ` Petr Mladek
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=20151211133151.GA15602@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=geert@linux-m68k.org \
--cc=jkosina@suse.com \
--cc=linux-kernel@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
Powered by JetHome