mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Jan Kara <jack@suse.cz>, Petr Mladek <pmladek@suse.com>,
	linux-kernel@vger.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Subject: [PATCH] printk: add cpu number to the recursion_msg message
Date: Tue,  5 Jan 2016 00:11:34 +0900	[thread overview]
Message-ID: <1451920294-1201-1-git-send-email-sergey.senozhatsky@gmail.com> (raw)

`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


             reply	other threads:[~2016-01-04 15:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-04 15:11 Sergey Senozhatsky [this message]
2016-01-04 15:28 ` Sergey Senozhatsky

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=1451920294-1201-1-git-send-email-sergey.senozhatsky@gmail.com \
    --to=sergey.senozhatsky@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=sergey.senozhatsky.work@gmail.com \
    /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

all inboxes | Powered by JetHome®