[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] xen: debugging aid to track those who have disabled preemption
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1295273570 0 # Node ID 15e53a2463f084c3adbbb21b4deb30d0d4f79b45 # Parent 711cbaa038cae8c03cf825165d2e07b0a3c94f89 xen: debugging aid to track those who have disabled preemption. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff -r 711cbaa038ca -r 15e53a2463f0 xen/common/preempt.c --- a/xen/common/preempt.c Mon Jan 17 14:12:48 2011 +0000 +++ b/xen/common/preempt.c Mon Jan 17 14:12:50 2011 +0000 @@ -21,5 +21,48 @@ */ #include <xen/preempt.h> +#include <xen/symbols.h> DEFINE_PER_CPU(unsigned int, __preempt_count); + +#ifdef DEBUG_PREEMPT + +#define NR_PREEMPT_DEBUG 16 + +struct preempt_info { + const char *file; + unsigned long line; + const char *func; + unsigned long r0, r1; +}; +typedef struct preempt_info preempt_info_t[NR_PREEMPT_DEBUG]; + +DEFINE_PER_CPU(preempt_info_t, __preempt_debug); + +void preempt_debug(const char *file, const unsigned long line, const char *func) +{ + struct preempt_info *pi = &this_cpu(__preempt_debug)[preempt_count()]; + if (preempt_count() >= NR_PREEMPT_DEBUG) + return; + pi->file = file; + pi->func = func; + pi->line = line; + pi->r0 = (unsigned long)__builtin_return_address(0); + pi->r1 = (unsigned long)__builtin_return_address(1); +} + +void preempt_debug_dump(void) +{ + struct preempt_info *pi = this_cpu(__preempt_debug); + int i, count = preempt_count(); + + printk("preempt debug on CPU%d, count %d:\n", smp_processor_id(), count); + count = min(count, NR_PREEMPT_DEBUG); + for(i=0;i<count;i++, pi++) { + printk("%d @ 0x%p\n", i, pi); + printk(" %s %s:%ld\n", pi->func, pi->file, pi->line); + printk(" %#lx", pi->r0); print_symbol(" %s\n", pi->r0); + printk(" %#lx", pi->r1); print_symbol(" %s\n", pi->r1); + } +} +#endif diff -r 711cbaa038ca -r 15e53a2463f0 xen/drivers/char/console.c --- a/xen/drivers/char/console.c Mon Jan 17 14:12:48 2011 +0000 +++ b/xen/drivers/char/console.c Mon Jan 17 14:12:50 2011 +0000 @@ -961,6 +961,7 @@ void panic(const char *fmt, ...) printk("Panic on CPU %d:\n", smp_processor_id()); printk("%s", buf); printk("****************************************\n\n"); + preempt_debug_dump(); if ( opt_noreboot ) printk("Manual reset required ('noreboot' specified)\n"); else diff -r 711cbaa038ca -r 15e53a2463f0 xen/include/xen/preempt.h --- a/xen/include/xen/preempt.h Mon Jan 17 14:12:48 2011 +0000 +++ b/xen/include/xen/preempt.h Mon Jan 17 14:12:50 2011 +0000 @@ -18,7 +18,18 @@ DECLARE_PER_CPU(unsigned int, __preempt_ #define preempt_count() (this_cpu(__preempt_count)) +//#define DEBUG_PREEMPT + +#ifdef DEBUG_PREEMPT +extern void preempt_debug(const char *file, const unsigned long line, const char *func); +extern void preempt_debug_dump(void); +#else +static inline void preempt_debug(const char *file, const unsigned long line, const char *func) {} +static inline void preempt_debug_dump(void) {} +#endif + #define preempt_disable() do { \ + preempt_debug(__FILE__, __LINE__, __func__);\ preempt_count()++; \ barrier(); \ } while (0) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |