diff options
author | kaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk> | 2005-10-30 23:17:58 +0100 |
---|---|---|
committer | kaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk> | 2005-10-30 23:17:58 +0100 |
commit | b55e426e37b4b6d7c6ed1a76e4d445bfc4e6b8ac (patch) | |
tree | e165a42a48c5a23ccb26250e3b74ca6735be9cc4 /xen/include/xen/trace.h | |
parent | 1cd7c2a733840500759e527f7440063ae3a88482 (diff) | |
download | xen-b55e426e37b4b6d7c6ed1a76e4d445bfc4e6b8ac.tar.gz xen-b55e426e37b4b6d7c6ed1a76e4d445bfc4e6b8ac.tar.bz2 xen-b55e426e37b4b6d7c6ed1a76e4d445bfc4e6b8ac.zip |
Tracing cleanups and simplify tb_set_size(). Dynamic
buffer shrinking is unsafe without heavier weight SMP
synchronisation.
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'xen/include/xen/trace.h')
-rw-r--r-- | xen/include/xen/trace.h | 79 |
1 files changed, 12 insertions, 67 deletions
diff --git a/xen/include/xen/trace.h b/xen/include/xen/trace.h index 4e2b431eeb..8e5e282769 100644 --- a/xen/include/xen/trace.h +++ b/xen/include/xen/trace.h @@ -32,10 +32,7 @@ #include <public/dom0_ops.h> #include <public/trace.h> -extern struct t_buf *t_bufs[]; extern int tb_init_done; -extern unsigned long tb_cpu_mask; -extern u32 tb_event_mask; /* Used to initialise trace buffer functionality */ void init_trace_bufs(void); @@ -43,72 +40,20 @@ void init_trace_bufs(void); /* used to retrieve the physical address of the trace buffers */ int tb_control(dom0_tbufcontrol_t *tbc); -/** - * trace - Enters a trace tuple into the trace buffer for the current CPU. - * @event: the event type being logged - * @d1...d5: the data items for the event being logged - * - * Logs a trace record into the appropriate buffer. Returns nonzero on - * failure, otherwise 0. Failure occurs only if the trace buffers are not yet - * initialised. - */ -static inline int trace(u32 event, unsigned long d1, unsigned long d2, - unsigned long d3, unsigned long d4, unsigned long d5) -{ - atomic_t old, new, seen; - struct t_buf *buf; - struct t_rec *rec; - - if ( !tb_init_done ) - return -1; - - if ( (tb_event_mask & event) == 0 ) - return 0; - - /* match class */ - if ( ((tb_event_mask >> TRC_CLS_SHIFT) & (event >> TRC_CLS_SHIFT)) == 0 ) - return 0; - - /* then match subclass */ - if ( (((tb_event_mask >> TRC_SUBCLS_SHIFT) & 0xf ) - & ((event >> TRC_SUBCLS_SHIFT) & 0xf )) == 0 ) - return 0; - - if ( (tb_cpu_mask & (1UL << smp_processor_id())) == 0 ) - return 0; - - buf = t_bufs[smp_processor_id()]; - - do - { - old = buf->rec_idx; - _atomic_set(new, (_atomic_read(old) + 1) % buf->rec_num); - seen = atomic_compareandswap(old, new, &buf->rec_idx); - } - while ( unlikely(_atomic_read(seen) != _atomic_read(old)) ); - - wmb(); - - rec = &buf->rec[_atomic_read(old)]; - rdtscll(rec->cycles); - rec->event = event; - rec->data[0] = d1; - rec->data[1] = d2; - rec->data[2] = d3; - rec->data[3] = d4; - rec->data[4] = d5; - - return 0; -} +void trace(u32 event, unsigned long d1, unsigned long d2, + unsigned long d3, unsigned long d4, unsigned long d5); /* Avoids troubling the caller with casting their arguments to a trace macro */ -#define trace_do_casts(e,d1,d2,d3,d4,d5) \ - trace(e, \ - (unsigned long)d1, \ - (unsigned long)d2, \ - (unsigned long)d3, \ - (unsigned long)d4, \ - (unsigned long)d5) +#define trace_do_casts(e,d1,d2,d3,d4,d5) \ + do { \ + if ( tb_init_done ) \ + trace(e, \ + (unsigned long)d1, \ + (unsigned long)d2, \ + (unsigned long)d3, \ + (unsigned long)d4, \ + (unsigned long)d5); \ + } while ( 0 ) /* Convenience macros for calling the trace function. */ #define TRACE_0D(event) trace_do_casts(event,0, 0, 0, 0, 0 ) |