Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1494170
| From | Sergey Senozhatsky <sergey.senozhatsky@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC][PATCHv2 6/7] printk: report printk recursion from alt_printk flush |
| Date | 2016-09-30 17:30 +0200 |
| Message-ID | <sn7V8-3uh-19@gated-at.bofh.it> (permalink) |
| References | <sn7Lr-3r4-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
If we end up executing vprintk_alt() then we have a printk
recursion. Set alt_printk_ctx `ALT_PRINTK_RECURSION_MASK' bit
in vprintk_alt() to indicate that recutsion and report the
"BUG: recent printk recursion!" problem later from
__alt_printk_flush().
Example:
BUG: recent printk recursion!
------------[ cut here ]------------
WARNING: CPU: 3 PID: 366 at kernel/printk/printk.c:1803 vprintk_emit+0x139/0x38c
CPU: 3 PID: 366 Comm: bash
Call Trace:
[<ffffffff811be508>] dump_stack+0x4d/0x63
[<ffffffff81039932>] __warn+0xb8/0xd3
[<ffffffff810399b3>] warn_slowpath_null+0x18/0x1a
[<ffffffff8106bfdb>] vprintk_emit+0x139/0x38c
[<ffffffff8106c390>] vprintk_default+0x18/0x1a
[<ffffffff8106d1e6>] vprintk_func+0x65/0x67
[<ffffffff810ab27f>] printk+0x3e/0x46
[..]
[<ffffffff8145fb60>] entry_SYSCALL_64_fastpath+0x13/0x94
---[ end trace ]---
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
kernel/printk/alt_printk.c | 9 +++++++++
kernel/printk/internal.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/kernel/printk/alt_printk.c b/kernel/printk/alt_printk.c
index db0bfc8..0010089 100644
--- a/kernel/printk/alt_printk.c
+++ b/kernel/printk/alt_printk.c
@@ -150,6 +150,13 @@ static void __alt_printk_flush(struct irq_work *work)
more:
len = atomic_read(&s->len);
+ if (this_cpu_read(alt_printk_ctx) & ALT_PRINTK_RECURSION_MASK) {
+ const char *msg = "BUG: recent printk recursion!\n";
+
+ this_cpu_and(alt_printk_ctx, ~ALT_PRINTK_RECURSION_MASK);
+ alt_printk_flush_line(msg, strlen(msg));
+ }
+
/*
* This is just a paranoid check that nobody has manipulated
* the buffer an unexpected way. If we printed something then
@@ -290,6 +297,8 @@ static int vprintk_alt(const char *fmt, va_list args)
{
struct alt_printk_seq_buf *s = this_cpu_ptr(&alt_print_seq);
+ /* There is only one way to get here -- a printk recursion. */
+ this_cpu_or(alt_printk_ctx, ALT_PRINTK_RECURSION_MASK);
return alt_printk_log_store(s, fmt, args);
}
diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
index 6338f5b..403b6ed 100644
--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -37,6 +37,7 @@ static inline int get_nmi_message_lost(void)
#define ALT_PRINTK_CONTEXT_MASK 0x07ffffff
#define ALT_PRINTK_NMI_CONTEXT_MASK 0x08000000
+#define ALT_PRINTK_RECURSION_MASK 0x10000000
extern raw_spinlock_t logbuf_lock;
--
2.10.0.372.g6fe1b14
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC][PATCHv2 0/7] printk: use alt_printk to handle printk() recursive calls Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-09-30 17:20 +0200
[RFC][PATCHv2 7/7] printk: remove zap_locks() function Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-09-30 17:20 +0200
[RFC][PATCHv2 4/7] printk: make alt_printk available when config printk set Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-09-30 17:20 +0200
Re: [RFC][PATCHv2 4/7] printk: make alt_printk available when config printk set Petr Mladek <pmladek@suse.com> - 2016-10-06 17:30 +0200
Re: [RFC][PATCHv2 4/7] printk: make alt_printk available when config printk set Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-10-10 03:40 +0200
[RFC][PATCHv2 5/7] printk: use alternative printk buffers Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-09-30 17:20 +0200
[RFC][PATCHv2 3/7] printk: introduce per-cpu alt_print seq buffer Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-09-30 17:30 +0200
Re: [RFC][PATCHv2 3/7] printk: introduce per-cpu alt_print seq buffer Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-10-01 04:30 +0200
Re: [RFC][PATCHv2 3/7] printk: introduce per-cpu alt_print seq buffer Petr Mladek <pmladek@suse.com> - 2016-10-06 17:00 +0200
Re: [RFC][PATCHv2 3/7] printk: introduce per-cpu alt_print seq buffer Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-10-10 04:10 +0200
Re: [RFC][PATCHv2 3/7] printk: introduce per-cpu alt_print seq buffer Petr Mladek <pmladek@suse.com> - 2016-10-10 13:10 +0200
Re: [RFC][PATCHv2 3/7] printk: introduce per-cpu alt_print seq buffer Petr Mladek <pmladek@suse.com> - 2016-10-06 15:10 +0200
Re: [RFC][PATCHv2 3/7] printk: introduce per-cpu alt_print seq buffer Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-10-10 04:00 +0200
[RFC][PATCHv2 6/7] printk: report printk recursion from alt_printk flush Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-09-30 17:30 +0200
Re: [RFC][PATCHv2 6/7] printk: report printk recursion from alt_printk flush Petr Mladek <pmladek@suse.com> - 2016-10-06 17:50 +0200
Re: [RFC][PATCHv2 6/7] printk: report printk recursion from alt_printk flush Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-10-10 03:30 +0200
Re: [RFC][PATCHv2 6/7] printk: report printk recursion from alt_printk flush Petr Mladek <pmladek@suse.com> - 2016-10-10 13:10 +0200
Re: [RFC][PATCHv2 0/7] printk: use alt_printk to handle printk() recursive calls Petr Mladek <pmladek@suse.com> - 2016-10-06 18:00 +0200
Re: [RFC][PATCHv2 0/7] printk: use alt_printk to handle printk() recursive calls Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-10-10 03:30 +0200
csiph-web