WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH] xen: debugging aid to track those who have disab

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] Re: [PATCH] xen: debugging aid to track those who have disabled preemption
From: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>
Date: Mon, 17 Jan 2011 14:17:33 +0000
Delivery-date: Mon, 17 Jan 2011 06:19:34 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <15e53a2463f084c3adbb.1295273752@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <15e53a2463f084c3adbb.1295273752@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
This is obviously a bit skanky but I figured it might be useful to
others in the future even if it never gets further than the list
archive.

Ian.

On Mon, 2011-01-17 at 14:15 +0000, Ian Campbell wrote:
> # 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

<Prev in Thread] Current Thread [Next in Thread>