kgdb: don't use a notifier to enter kgdb at panic; call directly
Right now kgdb/kdb hooks up to debug panics by registering for the panic
notifier. This works OK except that it means that kgdb/kdb gets called
_after_ the CPUs in the system are taken offline. That means that if
anything important was happening on those CPUs (like something that might
have contributed to the panic) you can't debug them.
Specifically I ran into a case where I got a panic because a task was
"blocked for more than 120 seconds" which was detected on CPU 2. I nicely
got shown stack traces in the kernel log for all CPUs including CPU 0,
which was running 'PID: 111 Comm: kworker/0:1H' and was in the middle of
I then ended up at the kdb prompt where switched over to kgdb to try to
look at local variables of the process on CPU 0. I found that I couldn't.
Digging more, I found that I had no info on any tasks running on CPUs
other than CPU 2 and that asking kdb for help showed me "Error: no saved
data for this cpu". This was because all the CPUs were offline.
Let's move the entry of kdb/kgdb to a direct call from panic() and stop
using the generic notifier. Putting a direct call in allows us to order
things more properly and it also doesn't seem like we're breaking any
abstractions by calling into the debugger from the panic function.
: This patch changes the way kdump and kgdb interact with each other.
: However it would seem rather odd to have both tools simultaneously armed
: and, even if they were, the user still has the option to use panic_timeout
: to force a kdump to happen. Thus I think the change of order is
Signed-off-by: Douglas Anderson <email@example.com>
Reviewed-by: Daniel Thompson <firstname.lastname@example.org>
Cc: Jason Wessel <email@example.com>
Cc: Kees Cook <firstname.lastname@example.org>
Cc: Borislav Petkov <email@example.com>
Cc: Thomas Gleixner <firstname.lastname@example.org>
Cc: Feng Tang <email@example.com>
Cc: YueHaibing <firstname.lastname@example.org>
Cc: Sergey Senozhatsky <email@example.com>
Cc: "Steven Rostedt (VMware)" <firstname.lastname@example.org>
Signed-off-by: Andrew Morton <email@example.com>
3 files changed