kgdb in git-x86#mm review

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Date: Sunday, February 10, 2008 - 9:53 pm

I sent Jan & Jason earlier a quick review of the kgdb code currently in git-x86#mm.

The kgdb code in git-x86#mm is right now is totally broken of course because the CFI
annotations in assembler code are gone now, but they are needed for gdb use. 
And the bogus fault handling code is still in there, but Jason apprently fixed that one.

Here are the other commments I wrote just in case someone is interested.
Overall I would say there is quite a lot of stuff to clean up still.

<snip>

ok, doing a review on the code in git-x86#mm. I have not read
everything in detail, just a quick skip over.

My personal test for clean kernel debugger integration is if the
debugger could be made a loadable (but not unloadable) module with
minor/no effort. How far away is your code from that?

The 32bit in_exception_stack code looks weird. Are you sure you cannot
just use the pt_regs passed to the die notifier?

It might be safer to explicitely disable interrupts early in the notifier.

You should probably use simple_strtoul() instead of inventing an
own hex parser in kgdb.c. And sprintf instead of an own hex writer.
In general more use sprintf would probably shorten a lot of the parser
code.

The num_online_cpu()s check in getthread() looks weird. What is that
supposed to do?

kgdb_softlock_notify: I think the right way to handle this is just
calling touch_softlockup_watchdog() (or perhaps better touch_nmi_watchdog)
Actually it should be only needed once when you exit the debugger
for soft lockup, but regularly for nmi watchdog.

On x86 it is ok, but on other architectures i'm suspect the SMP
synchronization with atomics might benefit from more memory barriers.

gdb_cmd_reboot: always calling emergency_sync looks dangerous.
In fact i suspect if you hold the other CPUs the changes are good
it will lock up. You should at least offer a option to not call that
(or better don't do it by default). Even machine_start is likely
lock up actually if the other CPUs are truly halted (as they should
be) because it will try to halt them. So if anything I suspect you
need to exit the debugger first before executing this.

The logic to halt all the other CPUs in kgdb_handle_exception et.al.
looks a little fragile. It would be probably best to use the same
as kcrash uses factored out into a common function.
One obvious problem is that it is racy against cpu hotplug, but there
are likely others too. With a better implementation you likely
wouldn't need the mdelay(2) hack further down.

You should use raw spinlocks everywhere in the debugger -- i don't
think you want lockdep etc. anywhere.

The unregister hook stuff looks racy against NMIs etc.

-Andi



--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
kgdb in git-x86#mm review, Andi Kleen, (Sun Feb 10, 9:53 pm)
Re: kgdb in git-x86#mm review, Mark Lord, (Mon Feb 11, 12:03 pm)
Re: kgdb in git-x86#mm review, Frank Ch. Eigler, (Mon Feb 11, 11:32 am)
Re: [git pull] kgdb-light -v8,, Jan Kiszka, (Mon Feb 11, 12:41 pm)
Re: [git pull] kgdb-light -v8,, Ingo Molnar, (Mon Feb 11, 12:54 pm)
[git pull] kgdb-light -v9, Ingo Molnar, (Mon Feb 11, 7:03 pm)
Re: [git pull] kgdb-light -v9, Andi Kleen, (Tue Feb 12, 6:03 am)
[git pull] kgdb-light -v10, Ingo Molnar, (Tue Feb 12, 7:27 am)
Re: [git pull] kgdb-light -v10, Domenico Andreoli, (Tue Feb 12, 9:18 am)
Re: [git pull] kgdb-light -v10, Jason Wessel, (Tue Feb 12, 9:59 am)
Re: [git pull] kgdb-light -v10, Domenico Andreoli, (Tue Feb 12, 11:45 am)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 8:19 am)
Re: [git pull] kgdb-light -v10, Ingo Molnar, (Tue Feb 12, 8:38 am)
Re: [git pull] kgdb-light -v10, Jason Wessel, (Tue Feb 12, 9:30 am)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 10:39 am)
Re: [git pull] kgdb-light -v10, Jason Wessel, (Tue Feb 12, 10:35 am)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 11:36 am)
Re: [git pull] kgdb-light -v10, Jason Wessel, (Tue Feb 12, 12:21 pm)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 1:10 pm)
Re: [git pull] kgdb-light -v10, Jason Wessel, (Tue Feb 12, 12:48 pm)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 9:50 am)
Re: [git pull] kgdb-light -v10, Ingo Molnar, (Tue Feb 12, 11:28 am)
Re: [git pull] kgdb-light -v10, Linus Torvalds, (Tue Feb 12, 12:46 pm)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 2:20 pm)
Re: [git pull] kgdb-light -v10, Andrew Morton, (Tue Feb 12, 2:20 pm)
Re: [git pull] kgdb-light -v10, Frank Ch. Eigler, (Tue Feb 12, 3:34 pm)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 4:16 pm)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 3:16 pm)
Re: [git pull] kgdb-light -v10, Ingo Molnar, (Tue Feb 12, 5:01 pm)
Re: [git pull] kgdb-light -v10, Linus Torvalds, (Tue Feb 12, 2:11 pm)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 3:22 pm)
Re: [git pull] kgdb-light -v10, Linus Torvalds, (Tue Feb 12, 3:01 pm)
Re: [git pull] kgdb-light -v10, Ingo Molnar, (Tue Feb 12, 1:01 pm)
Re: [git pull] kgdb-light -v10, Ingo Molnar, (Tue Feb 12, 1:10 pm)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 12:11 pm)
Re: [git pull] kgdb-light -v10, Linus Torvalds, (Tue Feb 12, 12:25 pm)
Re: [git pull] kgdb-light -v10, Jason Wessel, (Fri Feb 15, 4:36 pm)
Re: [git pull] kgdb-light -v10, Ingo Molnar, (Tue Feb 12, 12:42 pm)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 1:07 pm)
Re: [RFC][PATCH] modular kgdb-light, Jason Wessel, (Fri Feb 15, 4:24 pm)
Re: [git pull] kgdb-light -v10, Ingo Molnar, (Tue Feb 12, 12:24 pm)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 1:01 pm)
Re: [git pull] kgdb-light -v10, Ingo Molnar, (Tue Feb 12, 11:16 am)
Re: [git pull] kgdb-light -v10, Andi Kleen, (Tue Feb 12, 11:28 am)
Re: [git pull] kgdb-light -v9, Roland McGrath, (Tue Feb 12, 6:26 am)
Re: [git pull] kgdb-light -v9, Ingo Molnar, (Tue Feb 12, 6:34 am)
Re: [git pull] kgdb-light -v9, Sam Ravnborg, (Tue Feb 12, 5:35 am)
Re: kgdb in git-x86#mm review, Andi Kleen, (Mon Feb 11, 12:11 pm)