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 */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to