History

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 __mmc_switch(). 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. Daniel said: : 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 : acceptable.

Douglas Anderson committed 7 years ago

Commit 7d92bda1 parent ac7c3e43 files · +21 −20Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/kgdb.h+2−0
@@ -326,8 +326,10 @@ extern atomic_t kgdb_active; · 325 unmodified lines
326326 (raw_smp_processor_id() == atomic_read(&kgdb_active))
327327 extern bool dbg_is_early;
328328 extern void __init dbg_late_init(void);
329+extern void kgdb_panic(const char *msg);
329330 #else /* ! CONFIG_KGDB */
330331 #define in_dbg_master() (0)
331332 #define dbg_late_init()
333+static inline void kgdb_panic(const char *msg) {}
332334 #endif /* ! CONFIG_KGDB */
333335 #endif /* _KGDB_H_ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t