* [PATCH] printk: add cpu number to the recursion_msg message
@ 2016-01-04 15:11 Sergey Senozhatsky
2016-01-04 15:28 ` Sergey Senozhatsky
0 siblings, 1 reply; 2+ messages in thread
From: Sergey Senozhatsky @ 2016-01-04 15:11 UTC (permalink / raw)
To: Andrew Morton
Cc: Jan Kara, Petr Mladek, linux-kernel, Sergey Senozhatsky,
Sergey Senozhatsky
`recursion_bug' occupies 4 bytes to just tell us there was a recent
recursion bug (basically 'bool'). Make it a bit more informative and
keep in `recursion_bug' smp_processor_id of the CPU (the most recent
one) that has caused a recursive printk bug. For instance, the error
message will change from
BUG: recent printk recursion!
to
BUG: recent printk recursion on CPU5!
Rename `recursion_bug' to `recursion_bug_cpu'.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
kernel/printk/printk.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 1fc89ba..a578653 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1662,7 +1662,7 @@ asmlinkage int vprintk_emit(int facility, int level,
const char *dict, size_t dictlen,
const char *fmt, va_list args)
{
- static int recursion_bug;
+ static int recursion_bug_cpu = -1;
static char textbuf[LOG_LINE_MAX];
char *text = textbuf;
size_t text_len = 0;
@@ -1699,7 +1699,7 @@ asmlinkage int vprintk_emit(int facility, int level,
* it can be printed at the next appropriate moment:
*/
if (!oops_in_progress && !lockdep_recursing(current)) {
- recursion_bug = 1;
+ recursion_bug_cpu = this_cpu;
local_irq_restore(flags);
return 0;
}
@@ -1710,15 +1710,18 @@ asmlinkage int vprintk_emit(int facility, int level,
raw_spin_lock(&logbuf_lock);
logbuf_cpu = this_cpu;
- if (unlikely(recursion_bug)) {
- static const char recursion_msg[] =
- "BUG: recent printk recursion!";
+ if (unlikely(recursion_bug_cpu != -1)) {
+ static char recursion_msg[41];
+ size_t len;
+
+ len = sprintf(recursion_msg,
+ "BUG: recent printk recursion on CPU%d!",
+ recursion_bug_cpu);
- recursion_bug = 0;
+ recursion_bug_cpu = -1;
/* emit KERN_CRIT message */
printed_len += log_store(0, 2, LOG_PREFIX|LOG_NEWLINE, 0,
- NULL, 0, recursion_msg,
- strlen(recursion_msg));
+ NULL, 0, recursion_msg, len);
}
nmi_message_lost = get_nmi_message_lost();
--
2.7.0.rc0.20.g4b9ab0e
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] printk: add cpu number to the recursion_msg message
2016-01-04 15:11 [PATCH] printk: add cpu number to the recursion_msg message Sergey Senozhatsky
@ 2016-01-04 15:28 ` Sergey Senozhatsky
0 siblings, 0 replies; 2+ messages in thread
From: Sergey Senozhatsky @ 2016-01-04 15:28 UTC (permalink / raw)
To: Andrew Morton
Cc: Jan Kara, Petr Mladek, linux-kernel, Sergey Senozhatsky,
Sergey Senozhatsky
On (01/05/16 00:11), Sergey Senozhatsky wrote:
> `recursion_bug' occupies 4 bytes to just tell us there was a recent
> recursion bug (basically 'bool'). Make it a bit more informative and
> keep in `recursion_bug' smp_processor_id of the CPU (the most recent
> one) that has caused a recursive printk bug. For instance, the error
> message will change from
> BUG: recent printk recursion!
> to
> BUG: recent printk recursion on CPU5!
>
on the other hand -- no, this is silly. disregard, sorry. It's just my
setup that confused me.
but I think we can change `recursion_bug' type to `bool'. what do you think?
===8<===8<===
>From d772453988289efc3bae5598c3c12c6e7ffb801a Mon Sep 17 00:00:00 2001
From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Date: Tue, 5 Jan 2016 00:21:17 +0900
Subject: [PATCH] printk: change recursion_bug type to bool
`recursion_bug' is used as recursion_bug toggle, so make it `bool'.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
kernel/printk/printk.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 1fc89ba..d0b8697 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1662,7 +1662,7 @@ asmlinkage int vprintk_emit(int facility, int level,
const char *dict, size_t dictlen,
const char *fmt, va_list args)
{
- static int recursion_bug;
+ static bool recursion_bug;
static char textbuf[LOG_LINE_MAX];
char *text = textbuf;
size_t text_len = 0;
@@ -1699,7 +1699,7 @@ asmlinkage int vprintk_emit(int facility, int level,
* it can be printed at the next appropriate moment:
*/
if (!oops_in_progress && !lockdep_recursing(current)) {
- recursion_bug = 1;
+ recursion_bug = true;
local_irq_restore(flags);
return 0;
}
@@ -1714,7 +1714,7 @@ asmlinkage int vprintk_emit(int facility, int level,
static const char recursion_msg[] =
"BUG: recent printk recursion!";
- recursion_bug = 0;
+ recursion_bug = false;
/* emit KERN_CRIT message */
printed_len += log_store(0, 2, LOG_PREFIX|LOG_NEWLINE, 0,
NULL, 0, recursion_msg,
--
2.7.0.rc0.20.g4b9ab0e
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-04 15:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-04 15:11 [PATCH] printk: add cpu number to the recursion_msg message Sergey Senozhatsky
2016-01-04 15:28 ` Sergey Senozhatsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).