Hello.

Tim Nguyen wrote:

> I'm not sure this is the correct solution, but I'd like to throw this
> out in order to illustrate a couple of cases where KGDB could deadlock
> when debugging under SMP.  I've seen this in i386 and x86_64 versions.

> It so happens that when you go into the INT3 handler, the IPI_NMI we
> send to the slave processors may arrive when one of those processors
> holds the runqueue (struct rq) lock.  This could cause a deadlock.  I've
> seen it happen in two places:

> 1)  While looping inside the kgdb_handle_exception(), your net polling
> Ethernet driver (mine is e1000) tries to free SKB's using
> dev_kfree_sdb_any().  If you don't bump your preempt to HARDIRQ, the
> function would eventually deadlock trying to get the rq lock
> (specifically in try_to_wake_up()).
> 2)  After INT3 ISR calls kgdb_handle_exception(), you hold the slave
> CPUs expecting to jump back on the next instruction via the DEBUG ISR.
> However, just as you leave the INT3 ISR, you get hit with the pending
> smp_apic_timer_interrrupt().  smp_apic_timer_interrrupt() eventually
> deadlocks trying to get the same rq lock.

> I guess there may be more of these gotchas, but my patch places
> protections against the cases I've seen.  Thanks for taking a look.

    Yeah, there are more... :-)
    Consider KGDBoE specific one where the networking drivers usually call 
disable_irq() in their poll_controller() methods: for example, if you happen 
to set a breakpoint into an interrupt handler for a device sharing an IRQ with 
the device you're using for KGDBoE, you're going to get a lockup since KGDB 
stops all CPUs and that interrupt's handling will never complete... And in RT 
kernel, you'll additionally get a loong stack trace as a bonus. :-)

> Tim Nguyen

WBR, Sergei

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Kgdb-bugreport mailing list
Kgdb-bugreport@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to