Thread (28 messages) 28 messages, 9 authors, 2016-03-18

Re: [PATCH v2 1/5] printk/nmi: Generic solution for safe printk in NMI

From: Petr Mladek <pmladek@suse.com>
Date: 2015-12-04 15:29:31
Also in: linux-arm-kernel, linux-mips, linux-sh, lkml, sparclinux

On Wed 2015-12-02 13:45:16, Michael Ellerman wrote:
On Fri, 2015-11-27 at 12:09 +0100, Petr Mladek wrote:
quoted
printk() takes some locks and could not be used a safe way in NMI
context.

The chance of a deadlock is real especially when printing
stacks from all CPUs. This particular problem has been addressed
on x86 by the commit a9edc8809328 ("x86/nmi: Perform a safe NMI stack
trace on all CPUs").
...
quoted
diff --git a/kernel/printk/nmi.c b/kernel/printk/nmi.c
new file mode 100644
index 000000000000..3989e13a0021
--- /dev/null
+++ b/kernel/printk/nmi.c
@@ -0,0 +1,200 @@
...
quoted
+
+struct nmi_seq_buf {
+	atomic_t		len;	/* length of written data */
+	struct irq_work		work;	/* IRQ work that flushes the buffer */
+	unsigned char		buffer[PAGE_SIZE - sizeof(atomic_t) -
+				       sizeof(struct irq_work)];
+};
+static DEFINE_PER_CPU(struct nmi_seq_buf, nmi_print_seq);

PAGE_SIZE isn't always 4K.

On typical powerpc systems this will give you 128K, and on some 512K, which is
probably not what we wanted.
Good point!
The existing code just did:

#define NMI_BUF_SIZE           4096
I will change this to 8192. The 4kB were not enough in some cases.

Best Regards,
Petr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help