direct-io.hg

view xen/include/xen/trace.h @ 7567:a663683fe8cb

Remove trace compile option from Xen.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Oct 30 22:35:06 2005 +0100 (2005-10-30)
parents 06d84bf87159
children d8a39152f982
line source
1 /******************************************************************************
2 * include/xen/trace.h
3 *
4 * Xen Trace Buffer
5 *
6 * Copyright (C) 2003 by Intel Research Cambridge
7 *
8 * Author: Mark Williamson, mark.a.williamson@intel.com
9 * Date: January 2004
10 *
11 * Copyright (C) 2005 Bin Ren
12 *
13 * The trace buffer code is designed to allow debugging traces of Xen to be
14 * generated on UP / SMP machines. Each trace entry is timestamped so that
15 * it's possible to reconstruct a chronological record of trace events.
16 *
17 * Access to the trace buffers is via a dom0 hypervisor op and analysis of
18 * trace buffer contents can then be performed using a userland tool.
19 *
20 * See also common/trace.c and the dom0 op in include/public/dom0_ops.h
21 */
23 #ifndef __XEN_TRACE_H__
24 #define __XEN_TRACE_H__
26 #include <asm/page.h>
27 #include <xen/types.h>
28 #include <xen/sched.h>
29 #include <asm/atomic.h>
30 #include <asm/current.h>
31 #include <asm/msr.h>
32 #include <public/dom0_ops.h>
33 #include <public/trace.h>
35 extern struct t_buf *t_bufs[];
36 extern int tb_init_done;
37 extern unsigned long tb_cpu_mask;
38 extern u32 tb_event_mask;
40 /* Used to initialise trace buffer functionality */
41 void init_trace_bufs(void);
43 /* used to retrieve the physical address of the trace buffers */
44 int tb_control(dom0_tbufcontrol_t *tbc);
46 /**
47 * trace - Enters a trace tuple into the trace buffer for the current CPU.
48 * @event: the event type being logged
49 * @d1...d5: the data items for the event being logged
50 *
51 * Logs a trace record into the appropriate buffer. Returns nonzero on
52 * failure, otherwise 0. Failure occurs only if the trace buffers are not yet
53 * initialised.
54 */
55 static inline int trace(u32 event, unsigned long d1, unsigned long d2,
56 unsigned long d3, unsigned long d4, unsigned long d5)
57 {
58 atomic_t old, new, seen;
59 struct t_buf *buf;
60 struct t_rec *rec;
62 if ( !tb_init_done )
63 return -1;
65 if ( (tb_event_mask & event) == 0 )
66 return 0;
68 /* match class */
69 if ( ((tb_event_mask >> TRC_CLS_SHIFT) & (event >> TRC_CLS_SHIFT)) == 0 )
70 return 0;
72 /* then match subclass */
73 if ( (((tb_event_mask >> TRC_SUBCLS_SHIFT) & 0xf )
74 & ((event >> TRC_SUBCLS_SHIFT) & 0xf )) == 0 )
75 return 0;
77 if ( (tb_cpu_mask & (1UL << smp_processor_id())) == 0 )
78 return 0;
80 buf = t_bufs[smp_processor_id()];
82 do
83 {
84 old = buf->rec_idx;
85 _atomic_set(new, (_atomic_read(old) + 1) % buf->rec_num);
86 seen = atomic_compareandswap(old, new, &buf->rec_idx);
87 }
88 while ( unlikely(_atomic_read(seen) != _atomic_read(old)) );
90 wmb();
92 rec = &buf->rec[_atomic_read(old)];
93 rdtscll(rec->cycles);
94 rec->event = event;
95 rec->data[0] = d1;
96 rec->data[1] = d2;
97 rec->data[2] = d3;
98 rec->data[3] = d4;
99 rec->data[4] = d5;
101 return 0;
102 }
104 /* Avoids troubling the caller with casting their arguments to a trace macro */
105 #define trace_do_casts(e,d1,d2,d3,d4,d5) \
106 trace(e, \
107 (unsigned long)d1, \
108 (unsigned long)d2, \
109 (unsigned long)d3, \
110 (unsigned long)d4, \
111 (unsigned long)d5)
113 /* Convenience macros for calling the trace function. */
114 #define TRACE_0D(event) trace_do_casts(event,0, 0, 0, 0, 0 )
115 #define TRACE_1D(event,d) trace_do_casts(event,d, 0, 0, 0, 0 )
116 #define TRACE_2D(event,d1,d2) trace_do_casts(event,d1,d2,0, 0, 0 )
117 #define TRACE_3D(event,d1,d2,d3) trace_do_casts(event,d1,d2,d3,0, 0 )
118 #define TRACE_4D(event,d1,d2,d3,d4) trace_do_casts(event,d1,d2,d3,d4,0 )
119 #define TRACE_5D(event,d1,d2,d3,d4,d5) trace_do_casts(event,d1,d2,d3,d4,d5)
121 #endif /* __XEN_TRACE_H__ */