ia64/xen-unstable

changeset 17519:f73b9a286ee4

trace: Notify dom0 from tasklet context.

Avoids deadlocks by avoiding calling into scheduler recursively
(__trace_var() is sometimes called with scheduler locks held).

Signed-off-by: Naoki Nishiguchi <nisiguti@jp.fujitsu.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Apr 24 09:58:29 2008 +0100 (2008-04-24)
parents 77dec8732cde
children e382c13fab2b
files xen/common/trace.c
line diff
     1.1 --- a/xen/common/trace.c	Wed Apr 23 16:58:44 2008 +0100
     1.2 +++ b/xen/common/trace.c	Thu Apr 24 09:58:29 2008 +0100
     1.3 @@ -374,6 +374,15 @@ static inline int insert_lost_records(st
     1.4                             (unsigned char *)&ed);
     1.5  }
     1.6  
     1.7 +/*
     1.8 + * Notification is performed in qtasklet to avoid deadlocks with contexts
     1.9 + * which __trace_var() may be called from (e.g., scheduler critical regions).
    1.10 + */
    1.11 +static void trace_notify_dom0(unsigned long unused)
    1.12 +{
    1.13 +    send_guest_global_virq(dom0, VIRQ_TBUF);
    1.14 +}
    1.15 +static DECLARE_TASKLET(trace_notify_dom0_tasklet, trace_notify_dom0, 0);
    1.16  
    1.17  /**
    1.18   * trace - Enters a trace tuple into the trace buffer for the current CPU.
    1.19 @@ -506,7 +515,7 @@ void __trace_var(u32 event, int cycles, 
    1.20      /* Notify trace buffer consumer that we've crossed the high water mark. */
    1.21      if ( started_below_highwater &&
    1.22           (calc_unconsumed_bytes(buf) >= t_buf_highwater) )
    1.23 -        send_guest_global_virq(dom0, VIRQ_TBUF);
    1.24 +        tasklet_schedule(&trace_notify_dom0_tasklet);
    1.25  }
    1.26  
    1.27  /*