linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Korty <joe.korty@concurrent-rt.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	linux-rt-users@vger.kernel.org
Subject: [5.4-rt] kdb: push 'bt' command output to console immediately.
Date: Wed, 20 May 2020 11:16:14 -0400	[thread overview]
Message-ID: <20200520151613.GA54006@zipoli.concurrent-rt.com> (raw)

[5.4-rt] kdb: push 'bt' command output to console immediately.

The rt patch for 5.4 and 5.2 broke kdb slightly.  The kdb
'bt' command now prints a single line then returns to the
kdb prompt.  There is no stack trace being shown.

The missing stack trace is in fact being generated, but
is instead being spooled into an internal buffer.

On kdb return-to-kernel (ie, the 'go' command), the spooled
output is displayed.

This behavour occurs because kdb calls a non-kdb function,
stack_dump(), to decode and dump the stack.  That function
uses printk's.  In an NMI handler (of which kgdb/kdb is an
example), printk spools all output generated, and prints
that spooled output once the handler exits.

To fix this, mainline has long had a tap in printk that
forces it to divert to kdb_printf whenever kdb invokes
some out-of-kdb function.  That tap, in 5.4-rt, is for some
reason no longer functional.  This might have something to
do with the printk subsystem partial rewrite now present
in the rt patch.

Here is my test sequence.  This example assumes one is
using a serial console not a KVM.

   echo ttyS0 > /sys/module/kgdboc/parameters/kgdboc
   echo g > /proc/sysrq-trigger
   bt
   go

Here are the kernels I ran the above test on:

   4.19.120-rt52 -- Pass
   5.0.21-rt16   -- Pass (*)
   5.2.21-rt15   -- Fail
   5.4.40-rt24   -- Fail

* - Passed on 2nd boot.  First boot locked the system up
    on the 'echo g'.  No oops.

I have attached a small patch that Seems To Work.  It
taps earlier into printk than the official tap does.

Signed-off-by: Joe Korty <joe.korty@concurrent-rt.com>

Index: b/kernel/printk/printk.c
===================================================================
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2054,7 +2054,10 @@ asmlinkage __visible int printk(const ch
 	int r;
 
 	va_start(args, fmt);
-	r = vprintk_func(fmt, args);
+	if (kdb_trap_printk)
+		r = vkdb_printf(KDB_MSGSRC_INTERNAL, fmt, args);
+	else
+		r = vprintk_func(fmt, args);
 	va_end(args);
 
 	return r;

             reply	other threads:[~2020-05-20 15:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-20 15:16 Joe Korty [this message]
2020-05-20 15:33 ` [5.4-rt] kdb: push 'bt' command output to console immediately John Ogness
2020-05-20 15:40   ` Joe Korty
2020-05-26 16:44   ` Sebastian Andrzej Siewior
2020-05-26 16:55     ` Joe Korty
2020-06-26 13:05       ` Joe Korty

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=20200520151613.GA54006@zipoli.concurrent-rt.com \
    --to=joe.korty@concurrent-rt.com \
    --cc=bigeasy@linutronix.de \
    --cc=john.ogness@linutronix.de \
    --cc=linux-rt-users@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).