diff options
author | George Dunlap <gdunlap@xensource.com> | 2007-09-21 15:26:07 +0100 |
---|---|---|
committer | George Dunlap <gdunlap@xensource.com> | 2007-09-21 15:26:07 +0100 |
commit | 2ec9f061dc68fc474238150bb1a21c5a882407b0 (patch) | |
tree | 64f5bc7e4013ae20fc2af77b64b841245106e372 /xen/include/xen/trace.h | |
parent | 2aa818d3bb928b9c9cee965182b0e538748f2c41 (diff) | |
download | xen-2ec9f061dc68fc474238150bb1a21c5a882407b0.tar.gz xen-2ec9f061dc68fc474238150bb1a21c5a882407b0.tar.bz2 xen-2ec9f061dc68fc474238150bb1a21c5a882407b0.zip |
[xen][tracing] Introduce variable-size trace records
This patch introduces variable-size trace records. Each record consists of
a 32-bit "header", an optional cycle count, and up to seven more 32-bit words.
The header is packed with the following information:
bits 0-27: The trace event.
bits 28-30: The number of 32-bit "extra" words in the records
bit 31: Does the trace include a 64-bit tsc?
This patch standardizes behavior wrt 32 and 64-bit hypervisors and dom0s.
Note that this patch requires a new version of the xentrace daemon running in
dom0. The new daemon, instead of pre-pending the cpu to every record as it
writes it, inserts a "cpu change" record to the trace file that record the
cpu and the number of records it's about to write.
Signed-off-by: George Dunlap <gdunlap@xensource.com>
Diffstat (limited to 'xen/include/xen/trace.h')
-rw-r--r-- | xen/include/xen/trace.h | 83 |
1 files changed, 65 insertions, 18 deletions
diff --git a/xen/include/xen/trace.h b/xen/include/xen/trace.h index cd1422bc09..4bbb37d297 100644 --- a/xen/include/xen/trace.h +++ b/xen/include/xen/trace.h @@ -33,27 +33,74 @@ void init_trace_bufs(void); /* used to retrieve the physical address of the trace buffers */ int tb_control(struct xen_sysctl_tbuf_op *tbc); -void trace(u32 event, unsigned long d1, unsigned long d2, +void __trace_fixed(u32 event, unsigned long d1, unsigned long d2, unsigned long d3, unsigned long d4, unsigned long d5); +void __trace_var(u32 event, int cycles, int extra, unsigned char *extra_data); -/* Avoids troubling the caller with casting their arguments to a trace macro */ -#define trace_do_casts(e,d1,d2,d3,d4,d5) \ - do { \ - if ( unlikely(tb_init_done) ) \ - trace(e, \ - (unsigned long)(d1), \ - (unsigned long)(d2), \ - (unsigned long)(d3), \ - (unsigned long)(d4), \ - (unsigned long)(d5)); \ - } while ( 0 ) +static inline void trace_fixed(u32 event, unsigned long d1, + unsigned long d2, unsigned long d3, + unsigned long d4, unsigned long d5) +{ + if( unlikely(tb_init_done) ) + __trace_fixed(event, d1, d2, d3, d4, d5); +} + +static inline void trace_var(u32 event, int cycles, int extra, + unsigned char *extra_data) +{ + if( unlikely(tb_init_done) ) + __trace_var(event, cycles, extra, extra_data); +} /* Convenience macros for calling the trace function. */ -#define TRACE_0D(event) trace_do_casts(event,0, 0, 0, 0, 0 ) -#define TRACE_1D(event,d) trace_do_casts(event,d, 0, 0, 0, 0 ) -#define TRACE_2D(event,d1,d2) trace_do_casts(event,d1,d2,0, 0, 0 ) -#define TRACE_3D(event,d1,d2,d3) trace_do_casts(event,d1,d2,d3,0, 0 ) -#define TRACE_4D(event,d1,d2,d3,d4) trace_do_casts(event,d1,d2,d3,d4,0 ) -#define TRACE_5D(event,d1,d2,d3,d4,d5) trace_do_casts(event,d1,d2,d3,d4,d5) +#define TRACE_0D(_e) \ + do { \ + trace_var(_e, 1, 0, NULL); \ + } while ( 0 ) + +#define TRACE_1D(_e,_d) \ + do { \ + u32 _d1; \ + _d1 = _d; \ + trace_var(_e, 1, sizeof(_d1), (unsigned char *)&_d1); \ + } while ( 0 ) + +#define TRACE_2D(_e,d1,d2) \ + do { \ + u32 _d[2]; \ + _d[0]=d1; \ + _d[1]=d2; \ + trace_var(_e, 1, sizeof(*_d)*2, (unsigned char *)_d); \ + } while ( 0 ) + +#define TRACE_3D(_e,d1,d2,d3) \ + do { \ + u32 _d[3]; \ + _d[0]=d1; \ + _d[1]=d2; \ + _d[2]=d3; \ + trace_var(_e, 1, sizeof(*_d)*3, (unsigned char *)_d); \ + } while ( 0 ) + +#define TRACE_4D(_e,d1,d2,d3,d4) \ + do { \ + u32 _d[4]; \ + _d[0]=d1; \ + _d[1]=d2; \ + _d[2]=d3; \ + _d[3]=d4; \ + trace_var(_e, 1, sizeof(*_d)*4, (unsigned char *)_d); \ + } while ( 0 ) + +#define TRACE_5D(_e,d1,d2,d3,d4,d5) \ + do { \ + u32 _d[5]; \ + _d[0]=d1; \ + _d[1]=d2; \ + _d[2]=d3; \ + _d[3]=d4; \ + _d[4]=d5; \ + trace_var(_e, 1, sizeof(*_d)*5, (unsigned char *)_d); \ + } while ( 0 ) #endif /* __XEN_TRACE_H__ */ |